Last active
May 31, 2021 19:45
-
-
Save lmeulen/97d7af0a0a4a65424de1f6218258ffea to your computer and use it in GitHub Desktop.
Screens_mainloop_booleans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tahoma, utils, logging, datetime | |
CONFIG_FILE = 'systems.cred' | |
STATUS_FILE = "status_screens.dat" | |
COUNT_FILE = "status_screens_count.dat" | |
COUNT_FILE_OPENNOW = "status_screens_count_opennow.dat" | |
DELAY_MINUTES = 7 | |
def run(): | |
logger = logging.getLogger('home automation') | |
logger.debug("Script: Control screens") | |
screens = tahoma.Screens(config.get('ifttt_key')) | |
# Get status indicating a forced opening of screens is underway. Reset during night | |
force_opened = False if utils.is_now("04:00") else utils.get_current_status(STATUS_FILE) | |
utils.save_current_state(STATUS_FILE, force_opened) | |
pred_temp, pred_clouds, _ = utils.get_weather_forecast() | |
t, h, press, wb, wind_speed, uv, radiation, precip, cloudperc, cloudperc2, \ | |
raining, thunderstorm, _ = utils.get_current_weather() | |
close_today = determine_close_today(pred_clouds, pred_temp) | |
open_now, no_delay = determine_open_now(t, cloudperc, cloudperc2, raining, wind_speed, | |
radiation, precip, press, logger) | |
open_now = delay(open_now, no_delay, DELAY_MINUTES, COUNT_FILE_OPENNOW) | |
else: | |
open_now = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment