Browse Source

Device information added (comment); clean up

tags/v1.1.2^0
Dirk Alders 1 year ago
parent
commit
398d74ee81
5 changed files with 208 additions and 17 deletions
  1. 0
    1
      base.py
  2. 200
    8
      devices/__init__.py
  3. 4
    4
      function/ground_floor_west.py
  4. 3
    3
      function/rooms.py
  5. 1
    1
      smart_brain.py

+ 0
- 1
base.py View File

11
 
11
 
12
     def __init__(self, default_values=None):
12
     def __init__(self, default_values=None):
13
         super().__init__(default_values or self.DEFAULT_VALUES)
13
         super().__init__(default_values or self.DEFAULT_VALUES)
14
-        self['__type__'] = self.__class__.__name__
15
         #
14
         #
16
         self.__callback_list__ = []
15
         self.__callback_list__ = []
17
         self.logger = logging.getLogger(ROOT_LOGGER_NAME).getChild("devices")
16
         self.logger = logging.getLogger(ROOT_LOGGER_NAME).getChild("devices")

+ 200
- 8
devices/__init__.py View File

199
 
199
 
200
 
200
 
201
 class shelly(base):
201
 class shelly(base):
202
+    """ Communication (MQTT)
203
+
204
+        shelly
205
+            +- relay
206
+            |      +- 0 ["on" / "off"]              <- status 
207
+            |      |  +- command ["on"/ "off"]      <- command
208
+            |      |  +- energy [numeric]           <- status
209
+            |      +- 1 ["on" / "off"]              <- status
210
+            |         +- command ["on"/ "off"]      <- command
211
+            |         +- energy [numeric]           <- status
212
+            +- input
213
+            |      +- 0 [0 / 1]                     <- status
214
+            |      +- 1 [0 / 1]                     <- status
215
+            +- input_event
216
+            |      +- 0                             <- status
217
+            |      +- 1                             <- status
218
+            +- logpush
219
+            |      +- 0 [0 / 1]                     <- status
220
+            |      +- 1 [0 / 1]                     <- status
221
+            +- temperature [numeric] °C             <- status
222
+            +- temperature_f [numeric] F            <- status
223
+            +- overtemperature [0 / 1]              <- status
224
+            +- id                                   <- status
225
+            +- model                                <- status
226
+            +- mac                                  <- status
227
+            +- ip                                   <- status
228
+            +- new_fw                               <- status
229
+            +- fw_ver                               <- status
230
+    """
202
     KEY_OUTPUT_0 = "relay/0"
231
     KEY_OUTPUT_0 = "relay/0"
203
     KEY_OUTPUT_1 = "relay/1"
232
     KEY_OUTPUT_1 = "relay/1"
204
     KEY_INPUT_0 = "input/0"
233
     KEY_INPUT_0 = "input/0"
343
 
372
 
344
 
373
 
345
 class silvercrest_powerplug(base):
374
 class silvercrest_powerplug(base):
375
+    """ Communication (MQTT)
376
+
377
+        silvercrest_powerplug {
378
+                            |      "state": ["ON" / "OFF"]
379
+                            |      "linkquality": [0...255] lqi
380
+                            | }
381
+                            +- get {
382
+                            |           "state": ""
383
+                            |      }
384
+                            +- set {
385
+                                        "state": ["ON" / "OFF"]
386
+                                   }
387
+    """
346
     KEY_LINKQUALITY = "linkquality"
388
     KEY_LINKQUALITY = "linkquality"
347
     KEY_OUTPUT_0 = "state"
389
     KEY_OUTPUT_0 = "state"
348
     #
390
     #
389
 
431
 
390
 
432
 
391
 class silvercrest_motion_sensor(base):
433
 class silvercrest_motion_sensor(base):
434
+    """ Communication (MQTT)
435
+
436
+        silvercrest_motion_sensor {
437
+                                      battery: [0...100] %
438
+                                      battery_low: [True, False]
439
+                                      linkquality: [0...255] lqi
440
+                                      occupancy: [True, False]
441
+                                      tamper: [True, False]
442
+                                      voltage: [0...] mV
443
+                                  }
444
+    """
392
     KEY_BATTERY = "battery"
445
     KEY_BATTERY = "battery"
393
     KEY_BATTERY_LOW = "battery_low"
446
     KEY_BATTERY_LOW = "battery_low"
