소스 검색

GUI elements switch and brightness+color_temp joined; simulation extended by 1st automated test

tags/v1.0.0
Dirk Alders 1 년 전
부모
커밋
9907924e54

+ 7
- 7
__simulation__/devices.py 파일 보기

@@ -527,7 +527,7 @@ class gui_light(tradfri_light):
527 527
             if targetkey in self.data.keys():
528 528
                 self.store_data(**{targetkey: value})
529 529
             else:
530
-                print("Unknown key %s in %s" % (targetkey, self.__class__.__name__))
530
+                print("Unknown key %s in %s::%s" % (targetkey, message.topic, self.__class__.__name__))
531 531
         elif message.topic == self.topic + '/get':
532 532
             self.__tx__(None)
533 533
 
@@ -564,9 +564,9 @@ class gui_light(tradfri_light):
564 564
             color = COLOR_GUI_ACTIVE
565 565
             if key == self.KEY_STATE:
566 566
                 if value == True:
567
-                    print(color + 10 * ' ' + u'\u25a0' + 9 * ' ' + " - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
567
+                    print(color + 10 * ' ' + u'\u25a0' + 9 * ' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
568 568
                 else:
569
-                    print(color + 10 * ' ' + u'\u25a1' + 9*' ' + " - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
569
+                    print(color + 10 * ' ' + u'\u25a1' + 9*' ' + " - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
570 570
             elif key == self.KEY_ENABLE:
571 571
                 self.print_formatted(device, self.KEY_BRIGHTNESS, self.data.get(self.KEY_BRIGHTNESS))
572 572
                 self.print_formatted(device, self.KEY_COLOR_TEMP, self.data.get(self.KEY_COLOR_TEMP))
@@ -578,7 +578,7 @@ class gui_light(tradfri_light):
578 578
                 sys.stdout.write('B' if key == self.KEY_BRIGHTNESS else 'C')
579 579
                 sys.stdout.write(percent_bar(value))
580 580
                 sys.stdout.write("%3d%%" % value + 5 * " ")
581
-                print(" - ".join(self.topic.split('/')[1:-1]) + colored.attr("reset"))
581
+                print(" - ".join(self.topic.split('/')[1:]) + colored.attr("reset"))
582 582
 
583 583
 
584 584
 class tradfri_button(base):
@@ -654,7 +654,7 @@ class gui_led_array(base):
654 654
     def print_formatted(self, device, key, value):
655 655
         led = green_led() if value else grey_led()
656 656
         channel = '(%s)' % self.names.get(key, key)
657
-        devicename = ' - '.join(self.topic.split('/')[1:-1])
657
+        devicename = ' - '.join(self.topic.split('/')[1:])
658 658
         print(10 * ' ' + led + 9 * ' ' + COLOR_GUI_ACTIVE + devicename + ' ' + channel + colored.attr("reset"))
659 659
 
660 660
 
@@ -693,13 +693,13 @@ class gui_timer(base):
693 693
                 perc = payload / self.maxvalue * 100
694 694
                 if self.last_printed is None or abs(self.last_printed - perc) >= 4.8:
695 695
                     sys.stdout.write(COLOR_GUI_ACTIVE + 't' + percent_bar(perc))
696
-                    print('%3d%%' % perc + 2 * ' ' + ' - '.join(self.topic.split('/')[1:-1]) + ' (%.1f)' % payload + colored.attr('reset'))
696
+                    print('%3d%%' % perc + 2 * ' ' + ' - '.join(self.topic.split('/')[1:]) + ' (%.1f)' % payload + colored.attr('reset'))
697 697
                     self.last_printed = perc
698 698
             else:
699 699
                 self.maxvalue = None
700 700
                 self.last_printed = None
701 701
                 sys.stdout.write(COLOR_GUI_ACTIVE + 't' + percent_bar(0))
702
-                print('%3d%%' % 0 + 2 * ' ' + ' - '.join(self.topic.split('/')[1:-1]) + colored.attr('reset'))
702
+                print('%3d%%' % 0 + 2 * ' ' + ' - '.join(self.topic.split('/')[1:]) + colored.attr('reset'))
703 703
         else:
704 704
             print("Unknown Message")
705 705
 

+ 35
- 33
__simulation__/rooms.py 파일 보기

@@ -40,7 +40,7 @@ class base(object):
40 40
 
41 41
 class gfw_floor(base):
42 42
     def __init__(self, mqtt_client):
43
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_SWITCH, True, False, False)
43
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI, True, True, True)
44 44
         self.main_light = shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
45 45
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
46 46
         self.main_light_zigbee_1 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE, True, True, True, False)
@@ -49,36 +49,36 @@ class gfw_floor(base):
49 49
         self.main_light_zigbee_2 = tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_2_ZIGBEE, True, True, True, False)
50 50
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_2.power_on, "on")
51 51
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee_1.power_off, "off")
52
-        self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_BR_CT, False, True, True)
53 52
 
54 53
 
55 54
 class gfw_marion(base):
56 55
     def __init__(self, mqtt_client):
57
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI_SWITCH, True, False, False)
56
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI, True, False, False)
58 57
         self.main_light = shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
59 58
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
60 59
 
61 60
 
62 61
 class gfw_dirk(base):
