mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 19:44:08 +00:00
[ee895] Use the sub_* helpers for optional child entities (#20005)
This commit is contained in:
@@ -57,14 +57,7 @@ async def to_code(config: ConfigType) -> None:
|
||||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
if temperature := config.get(CONF_TEMPERATURE):
|
||||
sens = await sensor.new_sensor(temperature)
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
|
||||
if co2 := config.get(CONF_CO2):
|
||||
sens = await sensor.new_sensor(co2)
|
||||
cg.add(var.set_co2_sensor(sens))
|
||||
|
||||
if pressure := config.get(CONF_PRESSURE):
|
||||
sens = await sensor.new_sensor(pressure)
|
||||
cg.add(var.set_pressure_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_CO2, var.set_co2_sensor)
|
||||
await sensors(CONF_PRESSURE, var.set_pressure_sensor)
|
||||
|
||||
Reference in New Issue
Block a user