Set language if desired

This commit is contained in:
Jan-Henrik 2023-02-08 23:01:26 +01:00
parent 21511c669c
commit 9f0e6a2d34
3 changed files with 6 additions and 1 deletions

View file

@ -1,6 +1,6 @@
--- ---
name: E-Paper Screenshotter 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} #image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch}
slug: screenshotter slug: screenshotter
description: Screenshot images for E-Paper pricetags description: Screenshot images for E-Paper pricetags
@ -21,6 +21,7 @@ options:
wait_seconds: 5 wait_seconds: 5
ha_url: https://homeassistant.local:8123 ha_url: https://homeassistant.local:8123
ha_token: 123aaa ha_token: 123aaa
ha_language: en
schema: schema:
image_path: str image_path: str
config_file: str config_file: str
@ -30,5 +31,6 @@ schema:
wait_seconds: int wait_seconds: int
ha_url: str ha_url: str
ha_token: str ha_token: str
ha_language: str
stage: experimental stage: experimental
init: false init: false

View file

@ -19,6 +19,7 @@ rotate = os.environ.get("SCREEN_ROTATE", default="0")
wait = os.environ.get("SCREEN_WAIT", default="5") wait = os.environ.get("SCREEN_WAIT", default="5")
ha_url = os.environ.get("SCREEN_HA_URL", default="") ha_url = os.environ.get("SCREEN_HA_URL", default="")
ha_token = os.environ.get("SCREEN_HA_TOKEN", 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 # Open another headless browser with height extracted above
chrome_options = Options() chrome_options = Options()
@ -55,6 +56,7 @@ while True:
if task.get("ha_auth"): if task.get("ha_auth"):
print("Doing 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('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"]) driver.get(task["url"])
time.sleep(int(wait)) time.sleep(int(wait))

View file

@ -10,6 +10,7 @@ export SCREEN_ROTATE="$(bashio::config 'rotate')"
export SCREEN_WAIT="$(bashio::config 'wait_seconds')" export SCREEN_WAIT="$(bashio::config 'wait_seconds')"
export SCREEN_HA_URL="$(bashio::config 'ha_url')" export SCREEN_HA_URL="$(bashio::config 'ha_url')"
export SCREEN_HA_TOKEN="$(bashio::config 'ha_token')" export SCREEN_HA_TOKEN="$(bashio::config 'ha_token')"
export SCREEN_HA_LANGUAGE="$(bashio::config 'ha_language')"
mkdir -p $SCREEN_IMAGE_PATH mkdir -p $SCREEN_IMAGE_PATH