binary sensor
This commit is contained in:
parent
9293be012a
commit
0fb3f6e13f
|
@ -12,17 +12,16 @@ RATGDOBinarySensor = ratgdo_ns.class_(
|
||||||
"RATGDOBinarySensor", binary_sensor.BinarySensor, cg.Component
|
"RATGDOBinarySensor", binary_sensor.BinarySensor, cg.Component
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CONF_TYPE = "type"
|
||||||
TYPES = {"motion", "obstruction"}
|
TYPES = {"motion", "obstruction"}
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend(
|
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):
|
async def to_code(config):
|
||||||
for type in TYPES:
|
var = await binary_sensor.new_binary_sensor(config)
|
||||||
if type in config:
|
await cg.register_component(var, config)
|
||||||
conf = config[type]
|
await register_ratgdo_child(var, config)
|
||||||
var = await binary_sensor.new_binary_sensor(conf)
|
|
||||||
await register_ratgdo_child(var, config)
|
|
||||||
|
|
Loading…
Reference in New Issue