63 62
     def __init__(self, mqtt_client):
64
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_SWITCH, True, False, False)
63
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI, True, True, True)
65 64
         self.main_light = shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
66 65
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
67 66
         self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE, True, True, True)
68 67
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
69 68
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
70
-        self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_BR_CT, False, True, True)
71 69
         #
72 70
         self.powerplug = my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
73 71
         self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_0, "Amplifier")
74
-        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_1, "Desk Light")
75
-        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_2, "CD-Player")
76
-        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_3, "PC-Dock")
77
-        self.gui_switch_amplifier = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI_SWITCH, True, False, False)
78
-        self.gui_switch_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_SWITCH, True, False, False)
79
-        self.gui_br_ct_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_BR_CT, False, True, True)
80
-        self.gui_switch_cd_player = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI_SWITCH, True, False, False)
81
-        self.gui_switch_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI_SWITCH, True, False, False)
72
+        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_1, "Desk_Light")
73
+        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_2, "CD_Player")
74
+        self.powerplug.add_channel_name(my_powerplug.KEY_OUTPUT_3, "PC_Dock")
75
+        self.gui_amplifier = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI, True, False, False)
76
+        self.gui_desk_light = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI, True, True, True)
77
+        self.desk_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE, True, True, True)
78
+        self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_on, True)
79
+        self.powerplug.add_callback(my_powerplug.KEY_OUTPUT_1, self.desk_light_zigbee.power_off, False)
80
+        self.gui_cd_player = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI, True, False, False)
81
+        self.gui_pc_dock = gui_light(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI, True, False, False)
82 82
         #
83 83
         self.remote = remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
84 84
         #
@@ -98,18 +98,17 @@ class gfw(base):
98 98
 
99 99
 class ffw_julian(base):
100 100
     def __init__(self, mqtt_client):
101
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_SWITCH, True, False, False)
101
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI, True, True, True)
102 102
         self.main_light = shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
103 103
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
104 104
         self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE, True, True, True)
105 105
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
106 106
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
107
-        self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_BR_CT, False, True, True)
108 107
 
109 108
 
110 109
 class ffw_livingroom(base):
111 110
     def __init__(self, mqtt_client):
112
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
111
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI, True, False, False)
113 112
         self.main_light = shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
114 113
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
115 114
 
@@ -122,18 +121,18 @@ class ffw(base):
122 121
 
123 122
 class ffe_floor(base):
124 123
     def __init__(self, mqtt_client):
125
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI_SWITCH, True, False, False)
124
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI, True, False, False)
126 125
         self.main_light = shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
127 126
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
128 127
 
129 128
 
130 129
 class ffe_kitchen(base):
131 130
     def __init__(self, mqtt_client):
132
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI_SWITCH, True, False, False)
131
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI, True, False, False)
133 132
         self.main_light = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
134 133
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
135 134
         #
136
-        self.gui_switch_circulation_pump = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI_SWITCH, True, False, False)
135
+        self.gui_circulation_pump = gui_light(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI, True, False, False)
137 136
         self.circulation_pump = shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY,
138 137
                                        input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER, output_0_auto_off=10*60)
139 138
         self.circulation_pump.add_channel_name(shelly.KEY_OUTPUT_0, "Circulation Pump")
@@ -142,29 +141,28 @@ class ffe_kitchen(base):
142 141
 
143 142
 class ffe_diningroom(base):
144 143
     def __init__(self, mqtt_client):
145
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
144
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI, True, False, False)
146 145
         self.main_light = shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
147 146
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
148
-        self.gui_switch_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI_SWITCH, True, False, False)
147
+        self.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI, True, False, False)
149 148
         self.floor_lamp = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
150 149
         self.floor_lamp.add_channel_name(silvercrest_powerplug.KEY_OUTPUT_0, "Floor Lamp")
151
-        self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
152
-        self.garland.add_channel_name(silvercrest_powerplug, "Garland")
150
+        if config.CHRISTMAS:
151
+            self.garland = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
152
+            self.garland.add_channel_name(silvercrest_powerplug, "Garland")
153 153
 
154 154
 
155 155
 class ffe_sleep(base):
156 156
     def __init__(self, mqtt_client):
157
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_SWITCH, True, False, False)
157
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI, True, True, True)
158 158
         self.main_light = shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
159 159
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
160 160
         self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, True, True, True)
161 161
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
162 162
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
163
-        self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_BR_CT, False, True, True)
164 163
         #
165
-        self.gui_switch_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_SWITCH, True, False, False)
164
+        self.gui_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI, True, True, False)
166 165
         self.bed_light_di_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE, True, True, False)
167
-        self.gui_br_ct_bed_light_di = gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_BR_CT, False, True, False)
168 166
         #
169 167
         self.input_device = tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
170 168
         self.led_array = gui_led_array(mqtt_client, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
@@ -179,17 +177,21 @@ class ffe_sleep(base):
179 177
 
180 178
 class ffe_livingroom(base):
181 179
     def __init__(self, mqtt_client):
182
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH, True, False, False)
180
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI, True, True, True)
183 181
         self.main_light = shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
184 182
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
185 183
         self.main_light_zigbee = tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, True, True, True)
