瀏覽代碼

topic and parameters moved to config

tags/v1.0.0
Dirk Alders 2 年之前
父節點
當前提交
4f289c98c1
共有 4 個檔案被更改,包括 47 行新增42 行删除
  1. 22
    21
      function/first_floor_east.py
  2. 4
    3
      function/first_floor_west.py
  3. 19
    17
      function/ground_floor_west.py
  4. 2
    1
      function/rooms.py

+ 22
- 21
function/first_floor_east.py 查看文件

@@ -17,24 +17,25 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
17 17
 class first_floor_east_floor(room_shelly_motion_sensor):
18 18
     def __init__(self, mqtt_client):
19 19
         # http://shelly1l-3C6105E4E629
20
-        super().__init__(mqtt_client, "shellies/ffe/floor/main_light", "gui/ffe/floor/main_light/switch", "zigbee/ffe/floor/motion_sensor")
20
+        super().__init__(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY,
21
+                         config.TOPIC_FFE_FLOOR_MAIN_LIGHT_GUI_SWITCH, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_MOTION_SENSOR)
21 22
 
22 23
 
23 24
 class first_floor_east_kitchen(room_shelly):
24 25
     def __init__(self, mqtt_client):
25 26
         # http://shelly1l-8CAAB5616C01
26
-        super().__init__(mqtt_client, "shellies/ffe/kitchen/main_light", "gui/ffe/kitchen/main_light/switch")
27
+        super().__init__(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_GUI_SWITCH)
27 28
 
28 29
 
29 30
 class first_floor_east_dining(room_shelly):
30 31
     def __init__(self, mqtt_client):
31 32
         # http://shelly1l-84CCA8ADD055
32
-        super().__init__(mqtt_client, "shellies/ffe/diningroom/main_light", "gui/ffe/diningroom/main_light/switch")
33
-        self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/dinigroom/powerplug_floorlamp")
33
+        super().__init__(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_GUI_SWITCH)
34
+        self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
34 35
         if config.CHRISTMAS:
35
-            self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, topic="zigbee/ffe/dinigroom/garland")
36
+            self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
36 37
         #
37
-        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, topic="gui/ffe/diningroom/floorlamp/switch")
38
+        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_GUI_SWITCH)
38 39
         #
39 40
         # Callback initialisation
40 41
         #
@@ -52,17 +53,17 @@ class first_floor_east_dining(room_shelly):
52 53
 class first_floor_east_sleep(room_shelly_tradfri_light):
53 54
     def __init__(self, mqtt_client):
54 55
         # http://shelly1l-E8DB84A254C7
55
-        super().__init__(mqtt_client, "shellies/ffe/sleep/main_light", "gui/ffe/sleep/main_light/switch",
56
-                         "zigbee/ffe/sleep/main_light", "gui/ffe/sleep/main_light/br_ct")
56
+        super().__init__(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_SWITCH,
57
+                         config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_GUI_BR_CT)
57 58
         #
58
-        self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, "zigbee/ffe/sleep/bed_light_di")
59
+        self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)
59 60
         #
60
-        self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, "gui/ffe/sleep/bed_light_di/switch")
61
-        self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/sleep/bed_light_di/br_ct")
61
+        self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_GUI_SWITCH)
62
+        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)
62 63
         #
63
-        self.button_tradfri = devices.tradfri_button(mqtt_client, "zigbee/ffe/sleep/input_device")
64
+        self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
64 65
         #
65
-        self.brightness_functions = brightness_choose_n_action(mqtt_client, self.button_tradfri, "gui/ffe/sleep/active_device_state/led")
66
+        self.brightness_functions = brightness_choose_n_action(mqtt_client, self.button_tradfri, config.TOPIC_FFE_SLEEP_DEVICE_CHOOSER_LED)
66 67
         self.brightness_functions.add(self.main_light_tradfri, self.main_light_shelly.add_on_off_callback_0)
