binary sensor

This commit is contained in:
J. Nick Koston 2023-06-07 11:00:08 -05:00
parent 9293be012a
commit 0fb3f6e13f
No known key found for this signature in database
1 changed files with 5 additions and 6 deletions

View File

@ -12,17 +12,16 @@ RATGDOBinarySensor = ratgdo_ns.class_(
"RATGDOBinarySensor", binary_sensor.BinarySensor, cg.Component
)
CONF_TYPE = "type"
TYPES = {"motion", "obstruction"}
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{cv.Optional(type): binary_sensor.binary_sensor_schema() for type in TYPES}
{cv.Required(CONF_TYPE): str}
)
async def to_code(config):
for type in TYPES:
if type in config:
conf = config[type]
var = await binary_sensor.new_binary_sensor(conf)
await register_ratgdo_child(var, config)
var = await binary_sensor.new_binary_sensor(config)
await cg.register_component(var, config)
await register_ratgdo_child(var, config)