@@ -80,7 +80,11 @@ async def async_setup_entry(
8080 async_add_entities : AddEntitiesCallback ,
8181) -> None :
8282 """Set up a config entry."""
83+ < << << << HEAD
8384 device_list : list [MIoTDevice ] = hass .data [DOMAIN ]['devices' ][
85+ == == == =
86+ device_list : list [MIoTDevice ] = hass .data [DOMAIN ]["devices" ][
87+ >> >> > >> 83899 f8 (fomatted code )
8488 config_entry .entry_id ]
8589
8690 new_entities = []
@@ -106,9 +110,14 @@ class Light(MIoTServiceEntity, LightEntity):
106110 _brightness_scale : Optional [tuple [int , int ]]
107111 _mode_map : Optional [dict [Any , Any ]]
108112
113+ < << << << HEAD
109114 def __init__ (
110115 self , miot_device : MIoTDevice , entity_data : MIoTEntityData ,hass : HomeAssistant
111116 ) -> None :
117+ == == == =
118+ def __init__ (self , miot_device : MIoTDevice , entity_data : MIoTEntityData ,
119+ hass : HomeAssistant ) -> None :
120+ >> >> >> > 83899 f8 (fomatted code )
112121 """Initialize the Light."""
113122 super ().__init__ (miot_device = miot_device , entity_data = entity_data )
114123 self .hass = hass
@@ -149,8 +158,13 @@ def __init__(
149158 self ._attr_supported_features |= LightEntityFeature .EFFECT
150159 self ._prop_mode = prop
151160 else :
161+ < << << << HEAD
152162 _LOGGER .info (
153163 'invalid brightness format, %s' , self .entity_id )
164+ == == == =
165+ _LOGGER .info ("invalid brightness format, %s" ,
166+ self .entity_id )
167+ >> >> >> > 83899 f8 (fomatted code )
154168 continue
155169 # color-temperature
156170 if prop .name == 'color-temperature' :
@@ -176,22 +190,34 @@ def __init__(
176190 mode_list = prop .value_list .to_map ()
177191 elif prop .value_range :
178192 mode_list = {}
193+ < << << << HEAD
179194 if (
180195 int ((
181196 prop .value_range .max_
182197 - prop .value_range .min_
183198 ) / prop .value_range .step )
184199 > self ._VALUE_RANGE_MODE_COUNT_MAX
185200 ):
201+ == == == =
202+ if (int ((prop .value_range .max_ - prop .value_range .min_ ) /
203+ prop .value_range .step )
204+ > self ._VALUE_RANGE_MODE_COUNT_MAX ):
205+ > >> >> >> 83899 f8 (fomatted code )
186206 _LOGGER .error (
187207 'too many mode values, %s, %s, %s' ,
188208 self .entity_id , prop .name , prop .value_range )
189209 else :
190210 for value in range (
191211 prop .value_range .min_ ,
192212 prop .value_range .max_ ,
213+ << << << < HEAD
193214 prop .value_range .step ):
194215 mode_list [value ] = f'mode { value } '
216+ == == == =
217+ prop .value_range .step ,
218+ ):
219+ mode_list [value ] = f"mode { value } "
220+ >> >> >> > 83899 f8 (fomatted code )
195221 if mode_list :
196222 self ._mode_map = mode_list
197223 self ._attr_effect_list = list (self ._mode_map .values ())
@@ -245,9 +271,14 @@ def rgb_color(self) -> Optional[tuple[int, int, int]]:
245271 @property
246272 def effect (self ) -> Optional [str ]:
247273 """Return the current mode."""
274+ < << << << HEAD
248275 return self .get_map_value (
249276 map_ = self ._mode_map ,
250277 key = self .get_prop_value (prop = self ._prop_mode ))
278+ == == == =
279+ return self .get_map_value (map_ = self ._mode_map ,
280+ key = self .get_prop_value (prop = self ._prop_mode ))
281+ >> >> >> > 83899 f8 (fomatted code )
251282
252283 async def async_turn_on (self , ** kwargs ) -> None :
253284 """Turn the light on.
@@ -285,6 +316,7 @@ async def async_turn_on(self, **kwargs) -> None:
285316 # 开始发送开灯命令
286317 if command_send_mode and command_send_mode .state == "Send Together" :
287318 set_properties_list : List [Dict [str , Any ]] = []
319+ < << << << HEAD
288320 # mode
289321 if ATTR_EFFECT in kwargs :
290322 set_properties_list .append ({
@@ -296,6 +328,18 @@ async def async_turn_on(self, **kwargs) -> None:
296328 if send_brightness_first and ATTR_BRIGHTNESS in kwargs :
297329 brightness = brightness_to_value (
298330 self ._brightness_scale ,kwargs [ATTR_BRIGHTNESS ])
331+ == == == =
332+ if self ._prop_on :
333+ value_on = True if self ._prop_on .format_ == bool else 1 # noqa: E721
334+ set_properties_list .append ({
335+ "prop" : self ._prop_on ,
336+ "value" : value_on
337+ })
338+ # brightness
339+ if ATTR_BRIGHTNESS in kwargs :
340+ brightness = brightness_to_value (self ._brightness_scale ,
341+ kwargs [ATTR_BRIGHTNESS ])
342+ > >> >> >> 83899 f8 (fomatted code )
299343 set_properties_list .append ({
300344 "prop" : self ._prop_brightness ,
301345 "value" : brightness
@@ -318,6 +362,7 @@ async def async_turn_on(self, **kwargs) -> None:
318362 "value" : rgb
319363 })
320364 self ._attr_color_mode = ColorMode .RGB
365+ < << << << HEAD
321366 # brightness
322367 if not send_brightness_first and ATTR_BRIGHTNESS in kwargs :
323368 brightness = brightness_to_value (
@@ -334,16 +379,33 @@ async def async_turn_on(self, **kwargs) -> None:
334379 "value" : value_on
335380 })
336381 await self .set_properties_async (set_properties_list ,write_ha_state = False )
382+ == == == =
383+ # mode
384+ if ATTR_EFFECT in kwargs :
385+ set_properties_list .append ({
386+ "prop" :
387+ self ._prop_mode ,
388+ "value" :
389+ self .get_map_key (map_ = self ._mode_map ,
390+ value = kwargs [ATTR_EFFECT ]),
391+ })
392+ await self .set_properties_async (set_properties_list )
393+ >> >> >> > 83899 f8 (fomatted code )
337394 self .async_write_ha_state ()
338395
339396 elif command_send_mode and command_send_mode .state == "Send Turn On First" :
340397 set_properties_list : List [Dict [str , Any ]] = []
341398 if self ._prop_on :
399+ << << << < HEAD
342400 value_on = True if self ._prop_on .format_ == bool else 1
401+ == == == =
402+ value_on = True if self ._prop_on .format_ == bool else 1 # noqa: E721
403+ >> >> >> > 83899 f8 (fomatted code )
343404 set_properties_list .append ({
344405 "prop" : self ._prop_on ,
345406 "value" : value_on
346407 })
408+ < << << << HEAD
347409 # mode
348410 if ATTR_EFFECT in kwargs :
349411 set_properties_list .append ({
@@ -357,6 +419,14 @@ async def async_turn_on(self, **kwargs) -> None:
357419 if send_brightness_first and ATTR_BRIGHTNESS in kwargs :
358420 brightness = brightness_to_value (
359421 self ._brightness_scale ,kwargs [ATTR_BRIGHTNESS ])
422+ == == == =
423+ await self .set_property_async (prop = self ._prop_on ,
424+ value = value_on )
425+ # brightness
426+ if ATTR_BRIGHTNESS in kwargs :
427+ brightness = brightness_to_value (self ._brightness_scale ,
428+ kwargs [ATTR_BRIGHTNESS ])
429+ > >> >> >> 83899 f8 (fomatted code )
360430 set_properties_list .append ({
361431 "prop" : self ._prop_brightness ,
362432 "value" : brightness
@@ -379,6 +449,7 @@ async def async_turn_on(self, **kwargs) -> None:
379449 "value" : rgb
380450 })
381451 self ._attr_color_mode = ColorMode .RGB
452+ < << << << HEAD
382453 # brightness
383454 if not send_brightness_first and ATTR_BRIGHTNESS in kwargs :
384455 brightness = brightness_to_value (
@@ -389,10 +460,23 @@ async def async_turn_on(self, **kwargs) -> None:
389460 })
390461
391462 await self .set_properties_async (set_properties_list ,write_ha_state = False )
463+ == == == =
464+ # mode
465+ if ATTR_EFFECT in kwargs :
466+ set_properties_list .append ({
467+ "prop" :
468+ self ._prop_mode ,
469+ "value" :
470+ self .get_map_key (map_ = self ._mode_map ,
471+ value = kwargs [ATTR_EFFECT ]),
472+ })
473+ await self .set_properties_async (set_properties_list )
474+ >> >> >> > 83899 f8 (fomatted code )
392475 self .async_write_ha_state ()
393476
394477 else :
395478 if self ._prop_on :
479+ << << << < HEAD
396480 value_on = True if self ._prop_on .format_ == bool else 1
397481 await self .set_property_async (
398482 prop = self ._prop_on , value = value_on )
@@ -403,6 +487,18 @@ async def async_turn_on(self, **kwargs) -> None:
403487 await self .set_property_async (
404488 prop = self ._prop_brightness , value = brightness ,
405489 write_ha_state = False )
490+ == == == =
491+ value_on = True if self ._prop_on .format_ == bool else 1 # noqa: E721
492+ await self .set_property_async (prop = self ._prop_on ,
493+ value = value_on )
494+ # brightness
495+ if ATTR_BRIGHTNESS in kwargs :
496+ brightness = brightness_to_value (self ._brightness_scale ,
497+ kwargs [ATTR_BRIGHTNESS ])
498+ await self .set_property_async (prop = self ._prop_brightness ,
499+ value = brightness ,
500+ write_ha_state = False )
501+ > >> >> >> 83899 f8 (fomatted code )
406502 # color-temperature
407503 if ATTR_COLOR_TEMP_KELVIN in kwargs :
408504 await self .set_property_async (
@@ -416,17 +512,30 @@ async def async_turn_on(self, **kwargs) -> None:
416512 g = kwargs [ATTR_RGB_COLOR ][1 ]
417513 b = kwargs [ATTR_RGB_COLOR ][2 ]
418514 rgb = (r << 16 ) | (g << 8 ) | b
515+ < << << << HEAD
419516 await self .set_property_async (
420517 prop = self ._prop_color , value = rgb ,
421518 write_ha_state = False )
519+ == == == =
520+ await self .set_property_async (prop = self ._prop_color ,
521+ value = rgb ,
522+ write_ha_state = False )
523+ >> >> >> > 83899 f8 (fomatted code )
422524 self ._attr_color_mode = ColorMode .RGB
423525 # mode
424526 if ATTR_EFFECT in kwargs :
425527 await self .set_property_async (
426528 prop = self ._prop_mode ,
529+ << << << < HEAD
427530 value = self .get_map_key (
428531 map_ = self ._mode_map , value = kwargs [ATTR_EFFECT ]),
429532 write_ha_state = False )
533+ == == == =
534+ value = self .get_map_key (map_ = self ._mode_map ,
535+ value = kwargs [ATTR_EFFECT ]),
536+ write_ha_state = False ,
537+ )
538+ >> >> >> > 83899 f8 (fomatted code )
430539 self .async_write_ha_state ()
431540
432541 async def async_turn_off (self , ** kwargs ) -> None :
0 commit comments