|
@@ -3,6 +3,7 @@
|
3
|
3
|
#
|
4
|
4
|
|
5
|
5
|
import devices
|
|
6
|
+from function.helpers import now, sunset_time, sunrise_time
|
6
|
7
|
import logging
|
7
|
8
|
import task
|
8
|
9
|
|
|
@@ -77,13 +78,14 @@ class room_shelly_motion_sensor(room_shelly):
|
77
|
78
|
cyclic_task.run()
|
78
|
79
|
|
79
|
80
|
def set_motion_detected(self, device, key, data):
|
80
|
|
- if device == self.motion_sensor_silvercrest_1:
|
81
|
|
- self.motion_detected_1 = data
|
82
|
|
- elif device == self.motion_sensor_silvercrest_2:
|
83
|
|
- self.motion_detected_2 = data
|
84
|
|
- if data is True:
|
85
|
|
- logger.info("%s: Motion detected - Switching on main light %s", device.topic, self.main_light_shelly.topic)
|
86
|
|
- self.main_light_shelly.set_output_0(True)
|
|
81
|
+ if now() < sunrise_time(60) or now() > sunset_time(-60):
|
|
82
|
+ if device == self.motion_sensor_silvercrest_1:
|
|
83
|
+ self.motion_detected_1 = data
|
|
84
|
+ elif device == self.motion_sensor_silvercrest_2:
|
|
85
|
+ self.motion_detected_2 = data
|
|
86
|
+ if data is True:
|
|
87
|
+ logger.info("%s: Motion detected - Switching on main light %s", device.topic, self.main_light_shelly.topic)
|
|
88
|
+ self.main_light_shelly.set_output_0(True)
|
87
|
89
|
|
88
|
90
|
def reload_timer(self, device, key, data):
|
89
|
91
|
self.main_light_timer = self.timer_value
|