Skip to content

Commit 3763412

Browse files
authored
fix(e6): input temperature should be float (#363)
same as #361 #359 #358
1 parent 77e1baa commit 3763412

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

midealocal/devices/e6/__init__.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Midea local E6 device."""
22

3+
import json
34
import logging
45
from enum import StrEnum
56
from typing import Any, ClassVar
@@ -51,7 +52,7 @@ def __init__(
5152
device_protocol: ProtocolVersion,
5253
model: str,
5354
subtype: int,
54-
customize: str, # noqa: ARG002
55+
customize: str,
5556
) -> None:
5657
"""Initialize Midea E6 device."""
5758
super().__init__(
@@ -70,17 +71,26 @@ def __init__(
7071
DeviceAttributes.heating_power: True,
7172
DeviceAttributes.heating_working: None,
7273
DeviceAttributes.bathing_working: None,
73-
DeviceAttributes.min_temperature: [30, 35],
74-
DeviceAttributes.max_temperature: [80, 60],
75-
DeviceAttributes.heating_temperature: 50,
76-
DeviceAttributes.bathing_temperature: 40,
74+
DeviceAttributes.min_temperature: [30.0, 35.0],
75+
DeviceAttributes.max_temperature: [80.0, 60.0],
76+
DeviceAttributes.heating_temperature: 50.0,
77+
DeviceAttributes.bathing_temperature: 40.0,
7778
DeviceAttributes.heating_leaving_temperature: None,
7879
DeviceAttributes.bathing_leaving_temperature: None,
7980
DeviceAttributes.cold_water_single: None,
8081
DeviceAttributes.cold_water_dot: None,
8182
DeviceAttributes.heating_modes: None,
8283
},
8384
)
85+
# target_temperature step
86+
self._temperature_step: float | None = None
87+
self._default_temperature_step = 1
88+
self.set_customize(customize)
89+
90+
@property
91+
def temperature_step(self) -> float | None:
92+
"""Midea E6 device temperature step."""
93+
return self._temperature_step
8494

8595
def build_query(self) -> list[MessageQuery]:
8696
"""Midea E6 device build query."""
@@ -97,7 +107,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]:
97107
new_status[str(status)] = self._attributes[status]
98108
return new_status
99109

100-
def set_attribute(self, attr: str, value: bool | int | str) -> None:
110+
def set_attribute(self, attr: str, value: bool | float | str) -> None:
101111
"""Midea E6 device set attribute."""
102112
if attr in [
103113
DeviceAttributes.main_power,
@@ -117,6 +127,21 @@ def heating_modes(self) -> list[str]:
117127
"""Return available heating modes."""
118128
return self._heating_modes
119129

130+
def set_customize(self, customize: str) -> None:
131+
"""Midea E2 device set customize."""
132+
if customize and len(customize) > 0:
133+
try:
134+
params = json.loads(customize)
135+
if params and "temperature_step" in params:
136+
self._temperature_step = params.get("temperature_step")
137+
except Exception:
138+
_LOGGER.exception("[%s] Set customize error", self.device_id)
139+
self.update_all(
140+
{
141+
"temperature_step": self._temperature_step,
142+
},
143+
)
144+
120145

121146
class MideaAppliance(MideaE6Device):
122147
"""Midea E6 appliance."""

midealocal/devices/e6/message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def __init__(self, protocol_version: int) -> None:
6161
message_type=MessageType.set,
6262
)
6363
self.main_power: bool | None = None
64-
self.heating_temperature: int | None = None
65-
self.bathing_temperature: int | None = None
64+
self.heating_temperature: float | None = None
65+
self.bathing_temperature: float | None = None
6666
self.heating_power: bool | None = None
6767
self.heating_modes: str | None = None
6868
self.cold_water_single: bool | None = None
@@ -75,9 +75,9 @@ def _body(self) -> bytearray:
7575
main_power = 0x01 if self.main_power else 0x02
7676
body = [main_power, 0x01]
7777
elif self.heating_temperature is not None:
78-
body = [0x04, 0x13, self.heating_temperature]
78+
body = [0x04, 0x13, int(self.heating_temperature)]
7979
elif self.bathing_temperature is not None:
80-
body = [0x04, 0x12, self.bathing_temperature]
80+
body = [0x04, 0x12, int(self.bathing_temperature)]
8181
elif self.heating_power is not None:
8282
heating_power = 0x01 if self.heating_power else 0x02
8383
body = [0x04, 0x01, heating_power]

0 commit comments

Comments
 (0)