With testu for config_flow ok

This commit is contained in:
Jean-Marc Collin
2024-11-24 16:23:14 +00:00
parent ce4ea866cb
commit 81780bd316
3 changed files with 350 additions and 5 deletions

View File

@@ -147,7 +147,11 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
def check_valve_regulation_nb_entities(self, data: dict, step_id=None) -> bool:
"""Check the number of entities for Valve regulation"""
underlyings_to_check = data if step_id == "type" else self._infos
if step_id not in ["type", "valve_regulation", "check_complete"]:
return True
# underlyings_to_check = data if step_id == "type" else self._infos
underlyings_to_check = self._infos # data if step_id == "type" else self._infos
regulation_infos_to_check = (
data if step_id == "valve_regulation" else self._infos
)
@@ -348,7 +352,7 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
):
return False
if not self.check_valve_regulation_nb_entities(infos):
if not self.check_valve_regulation_nb_entities(infos, "check_complete"):
return False
return True
@@ -444,6 +448,7 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
if (
self._infos.get(CONF_PROP_FUNCTION) == PROPORTIONAL_FUNCTION_TPI
or is_central_config
or self.is_valve_regulation_selected(self._infos)
):
menu_options.append("tpi")

View File

@@ -86,10 +86,14 @@ class ThermostatOverClimateValve(ThermostatOverClimate):
self.name,
)
offset_list = config_entry.get(CONF_OFFSET_CALIBRATION_LIST)
opening_list = config_entry.get(CONF_OPENING_DEGREE_LIST)
closing_list = config_entry.get(CONF_CLOSING_DEGREE_LIST)
for idx, _ in enumerate(config_entry.get(CONF_UNDERLYING_LIST)):
offset = config_entry.get(CONF_OFFSET_CALIBRATION_LIST)[idx]
opening = config_entry.get(CONF_OPENING_DEGREE_LIST)[idx]
closing = config_entry.get(CONF_CLOSING_DEGREE_LIST)[idx]
offset = offset_list[idx] if idx < len(offset_list) else None
# number of opening should equal number of underlying
opening = opening_list[idx]
closing = closing_list[idx] if idx < len(closing_list) else None
under = UnderlyingValveRegulation(
hass=self._hass,
thermostat=self,