* split to spi and i2c * fix binary_sensor * i2c comms ready * fix rc522_spi binary sensor compat * lint * lint * add test and codeowners * fix refactor
22 lines
648 B
Python
22 lines
648 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import spi, rc522
|
|
from esphome.const import CONF_ID
|
|
|
|
CODEOWNERS = ['@glmnet']
|
|
DEPENDENCIES = ['spi']
|
|
AUTO_LOAD = ['rc522']
|
|
|
|
rc522_spi_ns = cg.esphome_ns.namespace('rc522_spi')
|
|
RC522Spi = rc522_spi_ns.class_('RC522Spi', rc522.RC522, spi.SPIDevice)
|
|
|
|
CONFIG_SCHEMA = cv.All(rc522.RC522_SCHEMA.extend({
|
|
cv.GenerateID(): cv.declare_id(RC522Spi),
|
|
}).extend(spi.spi_device_schema(cs_pin_required=True)))
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield rc522.setup_rc522(var, config)
|
|
yield spi.register_spi_device(var, config)
|