@@ -42,6 +42,8 @@ def __init__(self, manu_data):
42
42
self .icon = "mdi:led-strip-variant"
43
43
self .effect_list = EFFECT_LIST_0x56
44
44
45
+ if isinstance (self .manu_data , str ):
46
+ self .manu_data = [ord (c ) for c in self .manu_data ]
45
47
LOGGER .debug (f"Manu data: { [hex (x ) for x in self .manu_data ]} " )
46
48
LOGGER .debug (f"Manu data 15: { hex (self .manu_data [15 ])} " )
47
49
LOGGER .debug (f"Manu data 16: { hex (self .manu_data [16 ])} " )
@@ -57,10 +59,10 @@ def __init__(self, manu_data):
57
59
if self .manu_data [16 ] != 0xf0 :
58
60
# We're not in a colour mode, so set the effect
59
61
self .effect_speed = self .manu_data [17 ]
60
- if 0x02 <= self .manu_data [16 ] <= 0x0a :
62
+ if 0x01 <= self .manu_data [16 ] <= 0x0a :
61
63
self .effect = EFFECT_ID_TO_NAME_0x56 [self .manu_data [16 ] << 8 ]
62
64
else :
63
- self ._effect = EFFECT_OFF
65
+ self .effect = EFFECT_OFF
64
66
elif self .manu_data [15 ] == 0x62 :
65
67
# Music reactive mode.
66
68
self ._color_mode = ColorMode .BRIGHTNESS
@@ -89,7 +91,7 @@ def set_color(self, hs_color, brightness):
89
91
self .color_mode = ColorMode .HS
90
92
self .hs_color = hs_color
91
93
self .brightness = brightness
92
- self .effect = EFFECT_OFF
94
+ # self.effect = EFFECT_OFF # The effect is NOT actually off when setting a colour. Static effect 1 is close to effect off, but it's still an effect.
93
95
rgb_color = self .hsv_to_rgb ((hs_color [0 ], hs_color [1 ], self .brightness ))
94
96
LOGGER .debug (f"Setting RGB colour: { rgb_color } " )
95
97
background_col = [0 ,0 ,0 ] # Consider adding support for this in the future? For now, set black
@@ -209,7 +211,7 @@ def notification_handler(self, data):
209
211
return None
210
212
payload = bytearray .fromhex (payload )
211
213
LOGGER .debug (f"N: Response Payload: { ' ' .join ([f'{ byte :02X} ' for byte in payload ])} " )
212
- # return
214
+
213
215
if payload [0 ] == 0x81 :
214
216
# Status request response
215
217
power = payload [2 ]
@@ -225,23 +227,29 @@ def notification_handler(self, data):
225
227
hsv_color = super ().rgb_to_hsv (rgb_color )
226
228
self .hs_color = tuple (hsv_color [0 :2 ])
227
229
self .brightness = int (hsv_color [2 ])
230
+ LOGGER .debug ("Light is in colour mode" )
228
231
LOGGER .debug (f"RGB colour: { rgb_color } " )
229
232
LOGGER .debug (f"HS colour: { self .hs_color } " )
230
233
LOGGER .debug (f"Brightness: { self .brightness } " )
231
234
self .effect = EFFECT_OFF
232
235
self .color_mode = ColorMode .HS
233
236
self .color_temperature_kelvin = None
234
- elif selected_effect == 0x01 :
237
+ # elif selected_effect == 0x01: # We don't really need this any more, deal with it below instead
238
+ # self.color_mode = ColorMode.HS
239
+ # # self.effect = EFFECT_OFF
240
+ # self.effect = EFFECT_ID_TO_NAME_0x56[selected_effect << 8] # Effect 1 is still an effect
241
+ # hs_color = self.rgb_to_hsv(payload[6:9])
242
+ # self.hs_color = hs_color[0:2]
243
+ # self.brightness = hs_color[2]
244
+ elif 0x01 <= selected_effect <= 0x0a :
235
245
self .color_mode = ColorMode .HS
236
- self .effect = EFFECT_OFF
246
+ self .effect = EFFECT_ID_TO_NAME_0x56 [selected_effect << 8 ]
247
+ self .effect_speed = payload [5 ]
237
248
hs_color = self .rgb_to_hsv (payload [6 :9 ])
249
+ rgb_color = tuple (int (b ) for b in payload [6 :9 ])
250
+ LOGGER .debug (f"RGB Color: { rgb_color } , HS colour: { hs_color } , Brightness: { hs_color [2 ]} " )
238
251
self .hs_color = hs_color [0 :2 ]
239
252
self .brightness = hs_color [2 ]
240
- elif 0x02 <= selected_effect <= 0x0a :
241
- self .color_mode = ColorMode .HS
242
- self .effect = EFFECT_ID_TO_NAME_0x56 [selected_effect << 8 ]
243
- self .effect_speed = payload [5 ]
244
- # TODO: What about colours and brightness?
245
253
elif mode == 0x62 :
246
254
# Music reactive mode
247
255
# TODO: Brightness?
0 commit comments