Admin routes: settings read and update
WHY: the API service had no settings surface of its own — core NestQuestSettings is built from HA config-entry options, which the API (no config entry) cannot read. The core now has an HA-free durable settings store (core/settings_store.py) that keeps a validated ten-field JSON document in the existing nestquest_meta_state table under the well-known "settings" key: load_settings resolves it through the core _FIELDS validators (defaults for absent fields, per-field fallback over a corrupt document so the service never crashes) and update_settings validates every provided field BEFORE writing, so a rejected change — an unknown field or an invalid value, each named in the error — never leaves a half-applied document behind. The admin plane's GET/PATCH /settings routes are thin adapters over that store; the integration's HA options remain a temporary separate source until Feature 18 wires the client to the API.
This commit is contained in:
@@ -129,6 +129,17 @@ core_events = importlib.import_module(f"{_CORE_MODULE_NAME}.events")
|
||||
#: the snapshot builder's ``settings`` parameter takes.
|
||||
core_settings = importlib.import_module(f"{_CORE_MODULE_NAME}.settings")
|
||||
|
||||
#: The durable settings store (``core.settings_store.load_settings`` /
|
||||
#: ``update_settings``) the admin plane's settings routes read and
|
||||
#: write — the API's OWN settings source: a validated JSON document in
|
||||
#: the existing ``nestquest_meta_state`` table, resolved through the
|
||||
#: same core settings validators (the integration's HA config-entry
|
||||
#: options remain a temporary separate source until Feature 18 wires
|
||||
#: the client to the API).
|
||||
core_settings_store = importlib.import_module(
|
||||
f"{_CORE_MODULE_NAME}.settings_store"
|
||||
)
|
||||
|
||||
#: The children business layer (``core.children.create_child`` et al.)
|
||||
#: the admin plane's children routes call.
|
||||
core_children = importlib.import_module(f"{_CORE_MODULE_NAME}.children")
|
||||
@@ -206,4 +217,5 @@ __all__ = [
|
||||
"core_recurrence",
|
||||
"core_snapshot",
|
||||
"core_settings",
|
||||
"core_settings_store",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user