Browse Source

Mode Switch for garden light added

master
Dirk Alders 7 months ago
parent
commit
985e18e27f
3 changed files with 15 additions and 10 deletions
  1. 10
    8
      function/garden.py
  2. 2
    2
      function/videv.py
  3. 3
    0
      topics.py

+ 10
- 8
function/garden.py View File

4
 
4
 
5
 import config
5
 import config
6
 import devdi.topic as props
6
 import devdi.topic as props
7
-from devices import group
8
-from function.db import get_radiator_data, set_radiator_data
9
 from function.helpers import day_event
7
 from function.helpers import day_event
10
-from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
11
 from function.rooms import room, room_collection
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
 import logging
10
 import logging
14
 
11
 
15
 try:
12
 try:
46
         #
43
         #
47
         # Virtual Device Interface
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
         # garland
50
         # garland
50
         self.garland_videv = videv_switching(
51
         self.garland_videv = videv_switching(
51
             mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV,
52
             mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV,
53
         )
54
         )
54
 
55
 
55
     def __day_events__(self, device, key, data):
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 View File

27
         super().__init__(mqtt_client, topic)
27
         super().__init__(mqtt_client, topic)
28
         self[self.KEY_STATE] = False
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
         self.set(self.KEY_STATE, message.payload == b'true')
33
         self.set(self.KEY_STATE, message.payload == b'true')
34
         self.__tx__(self.KEY_STATE, message.payload == b'true')
34
         self.__tx__(self.KEY_STATE, message.payload == b'true')
35
 
35
 

+ 3
- 0
topics.py View File

22
 TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV = "videv/gfw/dirk/active_brightness_device"
22
 TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV = "videv/gfw/dirk/active_brightness_device"
23
 TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV = "videv/gfw/dirk/audio_player"
23
 TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV = "videv/gfw/dirk/audio_player"
24
 TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV = "videv/gfw/dirk/heating_valve"
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
 TOPIC_GAR_GARDEN_GARLAND_VIDEV = 'videv/gar/garden/garland'
28
 TOPIC_GAR_GARDEN_GARLAND_VIDEV = 'videv/gar/garden/garland'
26
 
29
 
27
 # first floor west
30
 # first floor west

Loading…
Cancel
Save