Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ariston/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
23 changes: 23 additions & 0 deletions ariston/nuos_split_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .velis_device import AristonVelisDevice
from .const import (
NuosSplitHpState,
NuosSplitOperativeMode,
NuosSplitPlantMode,
NuosSplitProperties,
Expand Down Expand Up @@ -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]
Expand Down
59 changes: 59 additions & 0 deletions tests/test_nuos_hp_state.py
Original file line number Diff line number Diff line change
@@ -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()