394
     KEY_LINKQUALITY = "linkquality"
447
     KEY_LINKQUALITY = "linkquality"
426
 
479
 
427
 
480
 
428
 class my_powerplug(base):
481
 class my_powerplug(base):
482
+    """ Communication (MQTT)
483
+
484
+        my_powerplug
485
+                   +- output
486
+                           +- 1 [True, False]                   <- status
487
+                           |  +- set [True, False, "toggle"]    <- command
488
+                           +- 2 [True, False]                   <- status
489
+                           |  +- set [True, False, "toggle"]    <- command
490
+                           +- 3 [True, False]                   <- status
491
+                           |  +- set [True, False, "toggle"]    <- command
492
+                           +- 4 [True, False]                   <- status
493
+                           |  +- set [True, False, "toggle"]    <- command
494
+                           +- all
495
+                              +- set [True, False, "toggle"]    <- command
496
+    """
429
     KEY_OUTPUT_0 = "output/1"
497
     KEY_OUTPUT_0 = "output/1"
430
     KEY_OUTPUT_1 = "output/2"
498
     KEY_OUTPUT_1 = "output/2"
431
     KEY_OUTPUT_2 = "output/3"
499
     KEY_OUTPUT_2 = "output/3"
533
 
601
 
534
 
602
 
535
 class tradfri_light(base):
603
 class tradfri_light(base):
604
+    """ Communication (MQTT)
605
+
606
+        tradfri_light {
607
+                    |      "state": ["ON" / "OFF" / "TOGGLE"]
608
+                    |      "linkquality": [0...255] lqi
609
+                    |      "brightness": [0...254]
610
+                    |      "color_mode": ["color_temp"]
611
+                    |      "color_temp": ["coolest", "cool", "neutral", "warm", "warmest", 250...454]
612
+                    |      "color_temp_startup": ["coolest", "cool", "neutral", "warm", "warmest", "previous", 250...454]
613
+                    |      "update": []
614
+                    | }
615
+                    +- get {
616
+                    |           "state": ""
617
+                    |      }
618
+                    +- set {
619
+                                "state": ["ON" / "OFF"]
620
+                                "brightness": [0...256]
621
+                                "color_temp": [250...454]
622
+                                "transition": [0...] seconds
623
+                                "brightness_move": [-X...0...X] X/s
624
+                                "brightness_step": [-X...0...X]
625
+                                "color_temp_move": [-X...0...X] X/s
626
+                                "color_temp_step": [-X...0...X]
627
+                            }
628
+    """
536
     KEY_LINKQUALITY = "linkquality"
629
     KEY_LINKQUALITY = "linkquality"
537
     KEY_OUTPUT_0 = "state"
630
     KEY_OUTPUT_0 = "state"
538
     KEY_BRIGHTNESS = "brightness"
631
     KEY_BRIGHTNESS = "brightness"
635
 
728
 
636
 
729
 
637
 class tradfri_button(base):
730
 class tradfri_button(base):
731
+    """ Communication (MQTT)
732
+
733
+        tradfri_button {
734
+                            "action": [
735
+                                           "arrow_left_click",
736
+                                           "arrow_left_hold",
737
+                                           "arrow_left_release",
738
+                                           "arrow_right_click",
739
+                                           "arrow_right_hold",
740
+                                           "arrow_right_release",
741
+                                           "brightness_down_click",
742
+                                           "brightness_down_hold",
743
+                                           "brightness_down_release",
744
+                                           "brightness_up_click",
745
+                                           "brightness_up_hold",
746
+                                           "brightness_up_release",
747
+                                           "toggle"
748
+                                      ]
749
+                            "action_duration": [0...] s
750
+                            "battery": [0...100] %
751
+                            "linkquality": [0...255] lqi
752
+                            "update": []
753
+                       }
754
+    """
638
     ACTION_TOGGLE = "toggle"
755
     ACTION_TOGGLE = "toggle"
639
     ACTION_BRIGHTNESS_UP = "brightness_up_click"
756
     ACTION_BRIGHTNESS_UP = "brightness_up_click"
640
     ACTION_BRIGHTNESS_DOWN = "brightness_down_click"
757
     ACTION_BRIGHTNESS_DOWN = "brightness_down_click"
685
 
802
 
686
 
803
 
687
 class brennenstuhl_heatingvalve(base):
