[scd30] Use the sub_* helpers for optional child entities (#19794)

This commit is contained in:
J. Nick Koston
2026-09-28 00:42:44 +02:00
committed by GitHub
parent d34b09dd7d
commit 6072805950
+4 -11
View File
@@ -99,17 +99,10 @@ async def to_code(config: ConfigType) -> None:
cg.add(var.set_update_interval(config[CONF_UPDATE_INTERVAL]))
if CONF_CO2 in config:
sens = await sensor.new_sensor(config[CONF_CO2])
cg.add(var.set_co2_sensor(sens))
if CONF_HUMIDITY in config:
sens = await sensor.new_sensor(config[CONF_HUMIDITY])
cg.add(var.set_humidity_sensor(sens))
if CONF_TEMPERATURE in config:
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
cg.add(var.set_temperature_sensor(sens))
sensors = sensor.sub_sensors(config)
await sensors(CONF_CO2, var.set_co2_sensor)
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
automation.register_apply_action(