diff --git a/midealocal/devices/a1/__init__.py b/midealocal/devices/a1/__init__.py index 6a99da70..184d8991 100644 --- a/midealocal/devices/a1/__init__.py +++ b/midealocal/devices/a1/__init__.py @@ -81,7 +81,7 @@ def __init__( DeviceAttributes.filter_cleaning_reminder: False, }, ) - self._pump_enable = False + self._capabilities: dict[str, bool] = {} self._speeds = self._default_speeds self._modes = self._default_modes self.set_customize(customize) @@ -101,6 +101,11 @@ def water_level_sets(self) -> list[str]: """Midea A1 device water level options.""" return MideaA1Device._water_level_sets + @property + def capabilities(self) -> dict[str, bool]: + """Return the capabilities reported by the device.""" + return dict(self._capabilities) + def build_query(self) -> list[MessageQuery]: """Midea A1 device build query.""" return [MessageQuery(self._message_protocol_version)] @@ -109,9 +114,10 @@ def process_message(self, msg: bytes) -> dict[str, Any]: """Midea A1 device process message.""" message = MessageA1Response(bytearray(msg)) self._message_protocol_version = message.protocol_version - # Preserve the hidden pump capability bit for future set packets. + # Preserve the pump capability bit for future set packets and expose it + # through the capability map. if hasattr(message, "pump_enable"): - self._pump_enable = message.pump_enable + self._capabilities["pump"] = message.pump_enable _LOGGER.debug("[%s] Received: %s", self.device_id, message) new_status = self.update_attributes_from_message( message, @@ -130,6 +136,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: if self._attributes[DeviceAttributes.tank_full] != tank_full_calculated: self._attributes[DeviceAttributes.tank_full] = tank_full_calculated new_status[DeviceAttributes.tank_full.value] = tank_full_calculated + new_status["capabilities"] = dict(self._capabilities) return new_status def make_message_set(self) -> MessageSet: @@ -154,7 +161,7 @@ def make_message_set(self) -> MessageSet: message.swing = self._attributes[DeviceAttributes.swing] message.anion = self._attributes[DeviceAttributes.anion] message.pump = self._attributes[DeviceAttributes.pump] - message.pump_enable = self._pump_enable + message.pump_enable = self._capabilities.get("pump", False) message.water_level_set = int( self._attributes[DeviceAttributes.water_level_set], ) diff --git a/tests/devices/a1/device_a1_test.py b/tests/devices/a1/device_a1_test.py index 773347aa..ee776561 100644 --- a/tests/devices/a1/device_a1_test.py +++ b/tests/devices/a1/device_a1_test.py @@ -83,14 +83,21 @@ def test_process_message(self) -> None: assert new_status[DeviceAttributes.pump.value] assert new_status[DeviceAttributes.tank_full.value] assert new_status[DeviceAttributes.mode.value] == "manual" + assert self.device.capabilities == {"pump": True} + + capabilities = self.device.capabilities + capabilities["pump"] = False + assert self.device.capabilities == {"pump": True} mock_message.mode = 10 mock_message.fan_speed = 99 + mock_message.pump_enable = False mock_message.tank = 30 new_status = self.device.process_message(b"") assert new_status[DeviceAttributes.mode.value] is None assert new_status[DeviceAttributes.fan_speed.value] is None assert not new_status[DeviceAttributes.tank_full.value] + assert self.device.capabilities == {"pump": False} def test_build_query(self) -> None: """Test build query."""