804
 class brennenstuhl_heatingvalve(base):
805
+    """ Communication (MQTT)
806
+
807
+        brennenstuhl_heatingvalve {
808
+                                |      "away_mode": ["ON", "OFF"]
809
+                                |      "battery": [0...100] %
810
+                                |      "child_lock": ["LOCK", "UNLOCK"]
811
+                                |      "current_heating_setpoint": [5...30] °C
812
+                                |      "linkquality": [0...255] lqi
813
+                                |      "local_temperature": [numeric] °C
814
+                                |      "preset": ["manual", ...]
815
+                                |      "system_mode": ["heat", ...]
816
+                                |      "valve_detection": ["ON", "OFF"]
817
+                                |      "window_detection": ["ON", "OFF"]
818
+                                | }
819
+                                +- set {
820
+                                           "away_mode": ["ON", "OFF", "TOGGLE"]
821
+                                           "child_lock": ["LOCK", "UNLOCK"]
822
+                                           "current_heating_setpoint": [5...30] °C
823
+                                           "preset": ["manual", ...]
824
+                                           "system_mode": ["heat", ...]
825
+                                           "valve_detection": ["ON", "OFF", "TOGGLE"]
826
+                                           "window_detection": ["ON", "OFF", "TOGGLE"]
827
+                                       }
828
+    """
688
     KEY_LINKQUALITY = "linkquality"
829
     KEY_LINKQUALITY = "linkquality"
689
     KEY_BATTERY = "battery"
830
     KEY_BATTERY = "battery"
690
     KEY_HEATING_SETPOINT = "current_heating_setpoint"
831
     KEY_HEATING_SETPOINT = "current_heating_setpoint"
750
 
891
 
751
 
892
 
752
 class remote(base):
893
 class remote(base):
894
+    """ Communication (MQTT)
895
+
896
+        remote (RAS5)                               <- command
897
+             +- CD [dc]
898
+             +- LINE1 [dc]
899
+             +- LINE2 [dc]
900
+             +- LINE3 [dc]
901
+             +- MUTE [dc]
902
+             +- POWER [dc]
903
+             +- VOLDOWN [dc]
904
+             +- VOLUP [dc]
905
+             +- PHONO [dc]
906
+             +- DOCK [dc]
907
+
908
+        remote (EUR642100)                          <- command
909
+             +- OPEN_CLOSE [dc]
910
+             +- VOLDOWN [dc]
911
+             +- VOLUP [dc]
912
+             +- ONE [dc]
913
+             +- TWO [dc]
914
+             +- THREE [dc]
915
+             +- FOUR [dc]
916
+             +- FIVE [dc]
917
+             +- SIX [dc]
918
+             +- SEVEN [dc]
919
+             +- EIGHT [dc]
920
+             +- NINE [dc]
921
+             +- ZERO [dc]
922
+             +- TEN [dc]
923
+             +- TEN_PLUS [dc]
924
+             +- PROGRAM [dc]
925
+             +- CLEAR [dc]
926
+             +- RECALL [dc]
927
+             +- TIME_MODE [dc]
928
+             +- A_B_REPEAT [dc]
929
+             +- REPEAT [dc]
930
+             +- RANDOM [dc]
931
+             +- AUTO_CUE [dc]
932
+             +- TAPE_LENGTH [dc]
933
+             +- SIDE_A_B [dc]
934
+             +- TIME_FADE [dc]
935
+             +- PEAK_SEARCH [dc]
936
+             +- SEARCH_BACK [dc]
937
+             +- SEARCH_FOR [dc]
938
+             +- TRACK_NEXT [dc]
939
+             +- TRACK_PREV [dc]
940
+             +- STOP [dc]
941
+             +- PAUSE [dc]
942
+             +- PLAY [dc]
943
+    """
753
     KEY_CD = "CD"
944
     KEY_CD = "CD"
754
     KEY_LINE1 = "LINE1"
945
     KEY_LINE1 = "LINE1"
755
     KEY_LINE3 = "LINE3"
946
     KEY_LINE3 = "LINE3"
796
         self.set_volume_up(False)
987
         self.set_volume_up(False)
797
 
988
 
798
 
989
 
799
-class status(base):
990
+class audio_status(base):
991
+    """ Communication (MQTT)
992
+
993
+        audio_status
994
+            +- state [True, False]                  <- status
995
+            +- title [text]                         <- status
996
+    """
800
     KEY_STATE = "state"
