mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 19:44:08 +00:00
[mcp9600][tem3200][kmeteriso][ufire_ec][ufire_ise] Use the sub_* helpers for optional child entities (#20045)
This commit is contained in:
@@ -48,9 +48,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
if temperature_config := config.get(CONF_TEMPERATURE):
|
||||
sens = await sensor.new_sensor(temperature_config)
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
if internal_temperature_config := config.get(CONF_INTERNAL_TEMPERATURE):
|
||||
sens = await sensor.new_sensor(internal_temperature_config)
|
||||
cg.add(var.set_internal_temperature_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_INTERNAL_TEMPERATURE, var.set_internal_temperature_sensor)
|
||||
|
||||
@@ -71,12 +71,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
|
||||
cg.add(var.set_thermocouple_type(config[CONF_THERMOCOUPLE_TYPE]))
|
||||
|
||||
if CONF_HOT_JUNCTION in config:
|
||||
conf = config[CONF_HOT_JUNCTION]
|
||||
sens = await sensor.new_sensor(conf)
|
||||
cg.add(var.set_hot_junction(sens))
|
||||
|
||||
if CONF_COLD_JUNCTION in config:
|
||||
conf = config[CONF_COLD_JUNCTION]
|
||||
sens = await sensor.new_sensor(conf)
|
||||
cg.add(var.set_cold_junction(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_HOT_JUNCTION, var.set_hot_junction)
|
||||
await sensors(CONF_COLD_JUNCTION, var.set_cold_junction)
|
||||
|
||||
@@ -46,10 +46,6 @@ async def to_code(config: ConfigType) -> None:
|
||||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
|
||||
if temperature_config := config.get(CONF_TEMPERATURE):
|
||||
sens = await sensor.new_sensor(temperature_config)
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
|
||||
if raw_pressure_config := config.get(CONF_RAW_PRESSURE):
|
||||
sens = await sensor.new_sensor(raw_pressure_config)
|
||||
cg.add(var.set_raw_pressure_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_RAW_PRESSURE, var.set_raw_pressure_sensor)
|
||||
|
||||
@@ -64,13 +64,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_temperature_compensation(config[CONF_TEMPERATURE_COMPENSATION]))
|
||||
cg.add(var.set_temperature_coefficient(config[CONF_TEMPERATURE_COEFFICIENT]))
|
||||
|
||||
if CONF_TEMPERATURE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
|
||||
if CONF_EC in config:
|
||||
sens = await sensor.new_sensor(config[CONF_EC])
|
||||
cg.add(var.set_ec_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_EC, var.set_ec_sensor)
|
||||
|
||||
if CONF_TEMPERATURE_SENSOR in config:
|
||||
sens = await cg.get_variable(config[CONF_TEMPERATURE_SENSOR])
|
||||
|
||||
@@ -56,13 +56,9 @@ async def to_code(config: ConfigType) -> None:
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
||||
if CONF_TEMPERATURE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
|
||||
if CONF_PH in config:
|
||||
sens = await sensor.new_sensor(config[CONF_PH])
|
||||
cg.add(var.set_ph_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
|
||||
await sensors(CONF_PH, var.set_ph_sensor)
|
||||
|
||||
if CONF_TEMPERATURE_SENSOR in config:
|
||||
sens = await cg.get_variable(config[CONF_TEMPERATURE_SENSOR])
|
||||
|
||||
Reference in New Issue
Block a user