1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-25 05:03:52 +01:00

Text sensor schema generator similar to sensor (#3172)

This commit is contained in:
Jesse Hills
2022-02-08 17:23:45 +13:00
committed by GitHub
parent ad43d6a5bc
commit 69856286e8
25 changed files with 176 additions and 298 deletions

View File

@@ -17,11 +17,7 @@ NextionTextSensor = nextion_ns.class_(
)
CONFIG_SCHEMA = (
text_sensor.TEXT_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(NextionTextSensor),
}
)
text_sensor.text_sensor_schema(klass=NextionTextSensor)
.extend(CONFIG_TEXT_COMPONENT_SCHEMA)
.extend(cv.polling_component_schema("never"))
)
@@ -30,8 +26,8 @@ CONFIG_SCHEMA = (
async def to_code(config):
hub = await cg.get_variable(config[CONF_NEXTION_ID])
var = cg.new_Pvariable(config[CONF_ID], hub)
await cg.register_component(var, config)
await text_sensor.register_text_sensor(var, config)
await cg.register_component(var, config)
cg.add(hub.register_textsensor_component(var))