From 40c1b899a8d372f15e838458eb3ff67b99b776dc Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Wed, 5 Mar 2025 03:48:30 +0000 Subject: [PATCH 1/2] fix(e2): input target_temperature should be float --- midealocal/devices/e2/__init__.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/midealocal/devices/e2/__init__.py b/midealocal/devices/e2/__init__.py index 8f3255d0..49c1bc76 100644 --- a/midealocal/devices/e2/__init__.py +++ b/midealocal/devices/e2/__init__.py @@ -96,8 +96,16 @@ def __init__( ) self._default_old_protocol = OldProtocol.auto self._old_protocol = self._default_old_protocol + # target_temperature step + self._temperature_step: float | None = None + self._default_temperature_step = 1 self.set_customize(customize) + @property + def target_temperature_step(self) -> float | None: + """Midea E3 device target temperature step.""" + return self._temperature_step + def _normalize_old_protocol(self, value: str | bool | int) -> OldProtocol: if isinstance(value, str): return_value = OldProtocol(value) @@ -139,7 +147,7 @@ def make_message_set(self) -> MessageSet: message.variable_heating = self._attributes[DeviceAttributes.variable_heating] return message - def set_attribute(self, attr: str, value: bool | int | str) -> None: + def set_attribute(self, attr: str, value: bool | float | str) -> None: """Midea E2 device set attribute.""" message: MessagePower | MessageSet | MessageNewProtocolSet | None = None if attr not in [ @@ -148,6 +156,9 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: DeviceAttributes.current_temperature, ]: old_protocol = self._normalize_old_protocol(self._old_protocol) + # convert input float target_temperature to int for message byte + if attr == DeviceAttributes.target_temperature: + value = int(value * 2) if attr == DeviceAttributes.power: message = MessagePower(self._message_protocol_version) message.power = bool(value) @@ -169,9 +180,16 @@ def set_customize(self, customize: str) -> None: self._old_protocol = self._normalize_old_protocol( params["old_protocol"], ) + if params and "temperature_step" in params: + self._temperature_step = params.get("temperature_step") except Exception: _LOGGER.exception("[%s] Set customize error", self.device_id) - self.update_all({"old_protocol": self._old_protocol}) + self.update_all( + { + "temperature_step": self._temperature_step, + "old_protocol": self._old_protocol, + }, + ) class MideaAppliance(MideaE2Device): From 17f472df0ff8c92ad693c98fca5f0844d2baf2b9 Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Wed, 5 Mar 2025 03:57:36 +0000 Subject: [PATCH 2/2] chore(e2): rename target_temperate_step to target_temperature --- midealocal/devices/e2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/midealocal/devices/e2/__init__.py b/midealocal/devices/e2/__init__.py index 49c1bc76..e141951a 100644 --- a/midealocal/devices/e2/__init__.py +++ b/midealocal/devices/e2/__init__.py @@ -102,7 +102,7 @@ def __init__( self.set_customize(customize) @property - def target_temperature_step(self) -> float | None: + def temperature_step(self) -> float | None: """Midea E3 device target temperature step.""" return self._temperature_step