186 184
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_on, "on")
187 185
         self.main_light.add_callback(shelly.KEY_OUTPUT_0, self.main_light_zigbee.power_off, "off")
188
-        self.gui_br_ct_main_light = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_BR_CT, False, True, True)
189 186
         for i in range(1, 7):
190
-            setattr(self, "floor_lamp_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
191
-        self.gui_switch_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_SWITCH, True, False, False)
192
-        self.gui_br_ct_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_BR_CT, False, True, True)
187
+            setattr(self, "floor_lamp_zigbee_%d" % i, tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i, True, True, True))
188
+        self.gui_floor_lamp = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI, True, True, True)
189
+        if config.CHRISTMAS:
190
+            self.xmas_tree = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
191
+            self.xmas_tree.add_channel_name(silvercrest_powerplug, "Xmas-Tree")
192
+            self.gui_xmas_tree = gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
193
+            self.xmas_star = silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
194
+            self.xmas_star.add_channel_name(silvercrest_powerplug, "Xmas-Star")
193 195
 
194 196
 
195 197
 class ffe(base):
@@ -203,7 +205,7 @@ class ffe(base):
203 205
 
204 206
 class stairway(base):
205 207
     def __init__(self, mqtt_client):
206
-        self.gui_switch_main_light = gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI_SWITCH, True, False, False)
208
+        self.gui_main_light = gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI, True, False, False)
207 209
         self.main_light = shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, input_0_func=shelly.INPUT_FUNC_OUT1_TRIGGER)
208 210
         self.main_light.add_channel_name(shelly.KEY_OUTPUT_0, "Main Light")
209 211
         self.motion_sensor_gf = silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF)

+ 232
- 0
__simulation__/test.py 파일 보기

