[shtcx] Use the sub_* helpers for optional child entities (#20033)

This commit is contained in:
J. Nick Koston
2026-10-02 12:29:58 -04:00
committed by GitHub
parent 25a30fc472
commit 4f1be0fcb2
+3 -7
View File
@@ -51,10 +51,6 @@ 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 humidity := config.get(CONF_HUMIDITY):
sens = await sensor.new_sensor(humidity)
cg.add(var.set_humidity_sensor(sens))
sensors = sensor.sub_sensors(config)
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)