Procházet zdrojové kódy

Device information added (comment); clean up

tags/v1.1.2^0
Dirk Alders před 1 rokem
rodič
revize
398d74ee81
5 změnil soubory, kde provedl 208 přidání a 17 odebrání
  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 Zobrazit soubor

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

+ 200
- 8
devices/__init__.py Zobrazit soubor

@@ -199,6 +199,35 @@ class base(mqtt_base):
199 199
 
200 200
 
201 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 231
     KEY_OUTPUT_0 = "relay/0"
203 232
     KEY_OUTPUT_1 = "relay/1"
204 233
     KEY_INPUT_0 = "input/0"
@@ -343,6 +372,19 @@ class shelly(base):
343 372
 
344 373
 
345 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 388
     KEY_LINKQUALITY = "linkquality"
347 389
     KEY_OUTPUT_0 = "state"
348 390
     #
@@ -389,6 +431,17 @@ class silvercrest_powerplug(base):
389 431
 
390 432
 
391 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 445
     KEY_BATTERY = "battery"
393 446
     KEY_BATTERY_LOW = "battery_low"
394 447
     KEY_LINKQUALITY = "linkquality"
@@ -426,6 +479,21 @@ class silvercrest_motion_sensor(base):
426 479
 
427 480
 
428 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 497
     KEY_OUTPUT_0 = "output/1"
430 498
     KEY_OUTPUT_1 = "output/2"
431 499
     KEY_OUTPUT_2 = "output/3"
@@ -533,6 +601,31 @@ class my_powerplug(base):
533 601
 
534 602
 
535 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 629
     KEY_LINKQUALITY = "linkquality"
537 630
     KEY_OUTPUT_0 = "state"
538 631
     KEY_BRIGHTNESS = "brightness"
@@ -635,6 +728,30 @@ class tradfri_light(base):
635 728
 
636 729
 
637 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 755
     ACTION_TOGGLE = "toggle"
639 756
     ACTION_BRIGHTNESS_UP = "brightness_up_click"
640 757
     ACTION_BRIGHTNESS_DOWN = "brightness_down_click"
@@ -685,6 +802,30 @@ class tradfri_button(base):
685 802
 
686 803
 
687 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 829
     KEY_LINKQUALITY = "linkquality"
689 830
     KEY_BATTERY = "battery"
690 831
     KEY_HEATING_SETPOINT = "current_heating_setpoint"
@@ -750,6 +891,56 @@ class brennenstuhl_heatingvalve(base):
750 891
 
751 892
 
752 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 944
     KEY_CD = "CD"
754 945
     KEY_LINE1 = "LINE1"
755 946
     KEY_LINE3 = "LINE3"
@@ -796,12 +987,19 @@ class remote(base):
796 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 997
     KEY_STATE = "state"
998
+    KEY_TITLE = "title"
801 999
     #
802 1000
     TX_TYPE = base.TX_VALUE
803 1001
     #
804
-    RX_KEYS = [KEY_STATE]
1002
+    RX_KEYS = [KEY_STATE, KEY_TITLE]
805 1003
 
806 1004
     def set_state(self, num, data):
807 1005
         """data: [True, False]"""
@@ -810,9 +1008,3 @@ class status(base):
810 1008
     def set_state_mcb(self, device, key, data):
811 1009
         self.logger.info("Changing state to %s", str(data))
812 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 Zobrazit soubor

@@ -140,13 +140,13 @@ class ground_floor_west_dirk(room):
140 140
 
141 141
         # Mediaplayer - Amplifier auto on
142 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 145
         # Mediaplayer - Audio source selection
146 146
         self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
147 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 150
         self.audio_source = self.AUDIO_SOURCE_PC
151 151
 
152 152
         # heating function

+ 3
- 3
function/rooms.py Zobrazit soubor

@@ -41,15 +41,15 @@ class room_collection(object):
41 41
                 if sub.__class__.__bases__[0].__name__ in self.ALLOWED_CLASSES:
42 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 45
         target = object_to_analyse or self
46 46
         #
47 47
         devices = []
48 48
         for name, obj in inspect.getmembers(target):
49 49
             if not callable(obj):                                       # sort out methods
50 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 53
                     elif obj.__module__ == "devices":
54 54
                         devices.append(obj)
55 55
                 except AttributeError:

+ 1
- 1
smart_brain.py Zobrazit soubor

@@ -15,7 +15,7 @@ logger = logging.getLogger(config.APP_NAME)
15 15
 
16 16
 VERS_MAJOR = 1
17 17
 VERS_MINOR = 1
18
-VERS_PATCH = 1
18
+VERS_PATCH = 2
19 19
 
20 20
 INFO_TOPIC = "__info__"
21 21
 INFO_DATA = {

Načítá se…
Zrušit
Uložit