mirror of
https://github.com/esphome/esphome.git
synced 2026-10-02 17:30:22 +00:00
[ens160_base] Use the sub_* helpers for optional child entities (#19921)
This commit is contained in:
@@ -63,15 +63,10 @@ async def to_code_base(config: ConfigType) -> MockObj:
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
||||
if eco2_config := config.get(CONF_ECO2):
|
||||
sens = await sensor.new_sensor(eco2_config)
|
||||
cg.add(var.set_co2(sens))
|
||||
if tvoc_config := config.get(CONF_TVOC):
|
||||
sens = await sensor.new_sensor(tvoc_config)
|
||||
cg.add(var.set_tvoc(sens))
|
||||
if aqi_config := config.get(CONF_AQI):
|
||||
sens = await sensor.new_sensor(aqi_config)
|
||||
cg.add(var.set_aqi(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_ECO2, var.set_co2)
|
||||
await sensors(CONF_TVOC, var.set_tvoc)
|
||||
await sensors(CONF_AQI, var.set_aqi)
|
||||
|
||||
if compensation_config := config.get(CONF_COMPENSATION):
|
||||
sens = await cg.get_variable(compensation_config[CONF_TEMPERATURE])
|
||||
|
||||
Reference in New Issue
Block a user