Browse Source

mqtt topic restructured and messy logging reduced

tags/v1.0.0
Dirk Alders 2 years ago
parent
commit
66f560ee3a

+ 5
- 7
devices/__init__.py View File

@@ -642,7 +642,6 @@ class nodered_gui_heatvalve(base):
642 642
         self.pack(self.KEY_FEEDBACK, data)
643 643
 
644 644
 
645
-
646 645
 class nodered_gui_button(base):
647 646
     KEY_STATE = "state"
648 647
     #
@@ -668,7 +667,7 @@ class nodered_gui_switch(nodered_gui_button):
668 667
         self.pack(self.KEY_STATE, data)
669 668
 
670 669
     def set_state_mcb(self, device, key, data):
671
-        logger.log(logging.INFO if data != self.get(self.KEY_STATE) else logging.DEBUG, "%s: Changing data to %s", self.topic, str(data))
670
+        logger.debug("%s: Sending %s with content %s", self.topic, key, str(data))
672 671
         self.set_state(data)
673 672
 
674 673
 
@@ -707,7 +706,7 @@ class nodered_gui_brightness_color_temp(base):
707 706
         self.pack(self.KEY_ENABLE, data)
708 707
 
709 708
     def set_enable_mcb(self, device, key, data):
710
-        logger.log(logging.INFO if data != self.get(self.KEY_ENABLE) else logging.DEBUG, "%s: Changing enable to %s", self.topic, str(data))
709
+        logger.debug("%s: Sending %s with content %s", self.topic, key, str(data))
711 710
         self.set_enable(data)
712 711
 
713 712
     def set_brightness(self, data):
@@ -715,7 +714,7 @@ class nodered_gui_brightness_color_temp(base):
715 714
         self.pack(self.KEY_BRIGHTNESS, data)
716 715
 
717 716
     def set_brightness_mcb(self, device, key, data):
718
-        logger.log(logging.INFO if data != self.get(self.KEY_BRIGHTNESS) else logging.DEBUG, "%s: Changing brightness to %s", self.topic, str(data))
717
+        logger.debug("%s: Sending %s with content %s", self.topic, key, str(data))
719 718
         self.set_brightness(data)
720 719
 
721 720
     def set_color_temp(self, data):
@@ -723,8 +722,7 @@ class nodered_gui_brightness_color_temp(base):
723 722
         self.pack(self.KEY_COLOR_TEMP, data)
724 723
 
725 724
     def set_color_temp_mcb(self, device, key, data):
726
-        logger.log(logging.INFO if data != self.get(self.KEY_COLOR_TEMP) else logging.DEBUG,
727
-                   "%s: Changing color temperature to %s", self.topic, str(data))
725
+        logger.debug("%s: Sending %s with content %s", self.topic, key, str(data))
728 726
         self.set_color_temp(data)
729 727
 
730 728
 
@@ -746,7 +744,7 @@ class nodered_gui_leds(base):
746 744
 
747 745
     def set_led(self, key, data):
748 746
         """data: [True, False]"""
749
-        logger.log(logging.INFO if data != self.get(key) else logging.DEBUG, "%s: Changing led state for %s to %s", self.topic, key, str(data))
747
+        logger.debug("%s: Sending %s with content %s", self.topic, key, str(data))
750 748
         self.pack(key, data)
751 749
 
752 750
 

+ 5
- 3
function/__init__.py View File

@@ -15,10 +15,12 @@ except ImportError:
15 15
     ROOT_LOGGER_NAME = 'root'
16 16
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
17 17
 
18
-# TODO: change topics for all zigbee devices to <type|[shellies, zigbee_*, gui, ...]>/<area|gfw, ffw, ffe>/<room>/<target|[main_light, floorlamp, ...]>/<function>
19 18
 # TODO: usage of implementation strategy from gfw_dirk for ffe_sleep
20
-# TODO: implement improved devices.nodered_gui_heatvalve incl. setpoint, boost, ... and functions from funtion.module
21
-#       implement nodered_gui_timer for circulation pump
19
+# TODO: implement devices.nodered_gui_timer (for circulation pump)
20
+#       implement devices.nodered_gui_heatvalve incl. setpoint, boost, ... and functions from funtion.module
21
+#       improve devices.brennenstuhl_heatvalve
22
+#       improve the implementation in common if highly reduced, just move it to function.__init__.py
23
+#
22 24
 # TODO: implement garland (incl. day events like sunset, sunrise, ...)
23 25
 # TODO: implement warning message
24 26
 

+ 2
- 2
function/common.py View File

@@ -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, "shellies/circulation_pump", "gui/none/common/circulation_pump/switch")
22
+        super().__init__(mqtt_client, "shellies/ffe/kitchen/circulation_pump", "gui/none/common/circulation_pump/switch")
23 23
         #
24 24
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions)
25 25
         #
@@ -53,7 +53,7 @@ class common_circulation_pump(room_shelly):
53 53
 class common_heating(object):
54 54
     def __init__(self, mqtt_client):
