Skip to content

Commit 94b1365

Browse files
Vietrzr
authored andcommitted
UIC-3272: Add Python Script for CTT test Switch Color Command Class
Origin: #146 Signed-off-by: Philippe Coval <[email protected]>
1 parent 2d6178b commit 94b1365

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import mqtt.mqtt_manager as mqtt_manager
2+
import utils.utils as utils
3+
4+
CLUSTER_NAME = "UnifySwitchColor"
5+
6+
def command_set_color(color_component_id, value, duration = 0):
7+
mqtt_manager.send_unify_cluster_command(CLUSTER_NAME, "SetColor",
8+
'{"ColorComponentId" : %d, "Value" : %d, "Duration" : %d}'
9+
% (color_component_id, value, duration)
10+
)
11+
12+
13+
def command_start_stop_level_change(start_stop, up_down, ignor_start_level, color_component_id, start_level, duration = 1):
14+
mqtt_manager.send_unify_cluster_command(CLUSTER_NAME, "StartStopChange",
15+
'{"StartStop" : %s, "UpDown" : %s, "IgnorStartLevel" : %s, "ColorComponentId" : %d, "StartLevel" : %d, "Duration" : %d}'
16+
% (utils.bool_to_str(start_stop), utils.bool_to_str(up_down), utils.bool_to_str(ignor_start_level), color_component_id, start_level, duration)
17+
)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
3+
import mqtt.mqtt_manager as mqtt_manager
4+
import utils.pretty_print as display
5+
6+
from clusters import on_off, level, unify_switch_color
7+
8+
def color_set(color_id, color_value):
9+
display.action_description(f"Color ID {color_id} Set to {color_value}")
10+
unify_switch_color.command_set_color(color_id, color_value, 0)
11+
12+
def color_start_change_up(color_id):
13+
display.action_description(f"Color ID {color_id} Start Level Change Up")
14+
unify_switch_color.command_start_stop_level_change(True, False, True, color_id, 50, 1)
15+
16+
def color_stop_change(color_id):
17+
display.action_description(f"Color ID {color_id} Stop Level Change")
18+
unify_switch_color.command_start_stop_level_change(False, False, True, color_id, 50, 1)
19+
20+
def switch_multilevel_set(level_value):
21+
display.action_description(f"Switch Multilevel Set to {level_value}")
22+
level.command_move_level(level_value, True, True)
23+
24+
def switch_binary_set_on():
25+
display.action_description(f"Switch Binary Set On")
26+
on_off.command_on()
27+
28+
def switch_binary_set_off():
29+
display.action_description(f"Switch Binary Set Off")
30+
on_off.command_off()
31+
32+
if __name__ == '__main__':
33+
mqtt_manager.add_node()
34+
35+
# set color component 'Green' (ID = 0x03) with value= 255
36+
color_set(3, 255)
37+
# start level change for color component 'Red' (ID = 0x02) increasing its brightness
38+
color_start_change_up(2)
39+
# stop level change for color component 'Red' (ID = 0x02)
40+
color_stop_change(2)
41+
# binary switch set
42+
switch_binary_set_on()
43+
# multilevel switch set
44+
switch_multilevel_set(50)
45+
46+
mqtt_manager.remove_node()

0 commit comments

Comments
 (0)