2019-04-17 12:06:00 +02:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import binary_sensor, rdm6300
|
2022-02-17 22:39:59 +01:00
|
|
|
from esphome.const import CONF_UID
|
2019-04-17 12:06:00 +02:00
|
|
|
from . import rdm6300_ns
|
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
DEPENDENCIES = ["rdm6300"]
|
2019-04-17 12:06:00 +02:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
CONF_RDM6300_ID = "rdm6300_id"
|
|
|
|
RDM6300BinarySensor = rdm6300_ns.class_(
|
|
|
|
"RDM6300BinarySensor", binary_sensor.BinarySensor
|
|
|
|
)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
2022-02-17 22:39:59 +01:00
|
|
|
CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(RDM6300BinarySensor).extend(
|
2021-03-07 20:03:16 +01:00
|
|
|
{
|
|
|
|
cv.GenerateID(CONF_RDM6300_ID): cv.use_id(rdm6300.RDM6300Component),
|
|
|
|
cv.Required(CONF_UID): cv.uint32_t,
|
|
|
|
}
|
|
|
|
)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
|
2021-05-24 10:58:29 +02:00
|
|
|
async def to_code(config):
|
2022-02-17 22:39:59 +01:00
|
|
|
var = await binary_sensor.new_binary_sensor(config)
|
2019-04-22 21:56:30 +02:00
|
|
|
|
2021-05-24 10:58:29 +02:00
|
|
|
hub = await cg.get_variable(config[CONF_RDM6300_ID])
|
2019-04-17 12:06:00 +02:00
|
|
|
cg.add(hub.register_card(var))
|
2019-04-22 21:56:30 +02:00
|
|
|
cg.add(var.set_id(config[CONF_UID]))
|