Auto-Off function added for Circulation pump
This commit is contained in:
parent
0bb194dfd0
commit
4a99c33b15
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -10,3 +10,6 @@
|
||||
[submodule "devdi"]
|
||||
path = devdi
|
||||
url = https://git.mount-mockery.de/smarthome/smart_devdi.git
|
||||
[submodule "task"]
|
||||
path = task
|
||||
url = https://git.mount-mockery.de/pylib/task.git
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
from devices.base import base
|
||||
import json
|
||||
import task
|
||||
|
||||
|
||||
class shelly_sw1(base):
|
||||
@ -49,6 +50,8 @@ class shelly_sw1(base):
|
||||
super().__init__(mqtt_client, topic)
|
||||
self["state"] = "off"
|
||||
#
|
||||
self.__auto_off__ = None
|
||||
#
|
||||
self.mqtt_client.add_callback(self.topic + '/relay/0/command', self.__rx_set__)
|
||||
|
||||
def __rx_set__(self, client, userdata, message):
|
||||
@ -57,10 +60,24 @@ class shelly_sw1(base):
|
||||
self.logger.info("Received set data for %s: %s", key, repr(data))
|
||||
self.__set__(key, data)
|
||||
self.send_device_status(key)
|
||||
if key == "relay/0" and data.lower() == "on":
|
||||
self.power_on()
|
||||
if key == "relay/0":
|
||||
if data.lower() == "on":
|
||||
self.power_on()
|
||||
if self.__auto_off__ is not None:
|
||||
self.__auto_off__.run()
|
||||
else:
|
||||
if self.__auto_off__ is not None:
|
||||
self.__auto_off__.stop()
|
||||
|
||||
def send_device_status(self, key):
|
||||
data = self[key]
|
||||
self.logger.info("Sending status for %s: %s", key, repr(data))
|
||||
self.mqtt_client.send(self.topic + '/' + key, data)
|
||||
|
||||
def auto_off(self, sec):
|
||||
self.__auto_off__ = task.delayed(sec, self.__auto_off_func__)
|
||||
|
||||
def __auto_off_func__(self):
|
||||
if self.get(self.PROPERTIES[0]).lower() != 'off':
|
||||
self.__set__(self.PROPERTIES[0], "off")
|
||||
self.send_device_status(self.PROPERTIES[0])
|
||||
|
@ -78,6 +78,10 @@ if __name__ == "__main__":
|
||||
# FFE #
|
||||
#######
|
||||
loc = props.LOC_FFE
|
||||
# KITCHEN
|
||||
roo = props.ROO_KIT
|
||||
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_CIR)
|
||||
sml.auto_off(600)
|
||||
# LIVINGROOM
|
||||
roo = props.ROO_LIV
|
||||
sml = ddi.get(props.STG_SHE, loc, roo, props.FUN_MAL)
|
||||
|
1
task
Submodule
1
task
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit af35e83d1f07fd4cb9070bdb77cf1f3bdda3a463
|
Loading…
x
Reference in New Issue
Block a user