Skip to content

feat: config flow with YAML import and global settings (phase 1, draft for #60)#136

Draft
lollox80 wants to merge 2 commits into
rhizomatics:mainfrom
lollox80:feat/config-flow-phase1
Draft

feat: config flow with YAML import and global settings (phase 1, draft for #60)#136
lollox80 wants to merge 2 commits into
rhizomatics:mainfrom
lollox80:feat/config-flow-phase1

Conversation

@lollox80

Copy link
Copy Markdown
Collaborator

Motivation

First concrete step for #60. SuperNotify is currently YAML-only, which HA flags as legacy and which raises the entry barrier for new users. This draft implements the smallest phase that moves the basics to the UI without touching deliveries, scenarios or the notify.supernotify contract - so the phasing discussion in #60 can happen on real code.

Opened as a draft on purpose: happy to reshape it to match your phased plan whenever you get a chance to share it.

Changes

  • config_flow.py (new): user step (guided setup for a fresh install, no YAML required), one-shot YAML import (existing setups show up in the UI unchanged), and reconfigure flow for the global settings (paths, archive, dupe check window/policy, discovery toggles). Single entry enforced (single_config_entry + unique_id guard).
  • init.py: config entry lifecycle. An entry imported from YAML only mirrors settings for the UI - the legacy notify platform keeps owning notify.supernotify, so there is no duplicate service and zero behaviour change for existing users. A UI-created entry loads the legacy notify platform via discovery, so a user with no YAML still gets notify.supernotify.
  • notify.py: async_get_service now accepts config from the legacy YAML path or from a config entry via discovery_info; when starting from YAML it triggers the one-shot import. YAML artifacts that are not JSON-serializable (e.g. Jinja Template objects produced by schema validation) are converted to their source strings before being stored in the entry - otherwise the first entry update crashes with Type is not JSON serializable: Template (regression-tested).
  • manifest.json: config_flow: true, single_config_entry: true.
  • strings.json + 11 translations for the new steps (en, it, de, es, fr, hi, ja, nl, pl, pt, zh-Hans).
  • Tests: test_config_flow.py (user / import / reconfigure / serialization regressions) and test_init.py (imported-entry lifecycle, options-update reload).

Out of scope (by design, next phases)

Deliveries, scenarios, recipients and cameras stay YAML-only in this phase. The import keeps them in entry.options untouched so later phases can migrate them incrementally.

Testing

  • Full suite green with pytest-homeassistant-custom-component (user/import/reconfigure flows, serialization and update-listener regressions).
  • Smoke-tested on a real HA install (2026.6.x, SuperNotify v1.16.2): YAML import -> entry appears as "SuperNotify (imported)", notify.supernotify unchanged, reconfigure form pre-filled and localized; deliveries keep working (Alexa announce verified end-to-end).
  • ruff check / ruff format / codespell clean with the repo config.

lollox80 and others added 2 commits July 11, 2026 15:57
Implements the first phase of the UI configuration discussed in rhizomatics#60:

- config_flow.py: user step (guided setup for a fresh install), one-shot
  YAML import (existing setups appear in the UI unchanged), and
  reconfigure flow for global settings. Single entry enforced.
- __init__.py: config entry lifecycle. A YAML-imported entry only mirrors
  settings for the UI (the legacy notify platform keeps owning
  notify.supernotify - no duplicate service). A UI-created entry loads the
  legacy notify platform via discovery, so a user with no YAML still gets
  notify.supernotify.
- notify.py: async_get_service accepts config from the legacy YAML path or
  from a config entry via discovery_info; when starting from YAML it
  triggers the one-shot import. Non-JSON-serializable YAML artifacts
  (e.g. Jinja Template objects) are converted to their source strings
  before being stored in the entry (regression-tested).
- strings.json + 11 translations for the new steps.
- tests: config flow (user/import/reconfigure/serialization) and entry
  lifecycle.

Deliveries, scenarios, recipients and cameras stay YAML-only in this
phase; the flow only covers environment/global settings, by design, so
the phasing can follow the plan in rhizomatics#60.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant