sunrise and sunset depending motion sensor action for room_shelly_motion_sensor implemented
This commit is contained in:
parent
bc1c30cd3f
commit
73d6606902
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
|||||||
[submodule "task"]
|
[submodule "task"]
|
||||||
path = task
|
path = task
|
||||||
url = https://git.mount-mockery.de/pylib/task.git
|
url = https://git.mount-mockery.de/pylib/task.git
|
||||||
|
[submodule "geo"]
|
||||||
|
path = geo
|
||||||
|
url = https://git.mount-mockery.de/pylib/geo.git
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
import config
|
||||||
|
import geo
|
||||||
import inspect
|
import inspect
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class changed_value_indicator(dict):
|
class changed_value_indicator(dict):
|
||||||
@ -16,3 +18,15 @@ class changed_value_indicator(dict):
|
|||||||
rv = self.get(key) != value
|
rv = self.get(key) != value
|
||||||
self[key] = value
|
self[key] = value
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
|
def now():
|
||||||
|
return time.mktime(time.localtime())
|
||||||
|
|
||||||
|
|
||||||
|
def sunrise_time(time_offs_min=30):
|
||||||
|
return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + time_offs_min * 60
|
||||||
|
|
||||||
|
|
||||||
|
def sunset_time(time_offs_min=-30):
|
||||||
|
return time.mktime(geo.sun.sunset(config.GEO_POSITION)) + time_offs_min * 60
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import devices
|
import devices
|
||||||
|
from function.helpers import now, sunset_time, sunrise_time
|
||||||
import logging
|
import logging
|
||||||
import task
|
import task
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ class room_shelly_motion_sensor(room_shelly):
|
|||||||
cyclic_task.run()
|
cyclic_task.run()
|
||||||
|
|
||||||
def set_motion_detected(self, device, key, data):
|
def set_motion_detected(self, device, key, data):
|
||||||
|
if now() < sunrise_time(60) or now() > sunset_time(-60):
|
||||||
if device == self.motion_sensor_silvercrest_1:
|
if device == self.motion_sensor_silvercrest_1:
|
||||||
self.motion_detected_1 = data
|
self.motion_detected_1 = data
|
||||||
elif device == self.motion_sensor_silvercrest_2:
|
elif device == self.motion_sensor_silvercrest_2:
|
||||||
|
1
geo
Submodule
1
geo
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 11166bb27ad2335f7812fcb88c788397f5106751
|
@ -12,7 +12,7 @@ if __name__ == "__main__":
|
|||||||
if config.DEBUG:
|
if config.DEBUG:
|
||||||
report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
|
report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
|
||||||
else:
|
else:
|
||||||
report.stdoutLoggingConfigure(((config.APP_NAME, logging.INFO), (config.APP_NAME+'.devices', logging.WARNING)), report.SHORT_FMT)
|
report.stdoutLoggingConfigure(((config.APP_NAME, logging.INFO)), report.SHORT_FMT)
|
||||||
#
|
#
|
||||||
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
||||||
password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user