Fix: Load Home Assistant UI config manually - v1.2.3

This commit is contained in:
Jørgen Ferdinand 2025-03-07 23:35:24 +01:00
parent 1b81ddc678
commit 04d5af4ea9
2 changed files with 18 additions and 11 deletions

View file

@ -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