diff --git a/ariston/const.py b/ariston/const.py index cfe1690..e836c5b 100644 --- a/ariston/const.py +++ b/ariston/const.py @@ -264,6 +264,20 @@ class NuosSplitOperativeMode(WaterHeaterMode): GREEN_PLUS = 6 +@unique +class NuosSplitHpState(Enum): + """NuosSplit heat pump state (slpPlantData `hpState`). + + Values from the official web app enum `eSlpHpState` (2026-11-27). + """ + + LOCKOUT = 0 + IDLE = 1 + HEATING = 2 + ANTILEGIONELLA = 3 + ANTIFREEZE = 4 + + @unique class LydosPlantMode(WaterHeaterMode): """Lydos hybrid plant mode enum""" diff --git a/ariston/nuos_split_device.py b/ariston/nuos_split_device.py index 56abccf..6416609 100644 --- a/ariston/nuos_split_device.py +++ b/ariston/nuos_split_device.py @@ -7,6 +7,7 @@ from .velis_device import AristonVelisDevice from .const import ( + NuosSplitHpState, NuosSplitOperativeMode, NuosSplitPlantMode, NuosSplitProperties, @@ -136,6 +137,28 @@ def water_heater_plant_mode_texts(self) -> list[str]: """Get the available plant mode names""" return [mode.name for mode in NuosSplitPlantMode] + @property + def hp_state_value(self) -> Optional[int]: + """Get the raw heat pump state value""" + return self.data.get(NuosSplitProperties.HP_STATE, None) + + @property + def hp_state_text(self) -> Optional[str]: + """Get the heat pump state name (LOCKOUT / IDLE / HEATING / ...)""" + value = self.hp_state_value + if value is None: + return None + try: + return NuosSplitHpState(value).name + except ValueError: + _LOGGER.debug("Unknown Nuos Split heat pump state value: %s", value) + return None + + @property + def hp_state_texts(self) -> list[str]: + """Get the available heat pump state names""" + return [state.name for state in NuosSplitHpState] + def set_water_heater_plant_mode(self, plant_mode: str) -> None: """Set the plant mode (MANUAL / PROGRAM)""" mode = NuosSplitPlantMode[plant_mode] diff --git a/tests/test_nuos_hp_state.py b/tests/test_nuos_hp_state.py new file mode 100644 index 0000000..44688cf --- /dev/null +++ b/tests/test_nuos_hp_state.py @@ -0,0 +1,59 @@ +"""Unit tests for the Nuos Split heat pump state (hpState).""" + +from __future__ import annotations + +import unittest + +from ariston.const import NuosSplitHpState +from ariston.nuos_split_device import AristonNuosSplitDevice + + +def _device(data: dict) -> AristonNuosSplitDevice: + """Instantiate without the abstract machinery; only data is used.""" + cls = AristonNuosSplitDevice + original = cls.__abstractmethods__ + cls.__abstractmethods__ = frozenset() + try: + device = cls.__new__(cls) + finally: + cls.__abstractmethods__ = original + device.data = data + return device + + +class NuosHpStateTests(unittest.TestCase): + """hpState follows the web app enum eSlpHpState.""" + + def test_enum_values(self) -> None: + self.assertEqual( + {state.name: state.value for state in NuosSplitHpState}, + { + "LOCKOUT": 0, + "IDLE": 1, + "HEATING": 2, + "ANTILEGIONELLA": 3, + "ANTIFREEZE": 4, + }, + ) + + def test_known_values(self) -> None: + for state in NuosSplitHpState: + device = _device({"hpState": state.value}) + self.assertEqual(device.hp_state_value, state.value) + self.assertEqual(device.hp_state_text, state.name) + + def test_missing_null_and_unknown(self) -> None: + for data in ({}, {"hpState": None}, {"hpState": 99}): + with self.subTest(data=data): + self.assertIsNone(_device(data).hp_state_text) + self.assertEqual(_device({"hpState": 99}).hp_state_value, 99) + + def test_texts(self) -> None: + self.assertEqual( + _device({}).hp_state_texts, + ["LOCKOUT", "IDLE", "HEATING", "ANTILEGIONELLA", "ANTIFREEZE"], + ) + + +if __name__ == "__main__": + unittest.main()