From 0fb3f6e13fccf5fb3276cd8d8b8c0d616a057e6f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jun 2023 11:00:08 -0500 Subject: [PATCH] binary sensor --- components/ratgdo/binary_sensor/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/ratgdo/binary_sensor/__init__.py b/components/ratgdo/binary_sensor/__init__.py index c23ff34..3647a6f 100644 --- a/components/ratgdo/binary_sensor/__init__.py +++ b/components/ratgdo/binary_sensor/__init__.py @@ -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)