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
         self.pack(self.KEY_FEEDBACK, data)
642
         self.pack(self.KEY_FEEDBACK, data)
643
 
643
 
644
 
644
 
645
-
646
 class nodered_gui_button(base):
645
 class nodered_gui_button(base):
647
     KEY_STATE = "state"
646
     KEY_STATE = "state"
648
     #
647
     #
668
         self.pack(self.KEY_STATE, data)
667
         self.pack(self.KEY_STATE, data)
669
 
668
 
670
     def set_state_mcb(self, device, key, data):
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
         self.set_state(data)
671
         self.set_state(data)
673
 
672
 
674
 
673
 
707
         self.pack(self.KEY_ENABLE, data)
706
         self.pack(self.KEY_ENABLE, data)
708
 
707
 
709
     def set_enable_mcb(self, device, key, data):
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
         self.set_enable(data)
710
         self.set_enable(data)
712
 
711
 
713
     def set_brightness(self, data):
712
     def set_brightness(self, data):
715
         self.pack(self.KEY_BRIGHTNESS, data)
714
         self.pack(self.KEY_BRIGHTNESS, data)
716
 
715
 
717
     def set_brightness_mcb(self, device, key, data):
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
         self.set_brightness(data)
718
         self.set_brightness(data)
720
 
719
 
721
     def set_color_temp(self, data):
720
     def set_color_temp(self, data):
723
         self.pack(self.KEY_COLOR_TEMP, data)
722
         self.pack(self.KEY_COLOR_TEMP, data)
724
 
723
 
725
     def set_color_temp_mcb(self, device, key, data):
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
         self.set_color_temp(data)
726
         self.set_color_temp(data)
729
 
727
 
730
 
728
 
746
 
744
 
747
     def set_led(self, key, data):
745
     def set_led(self, key, data):
748
         """data: [True, False]"""
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
         self.pack(key, data)
748
         self.pack(key, data)
751
 
749
 
752
 
750
 

+ 5
- 3
function/__init__.py View File

15
     ROOT_LOGGER_NAME = 'root'
15
     ROOT_LOGGER_NAME = 'root'
16
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
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
 # TODO: usage of implementation strategy from gfw_dirk for ffe_sleep
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
 # TODO: implement garland (incl. day events like sunset, sunrise, ...)
24
 # TODO: implement garland (incl. day events like sunset, sunrise, ...)
23
 # TODO: implement warning message
25
 # TODO: implement warning message
24
 
26
 

+ 2
- 2
function/common.py View File

19
 class common_circulation_pump(room_shelly):
19
 class common_circulation_pump(room_shelly):
20
     def __init__(self, mqtt_client):
20
     def __init__(self, mqtt_client):
21
         # http://shelly1-E89F6D85A466
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
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions)
24
         self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions)
25
         #
25
         #
53
 class common_heating(object):
53
 class common_heating(object):
54
     def __init__(self, mqtt_client):
54
     def __init__(self, mqtt_client):
55
         self.ffe_heating_sleep_madi = heating_function_brennenstuhl(
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
     def all_off(self):
58
     def all_off(self):
59
         pass    # dummy method for compatibility reasons
59
         pass    # dummy method for compatibility reasons

+ 15
- 15
function/first_floor_east.py View File

18
 class first_floor_east_floor(room_shelly):
18
 class first_floor_east_floor(room_shelly):
19
     def __init__(self, mqtt_client):
19
     def __init__(self, mqtt_client):
20
         # http://shelly1l-3C6105E4E629
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
 class first_floor_east_kitchen(room_shelly):
24
 class first_floor_east_kitchen(room_shelly):
25
     def __init__(self, mqtt_client):
25
     def __init__(self, mqtt_client):
26
         # http://shelly1l-8CAAB5616C01
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
 class first_floor_east_dining(room_shelly):
30
 class first_floor_east_dining(room_shelly):
31
     def __init__(self, mqtt_client):
31
     def __init__(self, mqtt_client):
32
         # http://shelly1l-84CCA8ADD055
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
         if config.CHRISTMAS:
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
         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, topic="gui/ffe/diningroom/floorlamp/switch")
39
         #
