#!/usr/bin/with-contenv sh # ⚠️ THE SHEBANG IS LOAD-BEARING. It must be `with-contenv`, not `env sh`. # # The Home Assistant base images run s6-overlay, which starts services with a # SANITISED environment: the container's variables live in # /run/s6/container_environment and are only re-imported by `with-contenv`. # With a plain `#!/usr/bin/env sh` the add-on starts perfectly, serves its UI, # and then fails EVERY Home Assistant call with 401 Unauthorized - because # SUPERVISOR_TOKEN is simply absent, while `homeassistant_api: true` in # config.yaml makes the permissions look correctly granted. # # Diagnosed 2026-08-23 the slow way. The startup probe in main.py now prints the # token length so the next person sees it in one line instead of an hour. set -e cd /opt/goodwe exec python3 -m app.main