2021-01-12 14:13:53 +01:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import i2c, rc522
|
|
|
|
from esphome.const import CONF_ID
|
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
CODEOWNERS = ["@glmnet"]
|
|
|
|
DEPENDENCIES = ["i2c"]
|
|
|
|
AUTO_LOAD = ["rc522"]
|
2021-05-15 07:02:52 +02:00
|
|
|
MULTI_CONF = True
|
2021-01-12 14:13:53 +01:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
rc522_i2c_ns = cg.esphome_ns.namespace("rc522_i2c")
|
|
|
|
RC522I2C = rc522_i2c_ns.class_("RC522I2C", rc522.RC522, i2c.I2CDevice)
|
2021-01-12 14:13:53 +01:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
CONFIG_SCHEMA = cv.All(
|
|
|
|
rc522.RC522_SCHEMA.extend(
|
|
|
|
{
|
|
|
|
cv.GenerateID(): cv.declare_id(RC522I2C),
|
|
|
|
}
|
|
|
|
).extend(i2c.i2c_device_schema(0x2C))
|
|
|
|
)
|
2021-01-12 14:13:53 +01:00
|
|
|
|
|
|
|
|
2021-05-24 10:58:29 +02:00
|
|
|
async def to_code(config):
|
2021-01-12 14:13:53 +01:00
|
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
2021-05-24 10:58:29 +02:00
|
|
|
await rc522.setup_rc522(var, config)
|
|
|
|
await i2c.register_i2c_device(var, config)
|