1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-17 10:42:21 +01:00

Binary Sensor codegen tidyup (#3217)

This commit is contained in:
Jesse Hills
2022-02-18 10:39:59 +13:00
committed by GitHub
parent 3b8bb09ae3
commit 7a242bb4ed
38 changed files with 196 additions and 222 deletions

View File

@@ -9,18 +9,20 @@ TemplateBinarySensor = template_ns.class_(
"TemplateBinarySensor", binary_sensor.BinarySensor, cg.Component
)
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(TemplateBinarySensor),
cv.Optional(CONF_LAMBDA): cv.returning_lambda,
}
).extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = (
binary_sensor.binary_sensor_schema(TemplateBinarySensor)
.extend(
{
cv.Optional(CONF_LAMBDA): cv.returning_lambda,
}
)
.extend(cv.COMPONENT_SCHEMA)
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
var = await binary_sensor.new_binary_sensor(config)
await cg.register_component(var, config)
await binary_sensor.register_binary_sensor(var, config)
if CONF_LAMBDA in config:
template_ = await cg.process_lambda(