4 Commits
Author SHA1 Message Date
agessaman fc8a7a3751 refactor(ha_addon): simplify the add-on and managed-key code
- managed_keys owns the env var and file name, so the shared module no longer imports the add-on entrypoint; is_managed takes the loaded set instead of re-reading the file.
- One write_text_atomic() in ini_writer, used by update_ini_values and the add-on.
- as_bool uses configparser's BOOLEAN_STATES.
- Drop the app-level ManagedKeyError handler (every writer already handles it) and fold require_auth's early returns.
- Tests read config.yaml with PyYAML (added to the test extra) instead of a hand-written parser, and share setup helpers.
2026-11-09 21:39:26 -08:00
agessaman 01f45732a8 fix(managed_keys): match sections case-insensitively like the INI writer
update_ini_values matches sections ignoring case, but the guard compared them exactly, so a write to [web_viewer] port slipped past a managed [Web_Viewer] port and still rewrote the real key. Both now share one section normalization.
2026-11-09 21:21:47 -08:00
agessaman 2575e86a03 fix(ha_addon): close review gaps in ingress, backups, and exit status
- mypy is clean again (the CI typecheck job was red on new lines).
- The overlay's config backup goes to /data/backups/local, so it no longer overwrites the base config backup taken in the same second.
- One ha_ingress_enabled() helper; a malformed ha_ingress value counts as off instead of disabling the whole web viewer.
- An exception that escapes the bot (e.g. a BLE adapter error) now exits 1 too.
- The web manifest's icon paths are relative, so they resolve with or without a path prefix.
- The root-relative URL scan also catches .href/.src/.action assignments, EventSource, Worker, Audio, Image and io().
2026-11-09 20:38:11 -08:00
agessaman 966fa1726a feat(web_viewer): keep Home Assistant managed settings read-only
The add-on rewrites the keys it owns on every start, so editing them in the viewer would be silently undone. modules/managed_keys.py loads the list the add-on exports (MESHCORE_HA_MANAGED_KEYS) and guards writes in one place: ConfigIniStore.write_sections refuses to change or delete a managed key, and the viewer's other config.ini writers now go through that store instead of calling update_ini_values directly. The plugins page shows managed fields as disabled with "Managed by Home Assistant". With the variable unset, nothing changes.
2026-11-09 20:12:30 -08:00