55 55
         self.ffe_heating_sleep_madi = heating_function_brennenstuhl(
56
-            mqtt_client, "zigbee_og_e/radiator/sleep_madi", 20, "gui/ffe_bo_sleep_madi", "gui/ffe_ts_sleep_madi", "gui/ffe_bl_sleep_madi")
56
+            mqtt_client, "zigbee/ffe/sleep/radiator_valve", 20, "gui/ffe_bo_sleep_madi", "gui/ffe_ts_sleep_madi", "gui/ffe_bl_sleep_madi")
57 57
 
58 58
     def all_off(self):
59 59
         pass    # dummy method for compatibility reasons

+ 15
- 15
function/first_floor_east.py View File

@@ -18,22 +18,22 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
18 18
 class first_floor_east_floor(room_shelly):
19 19
     def __init__(self, mqtt_client):
20 20
         # http://shelly1l-3C6105E4E629
21
-        super().__init__(mqtt_client, "shellies/floor_madi", "gui/ffe/floor/main_light/switch")
21
+        super().__init__(mqtt_client, "shellies/ffe/floor/main_light", "gui/ffe/floor/main_light/switch")
22 22
 
23 23
 
24 24
 class first_floor_east_kitchen(room_shelly):
25 25
     def __init__(self, mqtt_client):
26 26
         # http://shelly1l-8CAAB5616C01
27
-        super().__init__(mqtt_client, "shellies/kitchen", "gui/ffe/kitchen/main_light/switch")
27
+        super().__init__(mqtt_client, "shellies/ffe/kitchen/main_light", "gui/ffe/kitchen/main_light/switch")
28 28
 
29 29
 
30 30
 class first_floor_east_dining(room_shelly):
31 31
     def __init__(self, mqtt_client):
32 32
         # http://shelly1l-84CCA8ADD055
33
-        super().__init__(mqtt_client, "shellies/diningroom", "gui/ffe/diningroom/main_light/switch")
34
-        self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/dining_floorlamp")
33
+        super().__init__(mqtt_client, "shellies/ffe/diningroom/main_light", "gui/ffe/diningroom/main_light/switch")
34
+        self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/dinigroom/powerplug_floorlamp")
35 35
         if config.CHRISTMAS:
36
-            self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, topic="zigbee_og_e/powerplug/aux")
36
+            self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, topic="zigbee/ffe/dinigroom/garland")
37 37
         #
38 38
         self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, topic="gui/ffe/diningroom/floorlamp/switch")
39 39
         #
@@ -53,16 +53,16 @@ class first_floor_east_dining(room_shelly):
53 53
 class first_floor_east_sleep(room_shelly_tradfri_light):
54 54
     def __init__(self, mqtt_client):
55 55
         # http://shelly1l-E8DB84A254C7
56
-        super().__init__(mqtt_client, "shellies/sleep_madi", "gui/ffe/sleep/main_light/switch",
57
-                         "zigbee_og_e/light/sleep_madi", "gui/ffe/sleep/main_light/br_ct")
56
+        super().__init__(mqtt_client, "shellies/ffe/sleep/main_light", "gui/ffe/sleep/main_light/switch",
57
+                         "zigbee/ffe/sleep/main_light", "gui/ffe/sleep/main_light/br_ct")
58 58
         #
59
-        self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/sleep_bed_di")
59
+        self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, "zigbee/ffe/sleep/bed_light_di")
60 60
         #
61 61
         self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, "gui/ffe/sleep/bed_light_di/switch")
62 62
         self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/sleep/bed_light_di/br_ct")
63 63
         self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/ffe/sleep/active_device_state/led")
64 64
         #
65
-        self.button_tradfri = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
65
+        self.button_tradfri = devices.tradfri_button(mqtt_client, "zigbee/ffe/sleep/input_device")
66 66
         #
67 67
         # Callback initialisation
68 68
         #
@@ -129,16 +129,16 @@ class first_floor_east_sleep(room_shelly_tradfri_light):
129 129
 class first_floor_east_living(room_shelly_tradfri_light):
130 130
     def __init__(self, mqtt_client):
131 131
         # http://shelly1l-3C6105E3F910
132
-        super().__init__(mqtt_client, "shellies/livingroom", "gui/ffe/livingroom/main_light/switch",
133
-                         "zigbee_og_e/light/livingroom", "gui/ffe/livingroom/main_light/br_ct")
132
+        super().__init__(mqtt_client, "shellies/ffe/livingroom/main_light", "gui/ffe/livingroom/main_light/switch",
133
+                         "zigbee/ffe/livingroom/main_light", "gui/ffe/livingroom/main_light/br_ct")
134 134
         for i in range(1, 7):
135
-            setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/living_floorlamp_%d" % i))
135
+            setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, "zigbee/ffe/livingroom/floorlamp_%d" % i))
136 136
         #
137 137
         if config.CHRISTMAS:
138
-            self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/xmas-tree")
139
-            self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/xmas-star")
138
+            self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/livingroom/powerplug_xmas-tree")
139
+            self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, "zigbee/ffe/livingroom/powerplug_xmas-star")
140 140
         #
141
-        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, topic="gui/ffe/livingroom/floorlamp/switch")
141
+        self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, "gui/ffe/livingroom/floorlamp/switch")
142 142
         self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/livingroom/floorlamp/br_ct")
