diff --git a/pyplumio/const.py b/pyplumio/const.py index e8ba8edf..afa9f313 100644 --- a/pyplumio/const.py +++ b/pyplumio/const.py @@ -47,12 +47,18 @@ class EncryptionType(IntEnum): WPA2 = 4 +EXTRA_STATES: Final = ( + 12, # STABILIZATION: ecoMAX 810P-L TOUCH + 23, # STABILIZATION: ecoMAX 860P3-O +) + + @unique class DeviceState(IntEnum): """Contains device states.""" OFF = 0 - STABILISATION = 1 + STABILIZATION = 1 KINDLING = 2 WORKING = 3 SUPERVISION = 4 @@ -64,6 +70,18 @@ class DeviceState(IntEnum): UNSEALING = 10 OTHER = 11 + @classmethod + def _missing_(cls, value): + """Look up state in extra state table. + + Currently it's only used for stabilisation state, + since it differs between models. + """ + if value in EXTRA_STATES: + return cls.STABILIZATION + + return None + @unique class ProductType(IntEnum): diff --git a/tests/frames/test_messages.py b/tests/frames/test_messages.py index 2ce83a83..4c651c68 100644 --- a/tests/frames/test_messages.py +++ b/tests/frames/test_messages.py @@ -112,10 +112,15 @@ def test_sensor_data_decode_message(messages: dict[FrameType, bytearray]) -> Non }, } - # Test with the unknown state. + # Test with extra state. test_message[INDEX_STATE] = 12 frame = SensorDataMessage(message=test_message) - assert frame.data[ATTR_SENSORS][ATTR_STATE] == 12 + assert frame.data[ATTR_SENSORS][ATTR_STATE] == DeviceState.STABILIZATION + + # Test with the unknown state. + test_message[INDEX_STATE] = 99 + frame = SensorDataMessage(message=test_message) + assert frame.data[ATTR_SENSORS][ATTR_STATE] == 99 def test_sensor_data_without_fuel_level_and_load(