@@ -0,0 +1,232 @@
1
+import colored
2
+import time
3
+
4
+
5
+DT_TOGGLE = 0.1
6
+
7
+
8
+class test_smarthome(object):
9
+    def __init__(self, house):
10
+        self.house = house
11
+
12
+    def __smoke__(self):
13
+        result = ""
14
+        result += "Smoke-Test\n"
15
+        result += "  GUI Element exists for every shelly instance\n"
16
+        result += self.__gui_element_exists__("shelly")
17
+        result += "  On-Off test for every shelly instance\n"
18
+        result += self.__on_off_test__("shelly")
19
+        result += "  GUI Element exists for every silvercrest_powerplug instance\n"
20
+        result += self.__gui_element_exists__("silvercrest_powerplug")
21
+        result += "  On-Off test for every silvercrest_powerplug instance\n"
22
+        result += self.__on_off_test__("silvercrest_powerplug")
23
+        result += "  GUI Element exists for every my_powerplug instance and port\n"
24
+        result += self.__gui_element_exists_my_powerplug__()
25
+        result += "  On-Off test for every my_powerplug instance\n"
26
+        result += self.__on_off_test_my_powerplug__()
27
+        result += "  GUI Element exists for every tradfri_light instance\n"
28
+        result += self.__gui_element_exists__("tradfri_light")
29
+        result += "  Enable and disable test for gui elements corresponding with tradfri_light\n"
30
+        result += self.__br_ct_enable_test__()
31
+        result += "  Chnage brightness and color_temp by gui test\n"
32
+        result += self.__br_ct_change_test__()
33
+        return result
34
+
35
+    def __full__(self):
36
+        result = "Full-Test"
37
+        return result
38
+
39
+    def smoke(self):
40
+        print(self.__smoke__())
41
+
42
+    def full(self):
43
+        out = self.__smoke__()
44
+        out += self.__full__()
45
+        print(out)
46
+
47
+    def print_error(self, text, lvl=2):
48
+        return lvl*"  " + colored.fg("light_red") + '* ' + text + "\n" + colored.attr("reset")
49
+
50
+    def print_success(self, text, lvl=2):
51
+        return lvl*"  " + colored.fg("light_green") + '* ' + text + "\n" + colored.attr("reset")
52
+
53
+    def __gui_element_exists__(self, obj_name):
54
+        result = ""
55
+        for member in self.house.getmembers():
56
+            obj = self.house.getobjbyname(member)
57
+            if obj.__class__.__name__ == obj_name:
58
+                if obj_name == "tradfri_light":
59
+                    basename = member[:member.index('_zigbee')]
60
+                else:
61
+                    basename = member
62
+                try:
63
+                    gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
64
+                except AttributeError:
65
+                    result += self.print_error("No GUI element available, while testing %s (%s)." % (member, obj_name))
66
+                else:
67
+                    result += self.print_success("GUI element available, while testing %s (%s)." % (member, obj_name))
68
+        return result
69
+
70
+    def __gui_element_exists_my_powerplug__(self):
71
+        result = ""
72
+        for member in self.house.getmembers():
73
+            obj = self.house.getobjbyname(member)
74
+            if obj.__class__.__name__ == "my_powerplug":
75
+                for channel in [obj.KEY_OUTPUT_0, obj.KEY_OUTPUT_1, obj.KEY_OUTPUT_2, obj.KEY_OUTPUT_3]:
76
+                    try:
77
+                        gui = self.house.getobjbyname('.'.join(member.split(
78
+                            '.')[:-1]) + '.gui_' + obj.names.get(channel.lower(), "__dummy__").lower())
79
+                    except AttributeError:
80
+                        result += self.print_error("No GUI element available, while testing %s (%s)." % (member, obj.names.get(channel)))
81
+                    else:
82
+                        result += self.print_success("GUI element available, while testing %s (%s)." % (member, obj.names.get(channel)))
83
+        return result
84
+
85
+    def __on_off_test_my_powerplug__(self):
86
+        result = ""
87
+        for member in self.house.getmembers():
88
+            obj = self.house.getobjbyname(member)
89
+            if obj.__class__.__name__ == "my_powerplug":
90
+                for channel in [obj.KEY_OUTPUT_0, obj.KEY_OUTPUT_1, obj.KEY_OUTPUT_2, obj.KEY_OUTPUT_3]:
91
+                    try:
92
+                        gui = self.house.getobjbyname('.'.join(member.split(
93
+                            '.')[:-1]) + '.gui_' + obj.names.get(channel.lower(), "__dummy__").lower())
94
+                    except AttributeError:
95
+                        raise AttributeError
96
+                        pass  # exists test already covers non existing gui-elements
97
+                    else:
98
+                        success = True
99
+                        # Initial state equal between obj and gui
100
+                        obj_state = obj.data.get(channel)
101
+                        gui_state = gui.data.get(gui.KEY_STATE)
102
+                        if obj_state != gui_state:
103
+                            result += self.print_error("Initial state of %s (%s) is not equal to GUI state (%s), while testing %s (%s)" %
104
+                                                       ("my_powerplug", obj_state, gui_state, member, obj.names.get(channel)))
105
+                            success = False
106
+                        # state obj change results in state change of obj and gui
107
+                        for i in range(1, 3):
108
+                            gui.command("toggle_state")
109
+                            time.sleep(2 * DT_TOGGLE)
110
+                            last_obj_state = obj_state
111
+                            obj_state = obj.data.get(channel)
112
+                            gui_state = gui.data.get(gui.KEY_STATE)
113
+                            if last_obj_state == obj_state:
114
+                                result += self.print_error("State after %d. toggle of gui state: State unchanged (%s), while testing %s (%s)" %
115
+                                                           (i, obj_state, member, obj.names.get(channel)))
116
+                                success = False
117
+                            if obj_state != gui_state:
118
+                                result += self.print_error("State after %d. toggle of gui state:: State of device (%s) is not equal to GUI state (%s), while testing %s (%s)" %
119
+                                                           (i, obj_state, gui_state, member, obj.names.get(channel)))
120
+                                success = False
121
+                        #
122
+                        if success:
123
+                            result += self.print_success("On-Off test successfull, while testing %s (%s)." % (member, obj.names.get(channel)))
124
+        return result
125
+
126
+    def __on_off_test__(self, obj_name):
127
+        result = ""
128
+        for member in self.house.getmembers():
129
+            obj = self.house.getobjbyname(member)
130
+            if obj.__class__.__name__ == obj_name:
131
+                try:
132
+                    gui = self.house.getobjbyname('.'.join(member.split('.')[:-1]) + '.gui_' + member.split('.')[-1])
133
+                except AttributeError:
134
+                    pass  # exists test already covers non existing gui-elements
135
+                else:
136
+                    success = True
137
+                    # Initial state equal between obj and gui
138
+                    obj_state = obj.data.get(obj.KEY_OUTPUT_0).lower() == "on"
139
+                    gui_state = gui.data.get(gui.KEY_STATE)
140
+                    if obj_state != gui_state:
141
+                        result += self.print_error("Initial state of %s (%s) is not equal to GUI state (%s), while testing %s (%s)" %
142
+                                                   (obj_name, obj_state, gui_state, member, obj_name))
143
+                        success = False
144
+                    # state obj change results in state change of obj and gui
145
+                    for i in range(1, 3):
146
+                        gui.command("toggle_state")
147
+                        time.sleep(2 * DT_TOGGLE)
148
+                        last_obj_state = obj_state
149
+                        obj_state = obj.data.get(obj.KEY_OUTPUT_0).lower() == "on"
150
+                        gui_state = gui.data.get(gui.KEY_STATE)
151
+                        if last_obj_state == obj_state:
152
+                            result += self.print_error("State after %d. toggle of gui state: State unchanged (%s), while testing %s (%s)" %
153
+                                                       (i, obj_state, member, obj_name))
154
+                            success = False
155
+                        if obj_state != gui_state:
156
+                            result += self.print_error("State after %d. toggle of gui state:: State of device (%s) is not equal to GUI state (%s), while testing %s (%s)" %
157
+                                                       (i, obj_state, gui_state, member, obj_name))
158
+                            success = False
159
+                    #
160
+                    if success:
161
+                        result += self.print_success("On-Off test successfull, while testing %s." % (member))
162
+        return result
163
+
164
+    def __br_ct_enable_test__(self):
165
+        result = ""
166
+        for member in self.house.getmembers():
167
+            obj = self.house.getobjbyname(member)
168
+            if obj.__class__.__name__ == "tradfri_light":
169
+                basename = member[:member.index('_zigbee')]
170
+                gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
171
+                success = True
172
+                #
173
+                if gui.data.get(gui.KEY_ENABLE) != False:
174
+                    result += self.print_error("Inital enable state is not False, while testing %s." % (member))
175
+                    success = False
176
+                #
177
+                gui.command("toggle_state")
178
+                time.sleep(2 * DT_TOGGLE)
179
+                if gui.data.get(gui.KEY_ENABLE) != True:
180
+                    result += self.print_error("Enable state is not True after switching on, while testing %s." % (member))
181
+                    success = False
182
+                #
183
+                gui.command("toggle_state")
184
+                time.sleep(2 * DT_TOGGLE)
185
+                if gui.data.get(gui.KEY_ENABLE) != False:
186
+                    result += self.print_error("Enable state is not False after switching off, while testing %s." % (member))
187
+                    success = False
188
+                #
189
+                if success:
190
+                    result += self.print_success("Enable-Disable test successfull, while testing %s." % (member))
191
+        return result
192
+
193
+    def __br_ct_change_test__(self):
194
+        result = ""
195
+        for member in self.house.getmembers():
196
+            obj = self.house.getobjbyname(member)
197
+            if obj.__class__.__name__ == "tradfri_light":
198
+                basename = member[:member.index('_zigbee')]
199
+                gui = self.house.getobjbyname('.'.join(basename.split('.')[:-1]) + '.gui_' + basename.split('.')[-1])
200
+                success = True
201
+                #
202
+                if gui.data.get(gui.KEY_STATE) != True:
203
+                    gui.command("toggle_state")
204
+                    time.sleep(2 * DT_TOGGLE)
205
+                if gui.data.get(gui.KEY_STATE) != True:
206
+                    result += self.print_error("Unable to switch on light, while testing %s." % (member))
207
+                    success = False
208
+                    continue
209
+                #
210
+                if "set_brightness" in obj.capabilities():
211
+                    brightness = gui.data.get(obj.KEY_BRIGHTNESS)
212
+                    targetvalue = brightness + (25 if brightness <= 50 else -25)
213
+                    gui.command("set_brightness %d" % targetvalue)
214
+                    time.sleep(2 * DT_TOGGLE)
215
+                    if gui.data.get(obj.KEY_BRIGHTNESS) != targetvalue:
216
+                        result += self.print_error("Brightness change by gui was not successfull, while testing %s." % (member))
217
+                        success = False
218
+                if "set_color_temp" in obj.capabilities():
219
+                    color_temp = gui.data.get(obj.KEY_COLOR_TEMP)
220
+                    targetvalue = color_temp + (3 if color_temp <= 5 else -3)
221
+                    gui.command("set_color_temp %d" % targetvalue)
222
+                    time.sleep(2 * DT_TOGGLE)
223
+                    if gui.data.get(obj.KEY_COLOR_TEMP) != targetvalue:
224
+                        result += self.print_error("Color temperature change by gui was not successfull, while testing %s." % (member))
225
+                        success = False
226
+                #
227
+                gui.command("toggle_state")
228
+                time.sleep(2 * DT_TOGGLE)
229
+                #
230
+                if success:
231
+                    result += self.print_success("Brightness-ColorTemp test successfull, while testing %s." % (member))
232
+        return result

