From 9f0e6a2d340402b65d08c1a9d7c93cbb2a48f3c3 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Wed, 8 Feb 2023 23:01:26 +0100 Subject: [PATCH] Set language if desired --- screenshotter/config.yaml | 4 +++- screenshotter/rootfs/app/app.py | 2 ++ screenshotter/rootfs/etc/services.d/screenshotter/run | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/screenshotter/config.yaml b/screenshotter/config.yaml index c650084..f78d6da 100644 --- a/screenshotter/config.yaml +++ b/screenshotter/config.yaml @@ -1,6 +1,6 @@ --- name: E-Paper Screenshotter -version: 1.0.1.13 +version: 1.0.1.14 #image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch} slug: screenshotter description: Screenshot images for E-Paper pricetags @@ -21,6 +21,7 @@ options: wait_seconds: 5 ha_url: https://homeassistant.local:8123 ha_token: 123aaa + ha_language: en schema: image_path: str config_file: str @@ -30,5 +31,6 @@ schema: wait_seconds: int ha_url: str ha_token: str + ha_language: str stage: experimental init: false diff --git a/screenshotter/rootfs/app/app.py b/screenshotter/rootfs/app/app.py index 316d56a..d3c6e4d 100644 --- a/screenshotter/rootfs/app/app.py +++ b/screenshotter/rootfs/app/app.py @@ -19,6 +19,7 @@ rotate = os.environ.get("SCREEN_ROTATE", default="0") wait = os.environ.get("SCREEN_WAIT", default="5") ha_url = os.environ.get("SCREEN_HA_URL", default="") ha_token = os.environ.get("SCREEN_HA_TOKEN", default="") +ha_language = os.environ.get("SCREEN_HA_LANGUAGE", default="en") # Open another headless browser with height extracted above chrome_options = Options() @@ -55,6 +56,7 @@ while True: if task.get("ha_auth"): print("Doing HA Auth") driver.execute_script(f"window.localStorage.setItem('hassTokens', JSON.stringify({{hassUrl: '{ha_url}', access_token: '{ha_token}', token_type: 'Bearer'}}));") + driver.execute_script(f"window.localStorage.setItem('selectedLanguage', '{ha_language}');") driver.get(task["url"]) time.sleep(int(wait)) diff --git a/screenshotter/rootfs/etc/services.d/screenshotter/run b/screenshotter/rootfs/etc/services.d/screenshotter/run index a8e7a29..30c2f84 100644 --- a/screenshotter/rootfs/etc/services.d/screenshotter/run +++ b/screenshotter/rootfs/etc/services.d/screenshotter/run @@ -10,6 +10,7 @@ export SCREEN_ROTATE="$(bashio::config 'rotate')" export SCREEN_WAIT="$(bashio::config 'wait_seconds')" export SCREEN_HA_URL="$(bashio::config 'ha_url')" export SCREEN_HA_TOKEN="$(bashio::config 'ha_token')" +export SCREEN_HA_LANGUAGE="$(bashio::config 'ha_language')" mkdir -p $SCREEN_IMAGE_PATH