@@ -17,8 +17,12 @@ class CommandV6(Command):
17
17
PASSWORD_BYTE1 = 0x00
18
18
PASSWORD_BYTE2 = 0x00
19
19
20
+ TYPE_CONTROL = 0x31
21
+ TYPE_LINK = 0x3D
22
+ TYPE_UNLINK = 0x3E
23
+
20
24
def __init__ (self , cmd_1 , cmd_2 , remote_style , group_number ,
21
- select = False , select_command = None ):
25
+ select = False , select_command = None , command_type = 0x31 ):
22
26
"""
23
27
Initialize command.
24
28
:param cmd_1: The first part of the command.
@@ -27,9 +31,11 @@ def __init__(self, cmd_1, cmd_2, remote_style, group_number,
27
31
:param group_number: Group number (1-4).
28
32
:param select: If command requires selection.
29
33
:param select_command: Selection command bytes.
34
+ :param command_type: Whether the command is for control, link, or unlink
30
35
"""
31
36
super ().__init__ (cmd_1 , cmd_2 , group_number , select , select_command )
32
37
self ._remote_style = remote_style
38
+ self .type = command_type
33
39
34
40
def get_bytes (self , bridge ):
35
41
"""
@@ -44,7 +50,7 @@ def get_bytes(self, bridge):
44
50
sn = bridge .sn
45
51
46
52
preamble = [0x80 , 0x00 , 0x00 , 0x00 , 0x11 , wb1 , wb2 , 0x00 , sn , 0x00 ]
47
- cmd = [0x31 , self .PASSWORD_BYTE1 , self .PASSWORD_BYTE2 ,
53
+ cmd = [self . type , self .PASSWORD_BYTE1 , self .PASSWORD_BYTE2 ,
48
54
self ._remote_style , self ._cmd_1 ,
49
55
self ._cmd_2 , self ._cmd_2 , self ._cmd_2 , self ._cmd_2 ]
50
56
zone_selector = [self ._group_number , 0x00 ]
@@ -132,16 +138,17 @@ def convert_hue(self, hue, legacy_color_wheel=False):
132
138
return hue % (self .MAX_HUE + 1 )
133
139
134
140
def _build_command (self , cmd_1 , cmd_2 ,
135
- select = False , select_command = None ):
141
+ select = False , select_command = None , command_type = 0x31 ):
136
142
"""
137
143
Constructs the complete command.
138
144
:param cmd_1: Light command 1.
139
145
:param cmd_2: Light command 2.
146
+ :param command_type: Whether the command is for control, link, or unlink
140
147
:return: The complete command.
141
148
"""
142
149
143
150
return CommandV6 (cmd_1 , cmd_2 , self ._remote_style , self ._group_number ,
144
- select , select_command )
151
+ select , select_command , command_type )
145
152
146
153
147
154
class CommandSetBridgeLightV6 (CommandSetV6 ):
@@ -222,6 +229,20 @@ def off(self):
222
229
"""
223
230
return self ._build_command (0x01 , 0x08 )
224
231
232
+ def link (self ):
233
+ """
234
+ Build command for linking new lights.
235
+ :return: The command.
236
+ """
237
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_LINK )
238
+
239
+ def unlink (self ):
240
+ """
241
+ Build command for unlinking linked lights.
242
+ :return: The command.
243
+ """
244
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_UNLINK )
245
+
225
246
def night_light (self ):
226
247
"""
227
248
Build command for turning the led into night light mode.
@@ -284,6 +305,20 @@ def off(self):
284
305
"""
285
306
return self ._build_command (0x04 , 0x04 )
286
307
308
+ def link (self ):
309
+ """
310
+ Build command for linking new lights.
311
+ :return: The command.
312
+ """
313
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_LINK )
314
+
315
+ def unlink (self ):
316
+ """
317
+ Build command for unlinking linked lights.
318
+ :return: The command.
319
+ """
320
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_UNLINK )
321
+
287
322
def night_light (self ):
288
323
"""
289
324
Build command for turning the dimmer into night light mode.
@@ -326,6 +361,20 @@ def off(self):
326
361
"""
327
362
return self ._build_command (0x03 , 0x02 )
328
363
364
+ def link (self ):
365
+ """
366
+ Build command for linking new lights.
367
+ :return: The command.
368
+ """
369
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_LINK )
370
+
371
+ def unlink (self ):
372
+ """
373
+ Build command for unlinking linked lights.
374
+ :return: The command.
375
+ """
376
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_UNLINK )
377
+
329
378
def night_light (self ):
330
379
"""
331
380
Build command for turning the led into night light mode.
@@ -383,6 +432,20 @@ def off(self):
383
432
"""
384
433
return self ._build_command (0x03 , 0x02 )
385
434
435
+ def link (self ):
436
+ """
437
+ Build command for linking new lights.
438
+ :return: The command.
439
+ """
440
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_LINK )
441
+
442
+ def unlink (self ):
443
+ """
444
+ Build command for unlinking linked lights.
445
+ :return: The command.
446
+ """
447
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_UNLINK )
448
+
386
449
def night_light (self ):
387
450
"""
388
451
Build command for turning the led into night light mode.
@@ -496,6 +559,20 @@ def off(self):
496
559
"""
497
560
return self ._build_command (0x04 , 0x02 )
498
561
562
+ def link (self ):
563
+ """
564
+ Build command for linking new lights.
565
+ :return: The command.
566
+ """
567
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_LINK )
568
+
569
+ def unlink (self ):
570
+ """
571
+ Build command for unlinking linked lights.
572
+ :return: The command.
573
+ """
574
+ return self ._build_command (0x00 , 0x00 , command_type = CommandV6 .TYPE_UNLINK )
575
+
499
576
def night_light (self ):
500
577
"""
501
578
Build command for turning the led into night light mode.
0 commit comments