From 8034ada12f89f05e24bd2e56fd7728e0296bd5e2 Mon Sep 17 00:00:00 2001 From: Lukas Svoboda Date: Tue, 20 Jan 2026 19:59:29 +0100 Subject: [PATCH] Add shared hass.data keys/constants for cleaner integration state storage --- dev/custom_components/sws12500/data.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 dev/custom_components/sws12500/data.py diff --git a/dev/custom_components/sws12500/data.py b/dev/custom_components/sws12500/data.py new file mode 100644 index 0000000..1dec410 --- /dev/null +++ b/dev/custom_components/sws12500/data.py @@ -0,0 +1,17 @@ +"""Shared keys and helpers for storing integration runtime state in hass.data. + +This integration uses `hass.data[DOMAIN][entry_id]` as a per-entry dictionary. +Keeping keys in one place prevents subtle bugs where different modules +store different value types under the same key. +""" + +from __future__ import annotations + +from typing import Final + + +# Per-entry dict keys stored under hass.data[DOMAIN][entry_id] +ENTRY_COORDINATOR: Final[str] = "coordinator" +ENTRY_ADD_ENTITIES: Final[str] = "async_add_entities" +ENTRY_DESCRIPTIONS: Final[str] = "sensor_descriptions" +ENTRY_LAST_OPTIONS: Final[str] = "last_options"