1
1
"""Midea local E6 device."""
2
2
3
+ import json
3
4
import logging
4
5
from enum import StrEnum
5
6
from typing import Any , ClassVar
@@ -51,7 +52,7 @@ def __init__(
51
52
device_protocol : ProtocolVersion ,
52
53
model : str ,
53
54
subtype : int ,
54
- customize : str , # noqa: ARG002
55
+ customize : str ,
55
56
) -> None :
56
57
"""Initialize Midea E6 device."""
57
58
super ().__init__ (
@@ -70,17 +71,26 @@ def __init__(
70
71
DeviceAttributes .heating_power : True ,
71
72
DeviceAttributes .heating_working : None ,
72
73
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 ,
77
78
DeviceAttributes .heating_leaving_temperature : None ,
78
79
DeviceAttributes .bathing_leaving_temperature : None ,
79
80
DeviceAttributes .cold_water_single : None ,
80
81
DeviceAttributes .cold_water_dot : None ,
81
82
DeviceAttributes .heating_modes : None ,
82
83
},
83
84
)
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
84
94
85
95
def build_query (self ) -> list [MessageQuery ]:
86
96
"""Midea E6 device build query."""
@@ -97,7 +107,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]:
97
107
new_status [str (status )] = self ._attributes [status ]
98
108
return new_status
99
109
100
- def set_attribute (self , attr : str , value : bool | int | str ) -> None :
110
+ def set_attribute (self , attr : str , value : bool | float | str ) -> None :
101
111
"""Midea E6 device set attribute."""
102
112
if attr in [
103
113
DeviceAttributes .main_power ,
@@ -117,6 +127,21 @@ def heating_modes(self) -> list[str]:
117
127
"""Return available heating modes."""
118
128
return self ._heating_modes
119
129
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
+
120
145
121
146
class MideaAppliance (MideaE6Device ):
122
147
"""Midea E6 appliance."""
0 commit comments