mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
[ina219] Use the sub_* helpers for optional child entities (#19785)
This commit is contained in:
@@ -80,18 +80,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_max_current_a(config[CONF_MAX_CURRENT]))
|
||||
cg.add(var.set_max_voltage_v(config[CONF_MAX_VOLTAGE]))
|
||||
|
||||
if CONF_BUS_VOLTAGE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_BUS_VOLTAGE])
|
||||
cg.add(var.set_bus_voltage_sensor(sens))
|
||||
|
||||
if CONF_SHUNT_VOLTAGE in config:
|
||||
sens = await sensor.new_sensor(config[CONF_SHUNT_VOLTAGE])
|
||||
cg.add(var.set_shunt_voltage_sensor(sens))
|
||||
|
||||
if CONF_CURRENT in config:
|
||||
sens = await sensor.new_sensor(config[CONF_CURRENT])
|
||||
cg.add(var.set_current_sensor(sens))
|
||||
|
||||
if CONF_POWER in config:
|
||||
sens = await sensor.new_sensor(config[CONF_POWER])
|
||||
cg.add(var.set_power_sensor(sens))
|
||||
sensors = sensor.sub_sensors(config)
|
||||
await sensors(CONF_BUS_VOLTAGE, var.set_bus_voltage_sensor)
|
||||
await sensors(CONF_SHUNT_VOLTAGE, var.set_shunt_voltage_sensor)
|
||||
await sensors(CONF_CURRENT, var.set_current_sensor)
|
||||
await sensors(CONF_POWER, var.set_power_sensor)
|
||||
|
||||
Reference in New Issue
Block a user