ソースを参照

Mode Switch for garden light added

master
Dirk Alders 7ヶ月前
コミット
985e18e27f
3個のファイルの変更15行の追加10行の削除
  1. 10
    8
      function/garden.py
  2. 2
    2
      function/videv.py
  3. 3
    0
      topics.py

+ 10
- 8
function/garden.py ファイルの表示

@@ -4,12 +4,9 @@
4 4
 
5 5
 import config
6 6
 import devdi.topic as props
7
-from devices import group
8
-from function.db import get_radiator_data, set_radiator_data
9 7
 from function.helpers import day_event
10
-from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
11 8
 from function.rooms import room, room_collection
12
-from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
9
+from function.videv import videv_switching, videv_pure_switch
13 10
 import logging
14 11
 
15 12
 try:
@@ -46,6 +43,10 @@ class garden_garden(room):
46 43
         #
47 44
         # Virtual Device Interface
48 45
         #
46
+        # mode
47
+        self.mode_videv = videv_pure_switch(
48
+            mqtt_client, config.TOPIC_GAR_GARDEN_MODE_VIDEV
49
+        )
49 50
         # garland
50 51
         self.garland_videv = videv_switching(
51 52
             mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV,
@@ -53,7 +54,8 @@ class garden_garden(room):
53 54
         )
54 55
 
55 56
     def __day_events__(self, device, key, data):
56
-        if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY):
57
-            self.garland_powerplug.set_output_0(True)
58
-        elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE):
59
-            self.garland_powerplug.set_output_0(False)
57
+        if self.mode_videv.get(self.mode_videv.KEY_STATE):
58
+            if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY):
59
+                self.garland_powerplug.set_output_0(True)
60
+            elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE):
61
+                self.garland_powerplug.set_output_0(False)

+ 2
- 2
function/videv.py ファイルの表示

@@ -27,9 +27,9 @@ class videv_pure_switch(videv_base):
27 27
         super().__init__(mqtt_client, topic)
28 28
         self[self.KEY_STATE] = False
29 29
         #
30
-        self.mqtt_client.add_callback(self.topic + '/state/set', self.state)
30
+        self.mqtt_client.add_callback(self.topic + '/state/set', self.__state__)
31 31
 
32
-    def state(self, mqtt_client, tbd, message):
32
+    def __state__(self, mqtt_client, userdata, message):
33 33
         self.set(self.KEY_STATE, message.payload == b'true')
34 34
         self.__tx__(self.KEY_STATE, message.payload == b'true')
35 35
 

+ 3
- 0
topics.py ファイルの表示

@@ -22,6 +22,9 @@ TOPIC_GFW_DIRK_PC_DOCK_VIDEV = "videv/gfw/dirk/pc_dock"
22 22
 TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV = "videv/gfw/dirk/active_brightness_device"
23 23
 TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV = "videv/gfw/dirk/audio_player"
24 24
 TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV = "videv/gfw/dirk/heating_valve"
25
+
26
+# garden
27
+TOPIC_GAR_GARDEN_MODE_VIDEV = 'videv/gar/garden/mode'
25 28
 TOPIC_GAR_GARDEN_GARLAND_VIDEV = 'videv/gar/garden/garland'
26 29
 
27 30
 # first floor west

読み込み中…
キャンセル
保存