+ 2
- 2
devices/__init__.py 파일 보기

@@ -700,14 +700,14 @@ class nodered_gui_switch(nodered_gui_button):
700 700
         self.set_state(data)
701 701
 
702 702
 
703
-class nodered_gui_brightness_color_temp(base):
703
+class nodered_gui_light(nodered_gui_switch):
704 704
     KEY_ENABLE = "enable"
705 705
     KEY_BRIGHTNESS = "brightness"
706 706
     KEY_COLOR_TEMP = "color_temp"
707 707
     #
708 708
     TX_TYPE = base.TX_VALUE
709 709
     #
710
-    RX_KEYS = [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
710
+    RX_KEYS = nodered_gui_switch.RX_KEYS + [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
711 711
 
712 712
     #
713 713
     # RX

+ 2
- 5
function/__init__.py 파일 보기

@@ -16,14 +16,11 @@ except ImportError:
16 16
     ROOT_LOGGER_NAME = 'root'
17 17
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
18 18
 
19
-# TODO: implement TOPIC-changes in config.py (gfw.floor.main_light)
20
-# TODO: implement gui element for tradfri light as one class
19
+# TODO: implement devices.nodered_gui_timer (for circulation pump)
21 20
 # TODO: implement devices.nodered_gui_heatvalve incl. setpoint, boost, ... + replace led with timer
22 21
 # TODO: improve heating function
23 22
 # TODO: implement timer and motion leds for stairwasy
24
-# TODO: implement devices.nodered_gui_timer (for circulation pump)
25
-#       improve devices.brennenstuhl_heatvalve
26
-#       improve the implementation in common if highly reduced, just move it to function.__init__.py
23
+# TODO: improve devices.brennenstuhl_heatvalve
27 24
 # TODO: implement garland (incl. day events like sunset, sunrise, ...)
28 25
 # TODO: implement warning message
29 26
 

+ 1
- 1
function/common.py 파일 보기

@@ -19,7 +19,7 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
19 19
 class common_circulation_pump(room_shelly):
20 20
     def __init__(self, mqtt_client):
21 21
         # http://shelly1-E89F6D85A466
22
-        super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI_SWITCH)
22
+        super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_GUI)
23 23
         #
