@@ -127,12 +127,12 @@ def set_nightlight(self, ntlight: bool) -> None:
127127
128128 def set_state (
129129 self ,
130- pwr : bool = None ,
131- ntlight : bool = None ,
132- indicator : bool = None ,
133- ntlbrightness : int = None ,
134- maxworktime : int = None ,
135- childlock : bool = None ,
130+ pwr : bool | None = None ,
131+ ntlight : bool | None = None ,
132+ indicator : bool | None = None ,
133+ ntlbrightness : int | None = None ,
134+ maxworktime : int | None = None ,
135+ childlock : bool | None = None ,
136136 ) -> dict :
137137 """Set state of device."""
138138 state = {}
@@ -186,7 +186,7 @@ def _decode(self, response: bytes) -> dict:
186186 e .check_error (response [0x22 :0x24 ])
187187 payload = self .decrypt (response [0x38 :])
188188 js_len = struct .unpack_from ("<I" , payload , 0x08 )[0 ]
189- state = json .loads (payload [0x0C : 0x0C + js_len ])
189+ state = json .loads (payload [0x0C : 0x0C + js_len ])
190190 return state
191191
192192
@@ -234,7 +234,7 @@ def _decode(self, response: bytes) -> dict:
234234 e .check_error (response [0x22 :0x24 ])
235235 payload = self .decrypt (response [0x38 :])
236236 js_len = struct .unpack_from ("<I" , payload , 0xA )[0 ]
237- state = json .loads (payload [0x0E : 0x0E + js_len ])
237+ state = json .loads (payload [0x0E : 0x0E + js_len ])
238238 return state
239239
240240
@@ -255,13 +255,13 @@ def get_state(self) -> dict:
255255
256256 def set_state (
257257 self ,
258- pwr : bool = None ,
259- pwr1 : bool = None ,
260- pwr2 : bool = None ,
261- maxworktime : int = None ,
262- maxworktime1 : int = None ,
263- maxworktime2 : int = None ,
264- idcbrightness : int = None ,
258+ pwr : bool | None = None ,
259+ pwr1 : bool | None = None ,
260+ pwr2 : bool | None = None ,
261+ maxworktime : int | None = None ,
262+ maxworktime1 : int | None = None ,
263+ maxworktime2 : int | None = None ,
264+ idcbrightness : int | None = None ,
265265 ) -> dict :
266266 """Set the power state of the device."""
267267 state = {}
@@ -291,7 +291,16 @@ def _encode(self, flag: int, state: dict) -> bytes:
291291 data = json .dumps (state ).encode ()
292292 length = 12 + len (data )
293293 struct .pack_into (
294- "<HHHHBBI" , packet , 0 , length , 0xA5A5 , 0x5A5A , 0x0000 , flag , 0x0B , len (data )
294+ "<HHHHBBI" ,
295+ packet ,
296+ 0 ,
297+ length ,
298+ 0xA5A5 ,
299+ 0x5A5A ,
300+ 0x0000 ,
301+ flag ,
302+ 0x0B ,
303+ len (data ),
295304 )
296305 packet .extend (data )
297306 checksum = sum (packet [0x2 :], 0xBEAF ) & 0xFFFF
@@ -302,7 +311,7 @@ def _decode(self, response: bytes) -> dict:
302311 """Decode a message."""
303312 payload = self .decrypt (response [0x38 :])
304313 js_len = struct .unpack_from ("<I" , payload , 0x0A )[0 ]
305- state = json .loads (payload [0x0E : 0x0E + js_len ])
314+ state = json .loads (payload [0x0E : 0x0E + js_len ])
306315 return state
307316
308317
@@ -313,19 +322,19 @@ class ehc31(bg1):
313322
314323 def set_state (
315324 self ,
316- pwr : bool = None ,
317- pwr1 : bool = None ,
318- pwr2 : bool = None ,
319- pwr3 : bool = None ,
320- maxworktime1 : int = None ,
321- maxworktime2 : int = None ,
322- maxworktime3 : int = None ,
323- idcbrightness : int = None ,
324- childlock : bool = None ,
325- childlock1 : bool = None ,
326- childlock2 : bool = None ,
327- childlock3 : bool = None ,
328- childlock4 : bool = None ,
325+ pwr : bool | None = None ,
326+ pwr1 : bool | None = None ,
327+ pwr2 : bool | None = None ,
328+ pwr3 : bool | None = None ,
329+ maxworktime1 : int | None = None ,
330+ maxworktime2 : int | None = None ,
331+ maxworktime3 : int | None = None ,
332+ idcbrightness : int | None = None ,
333+ childlock : bool | None = None ,
334+ childlock1 : bool | None = None ,
335+ childlock2 : bool | None = None ,
336+ childlock3 : bool | None = None ,
337+ childlock4 : bool | None = None ,
329338 ) -> dict :
330339 """Set the power state of the device."""
331340 state = {}
@@ -449,7 +458,7 @@ def get_state(self) -> dict:
449458
450459 def get_value (start , end , factors ):
451460 value = sum (
452- int (payload_str [i - 2 : i ]) * factor
461+ int (payload_str [i - 2 : i ]) * factor
453462 for i , factor in zip (range (start , end , - 2 ), factors )
454463 )
455464 return value
0 commit comments