Add configure-ha-token.sh

This commit is contained in:
2025-12-31 04:26:26 -08:00
parent c8ee6a975b
commit c40388b8a6

44
configure-ha-token.sh Normal file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Configure Home Assistant access token for auto-login
echo "Home Assistant Auto-Login Configuration"
echo "========================================"
echo ""
echo "To keep the dashboard logged in, you need a Long-Lived Access Token."
echo ""
echo "STEP 1: Create a token in Home Assistant"
echo " - Open Home Assistant in another browser"
echo " - Go to: Profile (bottom left) > Long-Lived Access Tokens"
echo " - Click 'Create Token'"
echo " - Give it a name like 'Dashboard Kiosk'"
echo " - Copy the token (you'll only see it once!)"
echo ""
echo "STEP 2: Enter the token below"
echo ""
read -p "Enter your Home Assistant Long-Lived Access Token: " TOKEN
if [ -z "$TOKEN" ]; then
echo "No token provided. Exiting."
exit 1
fi
# Update the dashboard script with the token
SCRIPT_FILE="$HOME/scripts/homeassistant-dashboard.sh"
BACKUP_FILE="$SCRIPT_FILE.backup"
# Create backup
cp "$SCRIPT_FILE" "$BACKUP_FILE"
echo "Created backup: $BACKUP_FILE"
# Update URL with token
sed -i "s|HA_URL=\"\${HA_URL:-.*}\"|HA_URL=\"\${HA_URL:-http://homeassistant.local:8123/lovelace/default_view?auth_token=$TOKEN}\"|" "$SCRIPT_FILE"
echo ""
echo "✓ Token configured!"
echo ""
echo "The dashboard will now auto-login using the token."
echo ""
echo "To test, restart the dashboard:"
echo " ~/scripts/restart-dashboard.sh"
echo ""
echo "Note: The token is stored in the script file. Keep it secure!"