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

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

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