Browse Source

Auto-Off function added for Circulation pump

master
Dirk Alders 1 year ago
parent
commit
4a99c33b15
4 changed files with 27 additions and 2 deletions
  1. 3
    0
      .gitmodules
  2. 19
    2
      devices/shelly.py
  3. 4
    0
      home_emulation.py
  4. 1
    0
      task

+ 3
- 0
.gitmodules View File

10
 [submodule "devdi"]
10
 [submodule "devdi"]
11
 	path = devdi
11
 	path = devdi
12
 	url = https://git.mount-mockery.de/smarthome/smart_devdi.git
12
 	url = https://git.mount-mockery.de/smarthome/smart_devdi.git
13
+[submodule "task"]
14
+	path = task
15
+	url = https://git.mount-mockery.de/pylib/task.git

+ 19
- 2
devices/shelly.py View File

32
 
32
 
33
 from devices.base import base
33
 from devices.base import base
34
 import json
34
 import json
35
+import task
35
 
36
 
36
 
37
 
37
 class shelly_sw1(base):
38
 class shelly_sw1(base):
49
         super().__init__(mqtt_client, topic)
50
         super().__init__(mqtt_client, topic)
50
         self["state"] = "off"
51
         self["state"] = "off"
51
         #
52
         #
53
+        self.__auto_off__ = None
54
+        #
52
         self.mqtt_client.add_callback(self.topic + '/relay/0/command', self.__rx_set__)
55
         self.mqtt_client.add_callback(self.topic + '/relay/0/command', self.__rx_set__)
53
 
56
 
54
     def __rx_set__(self, client, userdata, message):
57
     def __rx_set__(self, client, userdata, message):
57
         self.logger.info("Received set data for %s: %s", key, repr(data))
60
         self.logger.info("Received set data for %s: %s", key, repr(data))
58
         self.__set__(key, data)
61
         self.__set__(key, data)
59
         self.send_device_status(key)
62
         self.send_device_status(key)
60
-        if key == "relay/0" and data.lower() == "on":
61
-            self.power_on()
63
+        if key == "relay/0":
64
+            if data.lower() == "on":
65
+                self.power_on()
66
+                if self.__auto_off__ is not None:
67
+                    self.__auto_off__.run()
68
+            else:
69
+                if self.__auto_off__ is not None:
70
+                    self.__auto_off__.stop()
62
 
71
 
63
     def send_device_status(self, key):
72
     def send_device_status(self, key):
64
         data = self[key]
73
         data = self[key]
65
         self.logger.info("Sending status for %s: %s", key, repr(data))
74
         self.logger.info("Sending status for %s: %s", key, repr(data))
66
         self.mqtt_client.send(self.topic + '/' + key, data)
75
         self.mqtt_client.send(self.topic + '/' + key, data)
76
+
77
+    def auto_off(self, sec):
78
+        self.__auto_off__ = task.delayed(sec, self.__auto_off_func__)
79
+
80
+    def __auto_off_func__(self):
81
+        if self.get(self.PROPERTIES[0]).lower() != 'off':
82
+            self.__set__(self.PROPERTIES[0], "off")
83
+            self.send_device_status(self.PROPERTIES[0])

+ 4
- 0
home_emulation.py View File

78
     # FFE #
78
     # FFE #
79
     #######
79
     #######
80
     loc = props.LOC_FFE
80
     loc = props.LOC_FFE
81
+    # KITCHEN
82
+    roo = props.ROO_KIT
83
+    sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_CIR)
84
+    sml.auto_off(600)
81
     # LIVINGROOM
85
     # LIVINGROOM
82
     roo = props.ROO_LIV
86
     roo = props.ROO_LIV
83
     sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
87
     sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)

+ 1
- 0
task

1
+Subproject commit af35e83d1f07fd4cb9070bdb77cf1f3bdda3a463

Loading…
Cancel
Save