39
         #
53
 class first_floor_east_sleep(room_shelly_tradfri_light):
53
 class first_floor_east_sleep(room_shelly_tradfri_light):
54
     def __init__(self, mqtt_client):
54
     def __init__(self, mqtt_client):
55
         # http://shelly1l-E8DB84A254C7
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
         self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, "gui/ffe/sleep/bed_light_di/switch")
61
         self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, "gui/ffe/sleep/bed_light_di/switch")
62
         self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/sleep/bed_light_di/br_ct")
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
         self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/ffe/sleep/active_device_state/led")
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
         # Callback initialisation
67
         # Callback initialisation
68
         #
68
         #
129
 class first_floor_east_living(room_shelly_tradfri_light):
129
 class first_floor_east_living(room_shelly_tradfri_light):
130
     def __init__(self, mqtt_client):
130
     def __init__(self, mqtt_client):
131
         # http://shelly1l-3C6105E3F910
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
         for i in range(1, 7):
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
         if config.CHRISTMAS:
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
         self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/livingroom/floorlamp/br_ct")
142
         self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/livingroom/floorlamp/br_ct")
143
         #
143
         #
144
         if config.CHRISTMAS:
144
         if config.CHRISTMAS:

+ 3
- 2
function/first_floor_west.py View File

15
 class first_floor_west_julian(room_shelly_tradfri_light):
15
 class first_floor_west_julian(room_shelly_tradfri_light):
16
     # http://shelly1l-3C6105E43452
16
     # http://shelly1l-3C6105E43452
17
     def __init__(self, mqtt_client):
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
 class first_floor_west_living(room_shelly):
22
 class first_floor_west_living(room_shelly):
22
     # http://shelly1l-84CCA8ACE6A1
23
     # http://shelly1l-84CCA8ACE6A1
23
     def __init__(self, mqtt_client):
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
 
16
 
17
 
17
 
18
 class ground_floor_west_floor(room_shelly_silvercrest_light):
18
 class ground_floor_west_floor(room_shelly_silvercrest_light):
19
-    # https://shelly1l-84CCA8AD1148
19
+    # http://shelly1l-84CCA8AD1148
20
     def __init__(self, mqtt_client):
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
         # Callback initialisation
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
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.main_light_tradfri_2.set_brightness_mcb)
27
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.main_light_tradfri_2.set_brightness_mcb)
27
         self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.main_light_tradfri_2.set_color_temp_mcb)
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
 
33
 
33
 
34
 
34
 class ground_floor_west_marion(room_shelly):
35
 class ground_floor_west_marion(room_shelly):
35
-    # https://shelly1l-E8DB84A1E067
36
+    # http://shelly1l-E8DB84A1E067
36
     def __init__(self, mqtt_client):
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
 class ground_floor_west_dirk(room_shelly_tradfri_light):
41
 class ground_floor_west_dirk(room_shelly_tradfri_light):
56
     AUDIO_SOURCE_CD = 1
57
     AUDIO_SOURCE_CD = 1
57
     AUDIO_SOURCE_RASPI = 2
58
     AUDIO_SOURCE_RASPI = 2
58
 
59
 
59
-    # https://shelly1l-3C6105E44F27
60
+    # http://shelly1l-3C6105E44F27
60
     def __init__(self, mqtt_client):
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
         self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/desk_light/switch")
68
         self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/desk_light/switch")
68
         self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/gfw/dirk/desk_light/br_ct")
69
         self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/gfw/dirk/desk_light/br_ct")
71
         self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/cd_player/switch")
72
         self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/cd_player/switch")
72
         self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/pc_dock/switch")
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
         self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/gfw/dirk/active_device_state/led")
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
         self.delayed_task = task.delayed(1.0, self.send_audio_source)
81
         self.delayed_task = task.delayed(1.0, self.send_audio_source)
81
         #
82
         #

+ 1
- 1
function/rooms.py View File

59
 class room_shelly_tradfri_light(room_shelly):
59
 class room_shelly_tradfri_light(room_shelly):
60
     def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
60
     def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
61
         super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
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
         self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
64
         self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
65
         #
65
         #

Loading…
Cancel
Save