67 68
         self.brightness_functions.add(self.bed_light_di_tradfri, self.bed_light_di_tradfri.add_on_off_callback_0)
68 69
         #
@@ -93,20 +94,20 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
93 94
 class first_floor_east_living(room_shelly_tradfri_light):
94 95
     def __init__(self, mqtt_client):
95 96
         # http://shelly1l-3C6105E3F910
96
-        super().__init__(mqtt_client, "shellies/ffe/livingroom/main_light", "gui/ffe/livingroom/main_light/switch",
97
-                         "zigbee/ffe/livingroom/main_light", "gui/ffe/livingroom/main_light/br_ct")
97
+        super().__init__(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH,
98
+                         config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_GUI_BR_CT)
98 99
         for i in range(1, 7):
99
-            setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, "zigbee/ffe/livingroom/floorlamp_%d" % i))
100
+            setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i))
100 101
         #
101 102
         if config.CHRISTMAS:
102
-            self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/livingroom/powerplug_xmas-tree")
103
-            self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/livingroom/powerplug_xmas-star")
103
+            self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
104
+            self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
104 105
         #
105
-        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, "gui/ffe/livingroom/floorlamp/switch")
106
-        self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/livingroom/floorlamp/br_ct")
106
+        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_SWITCH)
107
+        self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_GUI_BR_CT)
107 108
         #
108 109
         if config.CHRISTMAS:
109
-            self.gui_switch_xmas_tree = devices.nodered_gui_switch(mqtt_client, "gui/ffe/livingroom/xmas_tree/switch")
110
+            self.gui_switch_xmas_tree = devices.nodered_gui_switch(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_GUI_SWITCH)
110 111
         #
111 112
         # Callback initialisation
112 113
         #

+ 4
- 3
function/first_floor_west.py 查看文件

@@ -2,6 +2,7 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 
5
+import config
5 6
 import logging
6 7
 from function.rooms import room_shelly, room_shelly_tradfri_light
7 8
 
@@ -15,11 +16,11 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
15 16
 class first_floor_west_julian(room_shelly_tradfri_light):
16 17
     # http://shelly1l-3C6105E43452
17 18
     def __init__(self, mqtt_client):
18
-        super().__init__(mqtt_client, "shellies/ffw/julian/main_light", "gui/ffw/julian/main_light/switch",
19
-                         "zigbee/ffe/julian/main_light", "gui/ffw/julian/main_light/br_ct")
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)
20 21
 
21 22
 
22 23
 class first_floor_west_living(room_shelly):
23 24
     # http://shelly1l-84CCA8ACE6A1
24 25
     def __init__(self, mqtt_client):
25
-        super().__init__(mqtt_client, "shellies/ffw/livingroom/main_light", "gui/ffw/livingroom/main_light/switch")
26
+        super().__init__(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI_SWITCH)

+ 19
- 17
function/ground_floor_west.py 查看文件

@@ -2,6 +2,7 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 
5
+import config
5 6
 import devices
6 7
 from function.modules import brightness_choose_n_action
7 8
 import logging
@@ -18,12 +19,12 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
18 19
 class ground_floor_west_floor(room_shelly_silvercrest_light):
19 20
     # http://shelly1l-84CCA8AD1148
20 21
     def __init__(self, mqtt_client):
21
-        super().__init__(mqtt_client, "shellies/gfw/floor/main_light", "gui/gfw/floor/main_light/switch",
22
-                         "zigbee/gfw/floor/main_light/a", "gui/gfw/floor/main_light/br_ct")
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_A_ZIGBEE, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_GUI_BR_CT)
23 24
         #
24 25
         # Callback initialisation
25 26
         #
26
-        self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee/gfw/floor/main_light/b")
27
+        self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_B_ZIGBEE)
27 28
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.main_light_tradfri_2.set_brightness_mcb)
28 29
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.main_light_tradfri_2.set_color_temp_mcb)
29 30
 