24 24
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions, True)
25 25
         #

+ 27
- 31
function/first_floor_east.py 파일 보기

@@ -17,30 +17,30 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
17 17
 class first_floor_east_floor(room_shelly):
18 18
     def __init__(self, mqtt_client):
19 19
         # http://shelly1l-3C6105E4E629
20
-        super().__init__(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI_SWITCH)
20
+        super().__init__(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI)
21 21
 
22 22
 
23 23
 class first_floor_east_kitchen(room_shelly):
24 24
     def __init__(self, mqtt_client):
25 25
         # http://shelly1l-8CAAB5616C01
26
-        super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI_SWITCH)
26
+        super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI)
27 27
 
28 28
 
29 29
 class first_floor_east_dining(room_shelly):
30 30
     def __init__(self, mqtt_client):
31 31
         # http://shelly1l-84CCA8ADD055
32
-        super().__init__(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI_SWITCH)
32
+        super().__init__(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI)
33 33
         self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
34 34
         if config.CHRISTMAS:
35 35
             self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
36 36
         #
37
-        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI_SWITCH)
37
+        self.gui_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI)
38 38
         #
39 39
         # Callback initialisation
40 40
         #
41 41
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_powerplug.set_output_0_mcb, True)
42
-        self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
43
-        self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
42
+        self.gui_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
43
+        self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
44 44
 
45 45
     def all_off(self, device=None, key=None, data=None):
46 46
         super().all_off(device, key, data)
@@ -52,13 +52,11 @@ class first_floor_east_dining(room_shelly):
52 52
 class first_floor_east_sleep(room_shelly_tradfri_light):
53 53
     def __init__(self, mqtt_client):
54 54
         # http://shelly1l-E8DB84A254C7
55
-        super().__init__(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_SWITCH,
56
-                         config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_BR_CT)
55
+        super().__init__(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)
57 56
         #
58 57
         self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)
59 58
         #
60
-        self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_SWITCH)
61
-        self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_BR_CT)
59
+        self.gui_bed_light_di = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI)
62 60
         #
63 61
         self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
64 62
         #
@@ -76,14 +74,13 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
76 74
 
77 75
         # bed light
78 76
         # switch
79
-        self.gui_switch_bed_light_di.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
80
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_bed_light_di.set_state_mcb)
77
+        self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
78
+        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_state_mcb)
81 79
         # brightness and color temperature
82
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
83
-        self.gui_br_ct_bed_light_di.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
84
-                                                 None, self.bed_light_di_tradfri.set_brightness_mcb)
85
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
86
-        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_bed_light_di.set_brightness_mcb)
80
+        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
81
+        self.gui_bed_light_di.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.bed_light_di_tradfri.set_brightness_mcb)
82
+        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_bed_light_di.set_enable_mcb)
83
+        self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_bed_light_di.set_brightness_mcb)
87 84
 
88 85
     def all_off(self, device=None, key=None, data=None):
89 86
         super().all_off(device, key, data)
@@ -93,8 +90,8 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
93 90
 class first_floor_east_living(room_shelly_tradfri_light):
94 91
     def __init__(self, mqtt_client):
95 92
         # http://shelly1l-3C6105E3F910
96
-        super().__init__(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH,
97
-                         config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_BR_CT)
93
+        super().__init__(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY,
94
+                         config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
98 95
         for i in range(1, 7):
99 96
             setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i))
100 97
         #
@@ -102,11 +99,10 @@ class first_floor_east_living(room_shelly_tradfri_light):
102 99
             self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
103 100
             self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
104 101
         #
105
-        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_SWITCH)
106
-        self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_BR_CT)
102
+        self.gui_floorlamp = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI)
107 103
         #
108 104
         if config.CHRISTMAS:
109
-            self.gui_switch_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI_SWITCH)
105
+            self.gui_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI)
110 106
         #
111 107
         # Callback initialisation
112 108
         #
@@ -114,17 +110,17 @@ class first_floor_east_living(room_shelly_tradfri_light):
114 110
         # floor lamp
115 111
         for device in self.__floorlamp_devices__():
116 112
             self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, device.set_output_0_mcb, True)
117
-            self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, device.set_output_0_mcb)
118
-            self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS, None, device.set_brightness_mcb)
119
-            self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP, None, device.set_color_temp_mcb)
120
-        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
121
-        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_floorlamp.set_enable_mcb)
122
-        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_floorlamp.set_brightness_mcb)
123
-        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_floorlamp.set_color_temp_mcb)
113
+            self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_STATE, None, device.set_output_0_mcb)
114
+            self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, device.set_brightness_mcb)
115
+            self.gui_floorlamp.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, device.set_color_temp_mcb)
116
+        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_state_mcb)
117
+        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_floorlamp.set_enable_mcb)
118
+        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_floorlamp.set_brightness_mcb)
119
+        self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_floorlamp.set_color_temp_mcb)
124 120
         #
125 121
         if config.CHRISTMAS:
126
-            self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_xmas_tree.set_state_mcb)
127
-            self.gui_switch_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
122
+            self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_xmas_tree.set_state_mcb)
123
+            self.gui_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
128 124
             #
