[ezo_pmp] Use the sub_* helpers for optional child entities (#19760)

This commit is contained in:
J. Nick Koston
2026-09-28 01:10:45 +02:00
committed by GitHub
parent 58437a539a
commit 8e9ceb32b9
3 changed files with 16 additions and 40 deletions
+4 -8
View File
@@ -31,12 +31,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
parent = await cg.get_variable(config[CONF_ID])
hub = await cg.get_variable(config[CONF_ID])
if CONF_PUMP_STATE in config:
sens = await binary_sensor.new_binary_sensor(config[CONF_PUMP_STATE])
cg.add(parent.set_is_dosing(sens))
if CONF_IS_PAUSED in config:
sens = await binary_sensor.new_binary_sensor(config[CONF_IS_PAUSED])
cg.add(parent.set_is_paused(sens))
binary_sensors = binary_sensor.sub_binary_sensors(config)
await binary_sensors(CONF_PUMP_STATE, hub.set_is_dosing)
await binary_sensors(CONF_IS_PAUSED, hub.set_is_paused)
+8 -24
View File
@@ -76,28 +76,12 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
parent = await cg.get_variable(config[CONF_ID])
hub = await cg.get_variable(config[CONF_ID])
if CONF_CURRENT_VOLUME_DOSED in config:
sens = await sensor.new_sensor(config[CONF_CURRENT_VOLUME_DOSED])
cg.add(parent.set_current_volume_dosed(sens))
if CONF_LAST_VOLUME_REQUESTED in config:
sens = await sensor.new_sensor(config[CONF_LAST_VOLUME_REQUESTED])
cg.add(parent.set_last_volume_requested(sens))
if CONF_TOTAL_VOLUME_DOSED in config:
sens = await sensor.new_sensor(config[CONF_TOTAL_VOLUME_DOSED])
cg.add(parent.set_total_volume_dosed(sens))
if CONF_ABSOLUTE_TOTAL_VOLUME_DOSED in config:
sens = await sensor.new_sensor(config[CONF_ABSOLUTE_TOTAL_VOLUME_DOSED])
cg.add(parent.set_absolute_total_volume_dosed(sens))
if CONF_PUMP_VOLTAGE in config:
sens = await sensor.new_sensor(config[CONF_PUMP_VOLTAGE])
cg.add(parent.set_pump_voltage(sens))
if CONF_MAX_FLOW_RATE in config:
sens = await sensor.new_sensor(config[CONF_MAX_FLOW_RATE])
cg.add(parent.set_max_flow_rate(sens))
sensors = sensor.sub_sensors(config)
await sensors(CONF_CURRENT_VOLUME_DOSED, hub.set_current_volume_dosed)
await sensors(CONF_LAST_VOLUME_REQUESTED, hub.set_last_volume_requested)
await sensors(CONF_TOTAL_VOLUME_DOSED, hub.set_total_volume_dosed)
await sensors(CONF_ABSOLUTE_TOTAL_VOLUME_DOSED, hub.set_absolute_total_volume_dosed)
await sensors(CONF_PUMP_VOLTAGE, hub.set_pump_voltage)
await sensors(CONF_MAX_FLOW_RATE, hub.set_max_flow_rate)
+4 -8
View File
@@ -24,12 +24,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config):
parent = await cg.get_variable(config[CONF_ID])
hub = await cg.get_variable(config[CONF_ID])
if CONF_DOSING_MODE in config:
sens = await text_sensor.new_text_sensor(config[CONF_DOSING_MODE])
cg.add(parent.set_dosing_mode(sens))
if CONF_CALIBRATION_STATUS in config:
sens = await text_sensor.new_text_sensor(config[CONF_CALIBRATION_STATUS])
cg.add(parent.set_calibration_status(sens))
text_sensors = text_sensor.sub_text_sensors(config)
await text_sensors(CONF_DOSING_MODE, hub.set_dosing_mode)
await text_sensors(CONF_CALIBRATION_STATUS, hub.set_calibration_status)