This commit is contained in:
2020-07-07 18:50:18 +02:00
parent ffbb2a0071
commit f852a9f3e2
5 changed files with 75 additions and 10 deletions

View File

@@ -21,8 +21,8 @@ class EchoScheduler:
print('Echo Scheduler Thread started!')
# Schedule Tasks
schedule.every(2).minutes.do(EchoScheduler.getClimateData)
schedule.every(2).minutes.do(EchoScheduler.getLightData)
schedule.every(2.1).minutes.do(EchoScheduler.getClimateData)
schedule.every(2.2).minutes.do(EchoScheduler.getLightData)
schedule.every(1).minute.do(EchoScheduler.checkAutomaticShutdown)
schedule.every(1).minute.do(EchoScheduler.checkAutomaticBlinds)
@@ -57,25 +57,53 @@ class EchoScheduler:
@staticmethod
def checkAutomaticShutdown():
# Get Device
collection = EchoDB.EchoDB.database['Devices']
device = collection.find_one({'uuid': '9472-4f60'})
#
# Main Light
#
# Get Device
device_main_light = collection.find_one({'uuid': '9472-4f60'})
# Check if light is on
if device['status'] == "off":
if device_main_light['status'] == "off":
return;
# Check if automatic movement is enabled
if device['automatic_movement'] == False:
if device_main_light['automatic_movement'] == False:
return;
# Check if date is current time is past device automatic shutdown time
automatic_shutdown_time = device['automatic_shutdown']
automatic_shutdown_time = device_main_light['automatic_shutdown']
current_time = datetime.datetime.now()
if current_time > automatic_shutdown_time:
Controller.Controller.handle_action(device, "off")
print('Scheduler Turned off light')
Controller.Controller.handle_action(device_main_light, "off")
print('Scheduler Turned off main light')
#
# LED Light
#
# Get Device
device_bed_led = collection.find_one({'uuid': '34gr-54jf'})
# Check if light is on
if device_bed_led['status'] == "off":
return;
# Check if automatic movement is enabled
if device_bed_led['automatic_movement'] == False:
return;
# Check if date is current time is past device automatic shutdown time
automatic_shutdown_time = device_bed_led['automatic_shutdown']
current_time = datetime.datetime.now()
if current_time > automatic_shutdown_time:
Controller.Controller.handle_action(device_bed_led, "off")
print('Scheduler Turned off main bed led light')
@staticmethod
def checkAutomaticBlinds():