129 125
             self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_star.set_output_0_mcb)
130 126
 

+ 2
- 3
function/first_floor_west.py 파일 보기

@@ -16,11 +16,10 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
16 16
 class first_floor_west_julian(room_shelly_tradfri_light):
17 17
     # http://shelly1l-3C6105E43452
18 18
     def __init__(self, mqtt_client):
19
-        super().__init__(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_SWITCH,
20
-                         config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI_BR_CT)
19
+        super().__init__(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)
21 20
 
22 21
 
23 22
 class first_floor_west_living(room_shelly):
24 23
     # http://shelly1l-84CCA8ACE6A1
25 24
     def __init__(self, mqtt_client):
26
-        super().__init__(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH)
25
+        super().__init__(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI)

+ 20
- 25
function/ground_floor_west.py 파일 보기

@@ -19,8 +19,7 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
19 19
 class ground_floor_west_floor(room_shelly_silvercrest_light):
20 20
     # http://shelly1l-84CCA8AD1148
21 21
     def __init__(self, mqtt_client):
22
-        super().__init__(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_SWITCH,
23
-                         config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_BR_CT)
22
+        super().__init__(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_1_ZIGBEE)
24 23
         #
25 24
         # Callback initialisation
26 25
         #
@@ -36,7 +35,7 @@ class ground_floor_west_floor(room_shelly_silvercrest_light):
36 35
 class ground_floor_west_marion(room_shelly):
37 36
     # http://shelly1l-E8DB84A1E067
38 37
     def __init__(self, mqtt_client):
39
-        super().__init__(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI_SWITCH)
38
+        super().__init__(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI)
40 39
 
41 40
 
42 41
 class ground_floor_west_dirk(room_shelly_tradfri_light):
@@ -60,19 +59,17 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
60 59
 
61 60
     # http://shelly1l-3C6105E44F27
62 61
     def __init__(self, mqtt_client):
63
-        super().__init__(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_SWITCH,
64
-                         config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI_BR_CT)
62
+        super().__init__(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE)
65 63
         #
66 64
         self.powerplug_common = devices.my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
67 65
         self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
68 66
         self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
69 67
         #
70
-        self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_SWITCH)
71
-        self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI_BR_CT)
68
+        self.gui_desk_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI)
72 69
         #
73
-        self.gui_switch_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI_SWITCH)
74
-        self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI_SWITCH)
75
-        self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI_SWITCH)
70
+        self.gui_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI)
71
+        self.gui_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI)
72
+        self.gui_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI)
76 73
         #
77 74
         self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
78 75
         #
@@ -97,22 +94,20 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
97 94
         # switch
98 95
         self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT,
99 96
                                          self.powerplug_common.toggle_output_1_mcb)
100
-        self.gui_switch_desk_light.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
101
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_switch_desk_light.set_state_mcb)
97
+        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
98
+        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_state_mcb)
102 99
         # brightness and color temp
103
-        self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
104
-                                               None, self.desk_light_tradfri.set_brightness_mcb)
105
-        self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP,
106
-                                               None, self.desk_light_tradfri.set_color_temp_mcb)
107
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_br_cr_desk_light.set_enable_mcb)
108
-        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_cr_desk_light.set_brightness_mcb)
109
-        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_cr_desk_light.set_color_temp_mcb)
100
+        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.desk_light_tradfri.set_brightness_mcb)
101
+        self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.desk_light_tradfri.set_color_temp_mcb)
102
+        self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_enable_mcb)
103
+        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_desk_light.set_brightness_mcb)
104
+        self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_desk_light.set_color_temp_mcb)
110 105
 
111 106
         # amplifier
112 107
         self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
113 108
                                          self.powerplug_common.toggle_output_0_mcb)
114
-        self.gui_switch_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
115
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_switch_amplifier.set_state_mcb)
109
+        self.gui_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
110
+        self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_amplifier.set_state_mcb)
116 111
         # amplifier auto on
117 112
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.cd_amplifier_synchronisation, True)
118 113
         self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.raspi_amplifier_synchronisation, True)
@@ -127,14 +122,14 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
127 122
         # cd player
128 123
         self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG,
129 124
                                          self.powerplug_common.toggle_output_2_mcb)
130
-        self.gui_switch_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
131
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_switch_cd_player.set_state_mcb)
125
+        self.gui_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
126
+        self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_cd_player.set_state_mcb)
132 127
 
133 128
         # pc dock
134 129
         self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
135 130
                                          self.powerplug_common.toggle_output_3_mcb)
136
-        self.gui_switch_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
137
-        self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_switch_pc_dock.set_state_mcb)
131
+        self.gui_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
132
+        self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_pc_dock.set_state_mcb)
138 133
 
139 134
     def all_off(self, device=None, key=None, data=None):
140 135
         super().all_off(device, key, data)

+ 17
- 20
function/rooms.py 파일 보기

@@ -21,16 +21,16 @@ class room(object):
21 21
 
22 22
 
23 23
 class room_shelly(room):
24
-    def __init__(self, mqtt_client, topic_shelly, topic_gui_switch):
24
+    def __init__(self, mqtt_client, topic_shelly, topic_gui):
25 25
         super().__init__(mqtt_client)
