Step 2: manual tests ok
This commit is contained in:
@@ -145,23 +145,34 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
|
|||||||
"""True of the valve regulation mode is selected"""
|
"""True of the valve regulation mode is selected"""
|
||||||
return infos.get(CONF_AUTO_REGULATION_MODE, None) == CONF_AUTO_REGULATION_VALVE
|
return infos.get(CONF_AUTO_REGULATION_MODE, None) == CONF_AUTO_REGULATION_VALVE
|
||||||
|
|
||||||
def check_valve_regulation_nb_entities(self, data: dict) -> bool:
|
def check_valve_regulation_nb_entities(self, data: dict, step_id=None) -> bool:
|
||||||
"""Check the number of entities for Valve regulation"""
|
"""Check the number of entities for Valve regulation"""
|
||||||
|
underlyings_to_check = data if step_id == "type" else self._infos
|
||||||
|
regulation_infos_to_check = (
|
||||||
|
data if step_id == "valve_regulation" else self._infos
|
||||||
|
)
|
||||||
|
|
||||||
ret = True
|
ret = True
|
||||||
if self.is_valve_regulation_selected(self._infos):
|
if self.is_valve_regulation_selected(underlyings_to_check):
|
||||||
nb_unders = len(self._infos.get(CONF_UNDERLYING_LIST))
|
nb_unders = len(underlyings_to_check.get(CONF_UNDERLYING_LIST))
|
||||||
nb_offset = len(data.get(CONF_OFFSET_CALIBRATION_LIST, []))
|
nb_offset = len(
|
||||||
nb_opening = len(data.get(CONF_OPENING_DEGREE_LIST, []))
|
regulation_infos_to_check.get(CONF_OFFSET_CALIBRATION_LIST, [])
|
||||||
nb_closing = len(data.get(CONF_CLOSING_DEGREE_LIST, []))
|
)
|
||||||
|
nb_opening = len(
|
||||||
|
regulation_infos_to_check.get(CONF_OPENING_DEGREE_LIST, [])
|
||||||
|
)
|
||||||
|
nb_closing = len(
|
||||||
|
regulation_infos_to_check.get(CONF_CLOSING_DEGREE_LIST, [])
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
nb_unders != nb_offset
|
nb_unders != nb_opening
|
||||||
or nb_unders != nb_opening
|
or (nb_unders != nb_offset and nb_offset > 0)
|
||||||
or nb_unders != nb_closing
|
or (nb_unders != nb_closing and nb_closing > 0)
|
||||||
):
|
):
|
||||||
ret = False
|
ret = False
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def validate_input(self, data: dict, _) -> None:
|
async def validate_input(self, data: dict, step_id) -> None:
|
||||||
"""Validate the user input allows us to connect.
|
"""Validate the user input allows us to connect.
|
||||||
|
|
||||||
Data has the keys from STEP_*_DATA_SCHEMA with values provided by the user.
|
Data has the keys from STEP_*_DATA_SCHEMA with values provided by the user.
|
||||||
@@ -239,7 +250,7 @@ class VersatileThermostatBaseConfigFlow(FlowHandler):
|
|||||||
|
|
||||||
# Check that the number of offet_calibration and opening_degree and closing_degree are equals
|
# Check that the number of offet_calibration and opening_degree and closing_degree are equals
|
||||||
# to the number of underlying entities
|
# to the number of underlying entities
|
||||||
if not self.check_valve_regulation_nb_entities(data):
|
if not self.check_valve_regulation_nb_entities(data, step_id):
|
||||||
raise ValveRegulationNbEntitiesIncorrect()
|
raise ValveRegulationNbEntitiesIncorrect()
|
||||||
|
|
||||||
def check_config_complete(self, infos) -> bool:
|
def check_config_complete(self, infos) -> bool:
|
||||||
|
|||||||
@@ -875,7 +875,7 @@ class UnderlyingValve(UnderlyingEntity):
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
thermostat: Any,
|
thermostat: Any,
|
||||||
valve_entity_id: str,
|
valve_entity_id: str,
|
||||||
type: UnderlyingEntityType = UnderlyingEntityType.VALVE,
|
entity_type: UnderlyingEntityType = UnderlyingEntityType.VALVE,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the underlying valve"""
|
"""Initialize the underlying valve"""
|
||||||
|
|
||||||
@@ -1039,7 +1039,7 @@ class UnderlyingValveRegulation(UnderlyingValve):
|
|||||||
hass,
|
hass,
|
||||||
thermostat,
|
thermostat,
|
||||||
opening_degree_entity_id,
|
opening_degree_entity_id,
|
||||||
type=UnderlyingEntityType.VALVE_REGULATION,
|
entity_type=UnderlyingEntityType.VALVE_REGULATION,
|
||||||
)
|
)
|
||||||
self._offset_calibration_entity_id = offset_calibration_entity_id
|
self._offset_calibration_entity_id = offset_calibration_entity_id
|
||||||
self._opening_degree_entity_id = opening_degree_entity_id
|
self._opening_degree_entity_id = opening_degree_entity_id
|
||||||
|
|||||||
Reference in New Issue
Block a user