From 04d5af4ea92de1be6416ed40f78b902f3b78c530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Ferdinand?= Date: Fri, 7 Mar 2025 23:35:24 +0100 Subject: [PATCH] Fix: Load Home Assistant UI config manually - v1.2.3 --- newt/config.yaml | 11 +++++------ newt/run.sh | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/newt/config.yaml b/newt/config.yaml index 9562563..b1c7df0 100644 --- a/newt/config.yaml +++ b/newt/config.yaml @@ -1,5 +1,5 @@ name: "Newt Add-on" -version: "1.2.2" +version: "1.2.3" slug: "newt" description: "Runs Newt inside Home Assistant OS" arch: @@ -15,17 +15,16 @@ privileged: - NET_ADMIN - DAC_READ_SEARCH options: - PANGOLIN_ENDPOINT: "https://yourendpoint.com" + PANGOLIN_ENDPOINT: "https://example.com" NEWT_ID: "your_newt_id" NEWT_SECRET: "your_newt_secret" schema: PANGOLIN_ENDPOINT: "str" NEWT_ID: "str" NEWT_SECRET: "str" -environment: - PANGOLIN_ENDPOINT: "{options[PANGOLIN_ENDPOINT]}" - NEWT_ID: "{options[NEWT_ID]}" - NEWT_SECRET: "{options[NEWT_SECRET]}" +# Ensure that environment variables are set correctly +map: + - config:rw hassio_api: true homeassistant_api: true auth_api: true diff --git a/newt/run.sh b/newt/run.sh index 0899794..1effbe5 100644 --- a/newt/run.sh +++ b/newt/run.sh @@ -3,13 +3,21 @@ set -e # Stop the script on errors echo "🔹 Starting Newt inside Home Assistant OS..." -# Load configuration from environment variables set by Home Assistant -export PANGOLIN_ENDPOINT=${PANGOLIN_ENDPOINT} -export NEWT_ID=${NEWT_ID} -export NEWT_SECRET=${NEWT_SECRET} +# Load configuration manually from the add-on options JSON file +CONFIG_PATH="/data/options.json" + +if [[ ! -f "$CONFIG_PATH" ]]; then + echo "❌ ERROR: Configuration file not found at $CONFIG_PATH!" + exit 1 +fi + +# Extract values from the JSON config +PANGOLIN_ENDPOINT=$(jq -r '.PANGOLIN_ENDPOINT' "$CONFIG_PATH") +NEWT_ID=$(jq -r '.NEWT_ID' "$CONFIG_PATH") +NEWT_SECRET=$(jq -r '.NEWT_SECRET' "$CONFIG_PATH") # Validate if configuration values are provided -if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" ]]; then +if [[ -z "$PANGOLIN_ENDPOINT" || -z "$NEWT_ID" || -z "$NEWT_SECRET" || "$PANGOLIN_ENDPOINT" == "null" ]]; then echo "❌ ERROR: Missing required configuration values!" exit 1 fi