@@ -35,7 +36,7 @@ class ground_floor_west_floor(room_shelly_silvercrest_light):
35 36
 class ground_floor_west_marion(room_shelly):
36 37
     # http://shelly1l-E8DB84A1E067
37 38
     def __init__(self, mqtt_client):
38
-        super().__init__(mqtt_client, "shellies/gfw/marion/main_light", "gui/gfw/marion/main_light/switch")
39
+        super().__init__(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY, config.TOPIC_GFW_MARION_MAIN_LIGHT_GUI_SWITCH)
39 40
 
40 41
 
41 42
 class ground_floor_west_dirk(room_shelly_tradfri_light):
@@ -59,28 +60,29 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
59 60
 
60 61
     # http://shelly1l-3C6105E44F27
61 62
     def __init__(self, mqtt_client):
62
-        super().__init__(mqtt_client, "shellies/gfw/dirk/main_light", "gui/gfw/dirk/main_light/switch", "zigbee/gfw/dirk/main_light", "gui/gfw/dirk/main_light/br_ct")
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)
63 65
         #
64
-        self.powerplug_common = devices.my_powerplug(mqtt_client, "my_apps/gfw/dirk/powerplug")
65
-        self.desk_light_tradfri = devices.tradfri_light(mqtt_client, "zigbee/gfw/dirk/desk_light")
66
-        self.button_tradfri = devices.tradfri_button(mqtt_client, "zigbee/gfw/dirk/input_device")
66
+        self.powerplug_common = devices.my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
67
+        self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
68
+        self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
67 69
         #
68
-        self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/desk_light/switch")
69
-        self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/gfw/dirk/desk_light/br_ct")
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)
70 72
         #
71
-        self.gui_switch_amplifier = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/amplifier/switch")
72
-        self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/cd_player/switch")
73
-        self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/pc_dock/switch")
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)
74 76
         #
75
-        self.remote_amplifier = devices.remote(mqtt_client, "my_apps/gfw/dirk/remote/RAS5")
77
+        self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
76 78
         #
77
-        self.brightness_functions = brightness_choose_n_action(mqtt_client, self.button_tradfri, "gui/gfw/dirk/active_device_state/led")
79
+        self.brightness_functions = brightness_choose_n_action(mqtt_client, self.button_tradfri, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED)
78 80
         self.brightness_functions.add(self.main_light_tradfri, self.main_light_shelly.add_on_off_callback_0)
79 81
         self.brightness_functions.add(self.desk_light_tradfri, self.powerplug_common.add_on_off_callback_1)
80 82
         self.brightness_functions.add(self.remote_amplifier, self.powerplug_common.add_on_off_callback_0)
81 83
         #
82
-        self.spotify_state = devices.audio_status(mqtt_client, "my_apps/gfw/dirk/hifi/spotify")
83
-        self.mpd_state = devices.audio_status(mqtt_client, "my_apps/gfw/dirk/hifi/mpd")
84
+        self.spotify_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_SPOTIFY)
85
+        self.mpd_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_MPD)
84 86
         #
85 87
         self.delayed_task = task.delayed(1.0, self.send_audio_source)
86 88
         #

+ 2
- 1
function/rooms.py 查看文件

@@ -2,6 +2,7 @@
2 2
 # -*- coding: utf-8 -*-
3 3
 #
4 4
 
5
+import config
5 6
 import devices
6 7
 from function.helpers import now, sunset_time, sunrise_time
7 8
 import logging
@@ -58,7 +59,7 @@ class room_shelly(room):
58 59
 
59 60
 
60 61
 class room_shelly_motion_sensor(room_shelly):
61
-    def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_motion_sensor_1, topic_motion_sensor_2=None, timer_value=30):
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):
62 63
         super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
63 64
         self.timer_value = timer_value
64 65
         #

Loading…
取消
儲存