#!/usr/bin/env bash # Deploy the Butterfly-rack dashboard to the lab HA host. # # ./deploy.sh push dashboard, validate config, restart HA # ./deploy.sh --dash-only push dashboard only (browser refresh picks it up) # # The snippet files (configuration.butterfly.yaml, scripts.butterfly.yaml) are # merged into /config by hand the first time; this script never edits them on # the host, so it cannot clobber unrelated config. set -euo pipefail HOST="${HA_HOST:-lab@lab-desktop.local}" CONFIG_DIR="${HA_CONFIG_DIR:-/home/lab/HA/homeassistant}" # bind-mounted as /config CONTAINER="${HA_CONTAINER:-homeassistant}" DASH="ui-lovelace-butterfly.yaml" cd "$(dirname "$0")" echo "Copying $DASH to $HOST:$CONFIG_DIR/ ..." scp "$DASH" "$HOST:$CONFIG_DIR/$DASH" if [[ "${1:-}" == "--dash-only" ]]; then echo "Dashboard copied. Refresh the browser to see it." exit 0 fi echo "Validating config in the container ..." ssh "$HOST" "docker exec $CONTAINER python -m homeassistant --script check_config -c /config" echo "Restarting $CONTAINER ..." ssh "$HOST" "docker restart $CONTAINER" echo "Done. HA is restarting; the dashboard is at http://lab-desktop.local:8123/butterfly-rack"