diff --git a/setup-ha-auto-login.sh b/setup-ha-auto-login.sh new file mode 100644 index 0000000..1ab7eac --- /dev/null +++ b/setup-ha-auto-login.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# Setup script for Home Assistant automatic login +# This helps configure Firefox to stay logged into Home Assistant + +echo "Home Assistant Auto-Login Setup" +echo "================================" +echo "" +echo "There are several ways to keep the dashboard logged in:" +echo "" +echo "OPTION 1: Long-Lived Access Token (Recommended)" +echo " - Create a token in Home Assistant:" +echo " Profile > Long-Lived Access Tokens > Create Token" +echo " - Then use URL: http://homeassistant.local:8123/lovelace/default_view?auth_token=YOUR_TOKEN" +echo "" +echo "OPTION 2: Trusted Networks" +echo " - Add this computer's IP to Home Assistant's trusted_networks" +echo " - Edit configuration.yaml or use the UI" +echo "" +echo "OPTION 3: Firefox Auto-Login" +echo " - Configure Firefox to save and auto-fill credentials" +echo "" +read -p "Which option do you want to use? (1/2/3): " choice + +case $choice in + 1) + echo "" + echo "Enter your Home Assistant Long-Lived Access Token:" + read -s TOKEN + echo "" + echo "Updating dashboard script with token..." + sed -i "s|HA_URL=\"\${HA_URL:-.*}\"|HA_URL=\"\${HA_URL:-http://homeassistant.local:8123/lovelace/default_view?auth_token=$TOKEN}\"|" ~/scripts/homeassistant-dashboard.sh + echo "✓ Token configured!" + echo " The dashboard will now auto-login using the token." + ;; + 2) + echo "" + echo "To use trusted networks:" + echo "1. Get this computer's IP:" + hostname -I | awk '{print $1}' + echo "" + echo "2. Add it to Home Assistant's trusted_networks in configuration.yaml:" + echo " http_config:" + echo " trusted_networks:" + echo " - $(hostname -I | awk '{print $1}')" + echo "" + echo "3. Restart Home Assistant" + echo "" + echo "After that, the dashboard should auto-login." + ;; + 3) + echo "" + echo "Setting up Firefox to save credentials..." + echo "You'll need to manually log in once, then Firefox will remember." + echo "" + echo "To test: Run ~/scripts/launch-dashboard.sh, log in manually once," + echo "then Firefox should remember your credentials." + ;; + *) + echo "Invalid choice" + exit 1 + ;; +esac