143 143
         #
144 144
         if config.CHRISTMAS:

+ 3
- 2
function/first_floor_west.py View File

@@ -15,10 +15,11 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
15 15
 class first_floor_west_julian(room_shelly_tradfri_light):
16 16
     # http://shelly1l-3C6105E43452
17 17
     def __init__(self, mqtt_client):
18
-        super().__init__(mqtt_client, "shellies/julian", "gui/ffw/julian/main_light/switch", "zigbee_og_e/light/julian", "gui/ffw/julian/main_light/br_ct")
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 20
 
20 21
 
21 22
 class first_floor_west_living(room_shelly):
22 23
     # http://shelly1l-84CCA8ACE6A1
23 24
     def __init__(self, mqtt_client):
24
-        super().__init__(mqtt_client, "shellies/living_mika", "gui/ffw/living/main_light/swicht")
25
+        super().__init__(mqtt_client, "shellies/ffw/livingroom/main_light", "gui/ffw/livingroom/main_light/switch")

+ 14
- 13
function/ground_floor_west.py View File

@@ -16,13 +16,14 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
16 16
 
17 17
 
18 18
 class ground_floor_west_floor(room_shelly_silvercrest_light):
19
-    # https://shelly1l-84CCA8AD1148
19
+    # http://shelly1l-84CCA8AD1148
20 20
     def __init__(self, mqtt_client):
21
-        super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw/floor/main_light/switch", "zigbee_eg_w/light/floor_eg_w/a", "gui/gfw/floor/main_light/br_ct")
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 23
         #
23 24
         # Callback initialisation
24 25
         #
25
-        self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b")
26
+        self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee/gfw/floor/main_light/b")
26 27
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.main_light_tradfri_2.set_brightness_mcb)
27 28
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.main_light_tradfri_2.set_color_temp_mcb)
28 29
 
@@ -32,9 +33,9 @@ class ground_floor_west_floor(room_shelly_silvercrest_light):
32 33
 
33 34
 
34 35
 class ground_floor_west_marion(room_shelly):
35
-    # https://shelly1l-E8DB84A1E067
36
+    # http://shelly1l-E8DB84A1E067
36 37
     def __init__(self, mqtt_client):
37
-        super().__init__(mqtt_client, "shellies/marion", "gui/gfw/marion/main_light/switch")
38
+        super().__init__(mqtt_client, "shellies/gfw/marion/main_light", "gui/gfw/marion/main_light/switch")
38 39
 
39 40
 
40 41
 class ground_floor_west_dirk(room_shelly_tradfri_light):
@@ -56,13 +57,13 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
56 57
     AUDIO_SOURCE_CD = 1
57 58
     AUDIO_SOURCE_RASPI = 2
58 59
 
59
-    # https://shelly1l-3C6105E44F27
60
+    # http://shelly1l-3C6105E44F27
60 61
     def __init__(self, mqtt_client):
61
-        super().__init__(mqtt_client, "shellies/dirk", "gui/gfw/dirk/main_light/switch", "zigbee_eg_w/light/dirk", "gui/gfw/dirk/main_light/br_ct")
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")
62 63
         #
63
-        self.powerplug_common = devices.my_powerplug(mqtt_client, "powerplug/dirk")
64
-        self.desk_light_tradfri = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/dirk_desk")
65
-        self.button_tradfri = devices.tradfri_button(mqtt_client, "zigbee_eg_w/input_device/dirk")
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 67
         #
67 68
         self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/desk_light/switch")
68 69
         self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/gfw/dirk/desk_light/br_ct")
@@ -71,11 +72,11 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
71 72
         self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/cd_player/switch")
72 73
         self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/pc_dock/switch")
73 74
         #
74
-        self.remote_amplifier = devices.remote(mqtt_client, "hifi/remote/RAS5")
75
+        self.remote_amplifier = devices.remote(mqtt_client, "my_apps/gfw/dirk/remote/RAS5")
75 76
         self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/gfw/dirk/active_device_state/led")
76 77
         #
77
-        self.spotify_state = devices.audio_status(mqtt_client, "hifi/spotify")
78
-        self.mpd_state = devices.audio_status(mqtt_client, "hifi/mpd")
78
+        self.spotify_state = devices.audio_status(mqtt_client, "my_apps/gfw/dirk/hifi/spotify")
79
+        self.mpd_state = devices.audio_status(mqtt_client, "my_apps/gfw/dirk/hifi/mpd")
79 80
         #
80 81
         self.delayed_task = task.delayed(1.0, self.send_audio_source)
81 82
         #

+ 1
- 1
function/rooms.py View File

@@ -59,7 +59,7 @@ class room_shelly(room):
59 59
 class room_shelly_tradfri_light(room_shelly):
60 60
     def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
61 61
         super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
62
-        self.main_light_tradfri = devices.tradfri_light(mqtt_client, topic=topic_tradfri_light)
62
+        self.main_light_tradfri = devices.tradfri_light(mqtt_client, topic_tradfri_light)
63 63
         #
64 64
         self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
65 65
         #

Loading…
Cancel
Save