diff --git a/screenshotter/config.yaml b/screenshotter/config.yaml index f1707ea..2e3122c 100644 --- a/screenshotter/config.yaml +++ b/screenshotter/config.yaml @@ -1,6 +1,6 @@ --- name: Screenshotter -version: 1.0.1.6 +version: 1.0.1.7 #image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch} slug: screenshotter description: Screenshot images for E-Paper pricetags diff --git a/screenshotter/rootfs/app/app.py b/screenshotter/rootfs/app/app.py index 1a9546a..61da90e 100644 --- a/screenshotter/rootfs/app/app.py +++ b/screenshotter/rootfs/app/app.py @@ -40,8 +40,7 @@ for image in config["images"]: while True: for i, task in enumerate(tasks): - now = datetime.datetime.now() - if task["next_execution"] > now: + if task["next_execution"] > datetime.datetime.now(): continue print(f"Running {task['name']}") driver = webdriver.Chrome(options=chrome_options, desired_capabilities=d) @@ -51,9 +50,11 @@ while True: if task.get("ha_auth"): print("Doing HA Auth") - driver.execute_script(f"window.localStorage.setItem('hassTokens', {{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}});") + print(driver.execute_script(f"window.localStorage.setItem('hassTokens', {{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}});")) + print(driver.execute_script(f"return window.localStorage.getItem('hassTokens');")) driver.get(task["url"]) time.sleep(int(wait)) + print(driver.execute_script(f"return window.localStorage.getItem('hassTokens');")) print("Making screenshot") @@ -67,6 +68,6 @@ while True: image = image.rotate(int(rotate), expand=True) file_name = f'{image_path}/{task["name"]}.png' image.save(file_name) - tasks[i]["next_execution"] = now + datetime.timedelta(minutes=task["period_minutes"]) + tasks[i]["next_execution"] = datetime.datetime.now() + datetime.timedelta(minutes=task["period_minutes"]) print(f"Task finished, next execution: {tasks[i]['next_execution']}") time.sleep(1)