esphome-ratgdo/components/ratgdo/binary_sensor/__init__.py

28 lines
636 B
Python
Raw Normal View History

2023-06-07 15:37:51 +00:00
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import binary_sensor
from .. import (
ratgdo_ns,
register_ratgdo_child,
)
DEPENDENCIES = ["ratgdo"]
RATGDOBinarySensor = ratgdo_ns.class_(
"RATGDOBinarySensor", binary_sensor.BinarySensor, cg.Component
)
2023-06-07 16:00:08 +00:00
CONF_TYPE = "type"
2023-06-07 15:37:51 +00:00
TYPES = {"motion", "obstruction"}
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend(
2023-06-07 16:00:08 +00:00
{cv.Required(CONF_TYPE): str}
2023-06-07 15:37:51 +00:00
)
async def to_code(config):
2023-06-07 16:00:08 +00:00
var = await binary_sensor.new_binary_sensor(config)
await cg.register_component(var, config)
await register_ratgdo_child(var, config)