997
     KEY_STATE = "state"
998
+    KEY_TITLE = "title"
801
     #
999
     #
802
     TX_TYPE = base.TX_VALUE
1000
     TX_TYPE = base.TX_VALUE
803
     #
1001
     #
804
-    RX_KEYS = [KEY_STATE]
1002
+    RX_KEYS = [KEY_STATE, KEY_TITLE]
805
 
1003
 
806
     def set_state(self, num, data):
1004
     def set_state(self, num, data):
807
         """data: [True, False]"""
1005
         """data: [True, False]"""
810
     def set_state_mcb(self, device, key, data):
1008
     def set_state_mcb(self, device, key, data):
811
         self.logger.info("Changing state to %s", str(data))
1009
         self.logger.info("Changing state to %s", str(data))
812
         self.set_state(data)
1010
         self.set_state(data)
813
-
814
-
815
-class audio_status(status):
816
-    KEY_TITLE = "title"
817
-    #
818
-    RX_KEYS = [status.KEY_STATE, KEY_TITLE]

+ 4
- 4
function/ground_floor_west.py View File

140
 
140
 
141
         # Mediaplayer - Amplifier auto on
141
         # Mediaplayer - Amplifier auto on
142
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.powerplug_common.set_output_0_mcb, True)
142
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.powerplug_common.set_output_0_mcb, True)
143
-        self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
144
-        self.mpd_state.add_callback(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
143
+        self.spotify_state.add_callback(devices.audio_status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
144
+        self.mpd_state.add_callback(devices.audio_status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
145
         # Mediaplayer - Audio source selection
145
         # Mediaplayer - Audio source selection
146
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
146
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
147
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True)
147
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True)
148
-        self.spotify_state.add_callback(devices.status.KEY_STATE, True, self.audio_source_selector, True)
149
-        self.mpd_state.add_callback(devices.status.KEY_STATE, True, self.audio_source_selector, True)
148
+        self.spotify_state.add_callback(devices.audio_status.KEY_STATE, True, self.audio_source_selector, True)
149
+        self.mpd_state.add_callback(devices.audio_status.KEY_STATE, True, self.audio_source_selector, True)
150
         self.audio_source = self.AUDIO_SOURCE_PC
150
         self.audio_source = self.AUDIO_SOURCE_PC
151
 
151
 
152
         # heating function
152
         # heating function

+ 3
- 3
function/rooms.py View File

41
                 if sub.__class__.__bases__[0].__name__ in self.ALLOWED_CLASSES:
41
                 if sub.__class__.__bases__[0].__name__ in self.ALLOWED_CLASSES:
42
                     sub.all_off()
42
                     sub.all_off()
43
 
43
 
44
-    def all_devices(self, object_to_analyse=None):
44
+    def all_devices(self, object_to_analyse=None, depth=0):
45
         target = object_to_analyse or self
45
         target = object_to_analyse or self
46
         #
46
         #
47
         devices = []
47
         devices = []
48
         for name, obj in inspect.getmembers(target):
48
         for name, obj in inspect.getmembers(target):
49
             if not callable(obj):                                       # sort out methods
49
             if not callable(obj):                                       # sort out methods
50
                 try:
50
                 try:
51
-                    if obj.__module__.startswith('function.'):
52
-                        devices.extend(self.all_devices(obj))           # rekurse in function instances
51
+                    if obj.__module__.startswith('function.') and not obj.__module__.endswith('.videv'):
52
+                        devices.extend(self.all_devices(obj, depth+1))           # rekurse in function instances
53
                     elif obj.__module__ == "devices":
53
                     elif obj.__module__ == "devices":
54
                         devices.append(obj)
54
                         devices.append(obj)
55
                 except AttributeError:
55
                 except AttributeError:

+ 1
- 1
smart_brain.py View File

15
 
15
 
16
 VERS_MAJOR = 1
16
 VERS_MAJOR = 1
17
 VERS_MINOR = 1
17
 VERS_MINOR = 1
18
-VERS_PATCH = 1
18
+VERS_PATCH = 2
19
 
19
 
20
 INFO_TOPIC = "__info__"
20
 INFO_TOPIC = "__info__"
21
 INFO_DATA = {
21
 INFO_DATA = {

Loading…
Cancel
Save