26
-        self.main_light_shelly = devices.shelly(mqtt_client, topic=topic_shelly)
26
+        self.main_light_shelly = devices.shelly(mqtt_client, topic_shelly)
27 27
         #
28
-        self.gui_switch_main_light = devices.nodered_gui_switch(mqtt_client, topic=topic_gui_switch)
28
+        self.gui_main_light = devices.nodered_gui_light(mqtt_client, topic_gui)
29 29
         #
30 30
         # Callback initialisation
31 31
         #
32
-        self.gui_switch_main_light.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
33
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_switch_main_light.set_state_mcb)
32
+        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
33
+        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
34 34
         #
35 35
         self.block_all_off = False
36 36
         self.last_flash_data = None
@@ -59,8 +59,8 @@ class room_shelly(room):
59 59
 
60 60
 
61 61
 class room_shelly_motion_sensor(room_shelly):
62
-    def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_motion_sensor_1, topic_motion_sensor_2=None, timer_value=config.DEFAULT_ON_TIME_LIGHT):
63
-        super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
62
+    def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_motion_sensor_1, topic_motion_sensor_2=None, timer_value=config.DEFAULT_ON_TIME_LIGHT):
63
+        super().__init__(mqtt_client, topic_shelly, topic_gui)
64 64
         self.timer_value = timer_value
65 65
         #
66 66
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.reload_timer, True)
@@ -108,26 +108,23 @@ class room_shelly_motion_sensor(room_shelly):
108 108
 
109 109
 
110 110
 class room_shelly_tradfri_light(room_shelly):
111
-    def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
112
-        super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
111
+    def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_tradfri_light):
112
+        super().__init__(mqtt_client, topic_shelly, topic_gui)
113 113
         self.main_light_tradfri = devices.tradfri_light(mqtt_client, topic_tradfri_light)
114 114
         #
115
-        self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
116
-        #
117 115
         # Callback initialisation
118 116
         #
119
-        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_br_ct_main_light.set_enable_mcb)
120
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_main_light.set_brightness_mcb)
121
-        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_main_light.set_color_temp_mcb)
122
-        self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
123
-                                               None, self.main_light_tradfri.set_brightness_mcb)
124
-        self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP,
125
-                                               None, self.main_light_tradfri.set_color_temp_mcb)
117
+        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
118
+        self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
119
+        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
120
+        self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
121
+        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
122
+        self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
126 123
 
127 124
 
128 125
 class room_shelly_silvercrest_light(room_shelly_tradfri_light):
129
-    def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
130
-        super().__init__(mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct)
126
+    def __init__(self, mqtt_client, topic_shelly, topic_gui, topic_tradfri_light):
127
+        super().__init__(mqtt_client, topic_shelly, topic_gui, topic_tradfri_light)
131 128
         #
132 129
         # Callback initialisation
133 130
         #

+ 1
- 1
function/stairway.py 파일 보기

@@ -16,6 +16,6 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
16 16
 class stairway(room_shelly_motion_sensor):
17 17
     def __init__(self, mqtt_client):
18 18
         # http://shelly1-3494546A9364
19
-        super().__init__(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI_SWITCH,
19
+        super().__init__(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI,
20 20
                          config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF,
21 21
                          config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MIN_ON_TIME)

+ 9
- 1
house_n_gui_sim.py 파일 보기

@@ -4,6 +4,7 @@ import mqtt
4 4
 import readline
5 5
 import report
6 6
 from __simulation__.rooms import house
7
+from __simulation__.test import test_smarthome
7 8
 import time
8 9
 
9 10
 if __name__ == "__main__":
@@ -12,7 +13,7 @@ if __name__ == "__main__":
12 13
     mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
13 14
                           password=config.MQTT_PASSWORD, name=config.APP_NAME + '_simulation')
14 15
     #
15
-    COMMANDS = ['quit', 'help']
16
+    COMMANDS = ['quit', 'help', 'test.smoke', 'test.full']
16 17
     #
17 18
     h = house(mc)
18 19
     for name in h.getmembers():
@@ -20,6 +21,7 @@ if __name__ == "__main__":
20 21
         for c in d.capabilities():
21 22
             COMMANDS.append(name + '.' + c)
22 23
     #
24
+    ts = test_smarthome(h)
23 25
 
24 26
     def reduced_list(text):
25 27
         """
@@ -56,7 +58,9 @@ if __name__ == "__main__":
56 58
 
57 59
     readline.parse_and_bind("tab: complete")
58 60
     readline.set_completer(completer)
61
+    time.sleep(0.3)
59 62
     print("\nEnter command: ")
63
+
60 64
     while True:
61 65
         userfeedback = input('')
62 66
         command = userfeedback.split(' ')[0]
@@ -64,6 +68,10 @@ if __name__ == "__main__":
64 68
             break
65 69
         elif userfeedback == 'help':
66 70
             print("Help is not yet implemented!")
71
+        elif userfeedback == 'test.full':
72
+            ts.full()
73
+        elif userfeedback == 'test.smoke':
74
+            ts.smoke()
67 75
         elif command in COMMANDS[2:]:
68 76
             h.command(userfeedback)
69 77
         elif userfeedback != "":

Loading…
취소
저장