Six silent failures found by installing this on a live system

Migrated the reference site off the YAML packages and onto the add-on. Every
bug below presented identically: the add-on starts, logs "started", serves its
UI, and cannot do its job.

- run.sh needs #!/usr/bin/with-contenv sh. s6-overlay sanitises the environment
  for services, so a plain shebang means SUPERVISOR_TOKEN is absent and every
  Core API call is 401 - while homeassistant_api: true makes permissions look
  granted. Startup now prints the token length and probes the API.
- Supervisor keys the image by config.yaml `version`, so rebuilding without a
  bump reuses the old image. Two fixes appeared not to work because of it.
- Alpine is musl and has no aiohttp wheel on PyPI; deps now come from apk so
  nothing compiles on a client's Pi.
- Alpine ships paho-mqtt 1.x, which has no CallbackAPIVersion. That raised at
  construction and took the control loop down with it - so MQTT setup is now
  wrapped too. Observability must never be able to stop the controller.
- MQTT discovery is published from on_connect: paho silently drops QoS-0
  publishes issued before the CONNACK, so the previous code announced nothing
  while logging "MQTT connected".
- Repeated failures now log once a minute. Six warnings a second rolled the log
  buffer and destroyed the startup diagnostics needed to find the 401.
- auto_start could never fire, because the store's defaults always supplied
  auto: False for the fallback to find.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NckgXecasQb2eSsPYNSW6
This commit is contained in:
2026-08-23 02:25:58 +02:00
co-authored by Claude Opus 5
parent 1abca15520
commit 594f8f9fc9
9 changed files with 162 additions and 36 deletions
+5 -6
View File
@@ -3,14 +3,13 @@ FROM ${BUILD_FROM}
ENV LANG=C.UTF-8 PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
RUN apk add --no-cache python3 py3-pip
# ⚠️ Install the dependencies from APK, not pip. Alpine ships musl, and there are
# no musl wheels for aiohttp on PyPI - pip would compile it from source on the
# client's Raspberry Pi, which needs a toolchain we would then have to ship and
# takes many minutes. apk has prebuilt packages for both.
RUN apk add --no-cache python3 py3-aiohttp py3-paho-mqtt
WORKDIR /opt/goodwe
COPY requirements.txt ./
# --break-system-packages: Alpine marks its python "externally managed" (PEP 668).
# This is a single-purpose container, so there is no environment to protect and a
# venv would only add a layer and a PATH to get wrong.
RUN pip3 install --no-cache-dir --break-system-packages -r requirements.txt
COPY app/ ./app/
COPY run.sh /run.sh