Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
710ef0dcf2 | ||
|
|
f668cf95b0 | ||
|
|
6d570e1c0e | ||
|
|
316503cf73 |
@@ -174,8 +174,23 @@ is simply a Home Assistant client.
|
|||||||
Assistant user it may also reach other permitted Home Assistant entities
|
Assistant user it may also reach other permitted Home Assistant entities
|
||||||
and services.
|
and services.
|
||||||
|
|
||||||
2. **Build a dashboard with only the NestQuest panel cards.** Create a
|
2. **Build a dashboard with only the NestQuest panel cards.** The
|
||||||
Lovelace dashboard whose **URL slug is `nestquest`** (Settings →
|
recommended path is the **zero-config dashboard strategy**: create a
|
||||||
|
Lovelace dashboard whose URL slug is `nestquest` with
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
strategy:
|
||||||
|
type: custom:nestquest-party
|
||||||
|
```
|
||||||
|
|
||||||
|
and no views of your own — the strategy generates the party-board and
|
||||||
|
quest-log views (each already in Panel layout) from the household
|
||||||
|
roster at render time. Optional `url_path` and `weather_entity` keys
|
||||||
|
may sit beside `strategy:`. The manual instructions below describe
|
||||||
|
building the two views by hand if you prefer not to use the strategy.
|
||||||
|
|
||||||
|
**Manual alternative:** create a Lovelace dashboard whose **URL slug
|
||||||
|
is `nestquest`** (Settings →
|
||||||
Dashboards → Edit → URL slug). A functional panel needs **two** views
|
Dashboards → Edit → URL slug). A functional panel needs **two** views
|
||||||
in that dashboard, each with its own card config from
|
in that dashboard, each with its own card config from
|
||||||
`design/ENTITIES-AND-SERVICES.md` §4. Give the views these exact URL
|
`design/ENTITIES-AND-SERVICES.md` §4. Give the views these exact URL
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ SQLite file, the migrations, and every business rule. Setup builds the
|
|||||||
entry's ONE shared API client, the coordinator that polls the panel
|
entry's ONE shared API client, the coordinator that polls the panel
|
||||||
snapshot through it, and the SSE subscription that re-fires the API's
|
snapshot through it, and the SSE subscription that re-fires the API's
|
||||||
transition frames on the HA bus, registers the single
|
transition frames on the HA bus, registers the single
|
||||||
``nestquest.complete_quest`` proxy service, and forwards the sensor and
|
``nestquest.complete_quest`` proxy service, registers the zero-config
|
||||||
|
panel dashboard (Feature 20), and forwards the sensor and
|
||||||
binary_sensor platforms.
|
binary_sensor platforms.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
@@ -29,6 +30,7 @@ from .const import (
|
|||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
)
|
)
|
||||||
from .coordinator import NestQuestCoordinator, coordinator_client_from_entry
|
from .coordinator import NestQuestCoordinator, coordinator_client_from_entry
|
||||||
|
from .dashboard import async_register_dashboard
|
||||||
from .frontend import async_register_frontend
|
from .frontend import async_register_frontend
|
||||||
from .services import async_deregister_services, async_register_services
|
from .services import async_deregister_services, async_register_services
|
||||||
from .sse import NestQuestEventStream
|
from .sse import NestQuestEventStream
|
||||||
@@ -87,6 +89,13 @@ async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool:
|
|||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up NestQuest from a config entry."""
|
"""Set up NestQuest from a config entry."""
|
||||||
await async_register_frontend(hass)
|
await async_register_frontend(hass)
|
||||||
|
# The zero-config panel dashboard (Feature 20): register the
|
||||||
|
# storage-mode strategy dashboard if no dashboard under the stable
|
||||||
|
# url_path exists yet. Unavailability of the Lovelace dashboards
|
||||||
|
# collection (YAML mode, lovelace not loaded) logs a warning and
|
||||||
|
# NEVER fails setup; an existing dashboard — ours or the user's —
|
||||||
|
# is left untouched, so a reload cannot duplicate it.
|
||||||
|
await async_register_dashboard(hass)
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
|
||||||
async def _async_update_listener(
|
async def _async_update_listener(
|
||||||
|
|||||||
@@ -43,6 +43,18 @@ DOMAIN_SERVICES: tuple[str, ...] = (
|
|||||||
|
|
||||||
SQLITE_DB_FILENAME = "nestquest.db"
|
SQLITE_DB_FILENAME = "nestquest.db"
|
||||||
|
|
||||||
|
# Zero-config panel dashboard (Feature 20): ONE storage-mode Lovelace
|
||||||
|
# dashboard registered on setup whose config carries the bundle's
|
||||||
|
# ``custom:nestquest-party`` strategy (frontend/src/strategy.ts) — the
|
||||||
|
# views are generated at render time from the household roster. The
|
||||||
|
# url_path IS the domain: the stable key idempotency is keyed on (a
|
||||||
|
# reload or a second entry never duplicates it, and a dashboard already
|
||||||
|
# registered under it — ours or the user's — is left untouched).
|
||||||
|
DASHBOARD_URL_PATH = DOMAIN
|
||||||
|
DASHBOARD_TITLE = "NestQuest"
|
||||||
|
DASHBOARD_ICON = "mdi:party-popper"
|
||||||
|
DASHBOARD_STRATEGY_TYPE = "custom:nestquest-party"
|
||||||
|
|
||||||
# Configuration keys and default values
|
# Configuration keys and default values
|
||||||
CONF_HORIZON_DAYS = "horizon_days"
|
CONF_HORIZON_DAYS = "horizon_days"
|
||||||
DEFAULT_HORIZON_DAYS = 14
|
DEFAULT_HORIZON_DAYS = 14
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
"""Zero-config panel dashboard registration for NestQuest (Feature 20).
|
||||||
|
|
||||||
|
On setup the integration registers ONE storage-mode Lovelace dashboard
|
||||||
|
whose CONFIG uses the bundle's ``custom:nestquest-party`` strategy (see
|
||||||
|
``frontend/src/strategy.ts``): the views themselves are GENERATED at
|
||||||
|
render time from the household roster, so the stored dashboard config
|
||||||
|
carries nothing but the strategy reference.
|
||||||
|
|
||||||
|
Registration mirrors the REAL two-step sequence the lovelace
|
||||||
|
integration itself uses when it creates the onboarding map dashboard
|
||||||
|
(``homeassistant/components/lovelace/__init__.py``,
|
||||||
|
``_create_map_dashboard``):
|
||||||
|
|
||||||
|
1. create the dashboard METADATA through the ``DashboardsCollection``
|
||||||
|
(``hass.data["lovelace"]["dashboards_collection"]``) — url_path,
|
||||||
|
title, icon, sidebar visibility. The strategy reference is NOT part
|
||||||
|
of the create payload: the collection's create schema allows only
|
||||||
|
the metadata fields, so a ``strategy`` key there fails the whole
|
||||||
|
create (this was the silent no-op the first implementation shipped).
|
||||||
|
2. save the dashboard CONFIG — ``{"strategy": ...}`` — through the
|
||||||
|
per-url_path CONTENT manager that the collection's change listener
|
||||||
|
registers under ``hass.data["lovelace"]["dashboards"][url_path]``
|
||||||
|
(a ``LovelaceStorage``), exactly the second step HA performs.
|
||||||
|
|
||||||
|
Registration is IDEMPOTENT — a dashboard already under the stable
|
||||||
|
``url_path`` (ours or a user's) skips BOTH steps and its stored config
|
||||||
|
is never overwritten — and the Lovelace surfaces being unavailable
|
||||||
|
(YAML mode, lovelace not loaded) is a logged warning, never a setup
|
||||||
|
failure.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from .const import (
|
||||||
|
DASHBOARD_ICON,
|
||||||
|
DASHBOARD_STRATEGY_TYPE,
|
||||||
|
DASHBOARD_TITLE,
|
||||||
|
DASHBOARD_URL_PATH,
|
||||||
|
LOGGER,
|
||||||
|
)
|
||||||
|
|
||||||
|
_LOGGER = LOGGER
|
||||||
|
|
||||||
|
# Single-flight guard for the check-then-create below: HA can set up
|
||||||
|
# several config entries CONCURRENTLY, and two overlapping setups would
|
||||||
|
# both pass the exists-check and race on the url_path create. The lock
|
||||||
|
# is per hass instance (kept as an attribute on the hass object, since
|
||||||
|
# hass.data is the integrations' shared registry the unload path
|
||||||
|
# empties) rather than one module-level asyncio.Lock — a bare
|
||||||
|
# module-level lock binds to whichever event loop first awaits it and
|
||||||
|
# raises RuntimeError on any other loop, while the race it must prevent
|
||||||
|
# only exists between setups running on the SAME hass anyway.
|
||||||
|
_REGISTRATION_LOCK_ATTR = "_nestquest_dashboard_registration_lock"
|
||||||
|
|
||||||
|
|
||||||
|
def _registration_lock(hass: HomeAssistant) -> asyncio.Lock:
|
||||||
|
"""Return the per-hass registration lock, creating it on first use."""
|
||||||
|
lock = getattr(hass, _REGISTRATION_LOCK_ATTR, None)
|
||||||
|
if lock is None:
|
||||||
|
lock = asyncio.Lock()
|
||||||
|
setattr(hass, _REGISTRATION_LOCK_ATTR, lock)
|
||||||
|
return lock
|
||||||
|
|
||||||
|
|
||||||
|
def _lovelace_data(hass: HomeAssistant) -> dict | None:
|
||||||
|
"""Return ``hass.data["lovelace"]`` when it is the real dict shape.
|
||||||
|
|
||||||
|
The lovelace integration stores a plain DICT of surfaces (``mode``,
|
||||||
|
``dashboards``, ``dashboards_collection``, ``resources``,
|
||||||
|
``yaml_dashboards``) under the ``lovelace`` key; anything else
|
||||||
|
(missing key, unexpected object) means the surfaces below cannot be
|
||||||
|
reached and registration must warn and continue.
|
||||||
|
"""
|
||||||
|
lovelace_data = hass.data.get("lovelace")
|
||||||
|
if not isinstance(lovelace_data, dict):
|
||||||
|
return None
|
||||||
|
return lovelace_data
|
||||||
|
|
||||||
|
|
||||||
|
def _dashboards_collection(hass: HomeAssistant):
|
||||||
|
"""Return the Lovelace dashboards METADATA collection, or None.
|
||||||
|
|
||||||
|
The collection lives at ``hass.data["lovelace"]
|
||||||
|
["dashboards_collection"]`` — NOT under ``["dashboards"]``, which
|
||||||
|
maps url_path to the per-dashboard CONTENT managers
|
||||||
|
(``LovelaceStorage``/``LovelaceYAML``). A missing key (lovelace
|
||||||
|
not loaded) and a missing/None entry (YAML mode never sets the
|
||||||
|
collection) both mean "cannot create storage dashboards here" —
|
||||||
|
callers log and continue. The presence of the surface is verified
|
||||||
|
by capability (``async_create_item`` callable), not by type, so no
|
||||||
|
lovelace import is needed.
|
||||||
|
"""
|
||||||
|
lovelace_data = _lovelace_data(hass)
|
||||||
|
if lovelace_data is None:
|
||||||
|
return None
|
||||||
|
collection = lovelace_data.get("dashboards_collection")
|
||||||
|
if collection is None or not callable(
|
||||||
|
getattr(collection, "async_create_item", None)
|
||||||
|
):
|
||||||
|
return None
|
||||||
|
return collection
|
||||||
|
|
||||||
|
|
||||||
|
def _dashboard_store(hass: HomeAssistant, url_path: str):
|
||||||
|
"""Return a url_path's dashboard CONTENT manager, or None.
|
||||||
|
|
||||||
|
After a metadata create, the collection's change listener registers
|
||||||
|
a ``LovelaceStorage`` for the new dashboard under
|
||||||
|
``hass.data["lovelace"]["dashboards"][url_path]``; the dashboard
|
||||||
|
CONFIG (the strategy reference) is saved through THAT manager —
|
||||||
|
the second step of HA's own dashboard creation.
|
||||||
|
"""
|
||||||
|
lovelace_data = _lovelace_data(hass)
|
||||||
|
if lovelace_data is None:
|
||||||
|
return None
|
||||||
|
dashboards = lovelace_data.get("dashboards")
|
||||||
|
if not isinstance(dashboards, dict):
|
||||||
|
return None
|
||||||
|
store = dashboards.get(url_path)
|
||||||
|
if store is None or not callable(getattr(store, "async_save", None)):
|
||||||
|
return None
|
||||||
|
return store
|
||||||
|
|
||||||
|
|
||||||
|
def _item_url_path(item) -> str | None:
|
||||||
|
"""Read a dashboard item's ``url_path`` through either access shape.
|
||||||
|
|
||||||
|
The collection hands back storage items as dicts while builtin
|
||||||
|
dashboards come back as config objects; the url_path is reachable
|
||||||
|
through ``item["url_path"]`` or ``item.url_path`` respectively.
|
||||||
|
"""
|
||||||
|
url_path = getattr(item, "url_path", None)
|
||||||
|
if isinstance(url_path, str):
|
||||||
|
return url_path
|
||||||
|
get_url_path = getattr(item, "get", None)
|
||||||
|
if callable(get_url_path):
|
||||||
|
value = get_url_path("url_path")
|
||||||
|
if isinstance(value, str):
|
||||||
|
return value
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _existing_dashboard(items) -> bool:
|
||||||
|
"""Whether a dashboard under the stable url_path already exists."""
|
||||||
|
return any(_item_url_path(item) == DASHBOARD_URL_PATH for item in items)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_register_dashboard(hass: HomeAssistant) -> bool:
|
||||||
|
"""Register the NestQuest panel dashboard exactly once.
|
||||||
|
|
||||||
|
Returns True when a dashboard under the stable ``url_path`` exists
|
||||||
|
after the call (pre-existing or created here), False when the
|
||||||
|
Lovelace surfaces were unavailable or refused. A dashboard already
|
||||||
|
registered under the stable ``url_path`` — whether ours from a
|
||||||
|
previous setup or a user's own — skips BOTH steps and is left
|
||||||
|
COMPLETELY alone: its stored config is never overwritten, it is
|
||||||
|
never deleted, never a duplicate. The strategy config is saved
|
||||||
|
ONLY for the dashboard created in THIS call, whose fresh content
|
||||||
|
store is empty, so the save cannot clobber anything.
|
||||||
|
"""
|
||||||
|
collection = _dashboards_collection(hass)
|
||||||
|
if collection is None:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Lovelace dashboards collection unavailable; the NestQuest "
|
||||||
|
"panel dashboard was not registered. Enable the Lovelace "
|
||||||
|
"integration in storage mode or create a dashboard with "
|
||||||
|
"strategy %s manually.",
|
||||||
|
DASHBOARD_STRATEGY_TYPE,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
# Single-flight: two concurrent entry setups must not both pass
|
||||||
|
# the exists-check and race on the url_path create.
|
||||||
|
async with _registration_lock(hass):
|
||||||
|
# async_items() is a SYNC @callback on the real collection
|
||||||
|
# (helpers/collection.py ObservableCollection) — not awaited.
|
||||||
|
if _existing_dashboard(collection.async_items()):
|
||||||
|
return True
|
||||||
|
await collection.async_create_item(
|
||||||
|
{
|
||||||
|
"url_path": DASHBOARD_URL_PATH,
|
||||||
|
"title": DASHBOARD_TITLE,
|
||||||
|
"icon": DASHBOARD_ICON,
|
||||||
|
"show_in_sidebar": True,
|
||||||
|
"allow_single_word": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# Step two (mirroring HA's _create_map_dashboard): the
|
||||||
|
# strategy CONFIG goes through the fresh dashboard's
|
||||||
|
# content manager, not through the metadata collection.
|
||||||
|
store = _dashboard_store(hass, DASHBOARD_URL_PATH)
|
||||||
|
if store is None:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"The NestQuest panel dashboard was registered but its "
|
||||||
|
"Lovelace content manager never appeared; add the "
|
||||||
|
"strategy %s to the dashboard manually.",
|
||||||
|
DASHBOARD_STRATEGY_TYPE,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
await store.async_save(
|
||||||
|
{"strategy": {"type": DASHBOARD_STRATEGY_TYPE}}
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Registering the NestQuest panel dashboard in the Lovelace "
|
||||||
|
"dashboards collection failed; set it up manually with "
|
||||||
|
"strategy %s.",
|
||||||
|
DASHBOARD_STRATEGY_TYPE,
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"frontend",
|
"frontend",
|
||||||
"http"
|
"http",
|
||||||
|
"lovelace"
|
||||||
],
|
],
|
||||||
"documentation": "https://github.com/Maniacs-Mansion/NestQuest",
|
"documentation": "https://github.com/Maniacs-Mansion/NestQuest",
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ missed instances, and ``admin_instances`` includes them (D-009).
|
|||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
|
import unicodedata
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -41,13 +43,18 @@ from .coordinator import (
|
|||||||
)
|
)
|
||||||
from .core.snapshot import instance_payload
|
from .core.snapshot import instance_payload
|
||||||
|
|
||||||
#: Home Assistant's state machine refuses states longer than 255
|
#: HA's state machine refuses states longer than 255
|
||||||
#: characters (its hard recorder/state limit). These sensors' states
|
#: characters (its hard recorder/state limit). These sensors' states
|
||||||
#: are numeric, but the guard is applied uniformly: a payload-bearing
|
#: are numeric, but the guard is applied uniformly: a payload-bearing
|
||||||
#: sensor can never crash the state write, and later string-state
|
#: sensor can never crash the state write, and later string-state
|
||||||
#: sensors reuse the same helper.
|
#: sensors reuse the same helper.
|
||||||
MAX_STATE_LENGTH = 255
|
MAX_STATE_LENGTH = 255
|
||||||
|
|
||||||
|
#: Entity-id length cap the slug mirror applies: HA truncates the
|
||||||
|
#: entity_id (``sensor.`` + slug) at MAX_LENGTH_STATE_ENTITY_ID (64),
|
||||||
|
#: so the slugged object id alone may not exceed 64 - len("sensor.").
|
||||||
|
_MAX_SLUG_LENGTH = 64 - len("sensor.")
|
||||||
|
|
||||||
|
|
||||||
def _state_within_limit(state: Any) -> Any:
|
def _state_within_limit(state: Any) -> Any:
|
||||||
"""Return ``state`` unchanged, refusing strings over HA's limit.
|
"""Return ``state`` unchanged, refusing strings over HA's limit.
|
||||||
@@ -98,6 +105,56 @@ def _next_open_quest(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _slugify(text: str) -> str:
|
||||||
|
"""Slugify a display name the way Home Assistant derives entity ids.
|
||||||
|
|
||||||
|
Mirrors ``homeassistant.util.slugify`` (the unicode path HA runs
|
||||||
|
entity names through) for accented-Latin names: NFKD-normalize,
|
||||||
|
fold to ASCII (accents drop out with their combining marks),
|
||||||
|
lowercase, and turn every run of non-alphanumerics into one
|
||||||
|
underscore, capped at HA's entity-id length like the registry does.
|
||||||
|
The documented divergence from HA's vendored slugifier is unidecode:
|
||||||
|
HA transliterates any script to ASCII (so e.g. non-Latin names
|
||||||
|
survive), this mirror drops those characters instead, and a name
|
||||||
|
that then slugs to nothing falls through to HA's ``unknown``
|
||||||
|
sentinel — the same answer HA's wrapper gives. (The harness is
|
||||||
|
mock-only — no real HA to import the helper from — and entity ids
|
||||||
|
are registry identity, so the mirror is deliberate.)
|
||||||
|
"""
|
||||||
|
slug = unicodedata.normalize("NFKD", text)
|
||||||
|
slug = slug.encode("ascii", "ignore").decode("ascii")
|
||||||
|
slug = re.sub(r"[^a-z0-9]+", "_", slug.lower()).strip("_")
|
||||||
|
return (slug or "unknown")[:_MAX_SLUG_LENGTH]
|
||||||
|
|
||||||
|
|
||||||
|
def _child_roster(children: Iterable[ChildDaySnapshot]) -> list[dict[str, Any]]:
|
||||||
|
"""The ordered child roster the panel cards discover children from.
|
||||||
|
|
||||||
|
One entry per ACTIVE child in the snapshot's order (the API's
|
||||||
|
sort_order, then id): ``child_id``, ``name``, and the ``slug`` the
|
||||||
|
entity-id derivation produces for the child's name — the piece the
|
||||||
|
cards need to build ``sensor.nestquest_<slug>_...`` ids. Duplicate
|
||||||
|
display names get the registry's ``_2``/``_3`` suffix in snapshot
|
||||||
|
order, matching how HA resolves the collision at registration. The
|
||||||
|
rollups' ``children`` attribute (per-child counts) is unchanged and
|
||||||
|
carries a different shape on purpose.
|
||||||
|
"""
|
||||||
|
slugs: dict[str, int] = {}
|
||||||
|
roster: list[dict[str, Any]] = []
|
||||||
|
for child in children:
|
||||||
|
base = _slugify(child.child_name)
|
||||||
|
taken = slugs.get(base, 0) + 1
|
||||||
|
slugs[base] = taken
|
||||||
|
roster.append(
|
||||||
|
{
|
||||||
|
"child_id": child.child_id,
|
||||||
|
"name": child.child_name,
|
||||||
|
"slug": base if taken == 1 else f"{base}_{taken}",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return roster
|
||||||
|
|
||||||
|
|
||||||
class _NestQuestChildDaySensor(CoordinatorEntity, SensorEntity):
|
class _NestQuestChildDaySensor(CoordinatorEntity, SensorEntity):
|
||||||
"""Base for the per-child day sensors.
|
"""Base for the per-child day sensors.
|
||||||
|
|
||||||
@@ -356,7 +413,12 @@ class _NestQuestHouseholdSensor(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
|
|
||||||
class NestQuestHouseholdDueTodaySensor(_NestQuestHouseholdSensor):
|
class NestQuestHouseholdDueTodaySensor(_NestQuestHouseholdSensor):
|
||||||
"""Total quests due today across active children."""
|
"""Total quests due today across active children.
|
||||||
|
|
||||||
|
Also publishes ``child_roster`` (see :func:`_child_roster`): the
|
||||||
|
ordered child identity list the panel cards read to discover the
|
||||||
|
board's children when the card config carries no ``child_order``.
|
||||||
|
"""
|
||||||
|
|
||||||
_attr_name = "NestQuest household quests due today"
|
_attr_name = "NestQuest household quests due today"
|
||||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
@@ -380,7 +442,8 @@ class NestQuestHouseholdDueTodaySensor(_NestQuestHouseholdSensor):
|
|||||||
"children": {
|
"children": {
|
||||||
str(child.child_id): child.due_today
|
str(child.child_id): child.due_today
|
||||||
for child in data.children
|
for child in data.children
|
||||||
}
|
},
|
||||||
|
"child_roster": _child_roster(data.children),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Generated
+522
@@ -9,10 +9,197 @@
|
|||||||
"lit": "^3.3.0"
|
"lit": "^3.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"jsdom": "^30.1.1",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"vite": "^7.1.5"
|
"vite": "^7.1.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@asamuzakjp/css-color": {
|
||||||
|
"version": "7.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.0.1.tgz",
|
||||||
|
"integrity": "sha512-C9duntabagkBZ1LebM7FKmphR4Q1pBclLxVbZETQV0akkFjV0ooFxo8FlvAQyKj9F6l8rEnmidgcTlpyxFYizg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@csstools/css-calc": "^3.4.0",
|
||||||
|
"@csstools/css-color-parser": "^4.2.3",
|
||||||
|
"@csstools/css-parser-algorithms": "^4.0.0",
|
||||||
|
"@csstools/css-tokenizer": "^4.0.1",
|
||||||
|
"lru-cache": "^11.5.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@asamuzakjp/dom-selector": {
|
||||||
|
"version": "9.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-9.2.1.tgz",
|
||||||
|
"integrity": "sha512-NT4s3yZLjovPpliRpTvdsdzyPjqRqiCZj9MxnarBihbaY5MbAG7DWAJcrLlhmC7xKTNCXsTELcqB8YsqpLnUFQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"bidi-js": "^1.1.0",
|
||||||
|
"css-tree": "^3.2.1",
|
||||||
|
"is-potential-custom-element-name": "^1.0.1",
|
||||||
|
"lru-cache": "^11.5.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@bramus/specificity": {
|
||||||
|
"version": "2.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz",
|
||||||
|
"integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"css-tree": "^3.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"specificity": "bin/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/color-helpers": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-gLNsunvwf3mCi5u5o46/Z/JcJMnhbHSaZ69rkgPzNM3J4s8hWwpPUQB6/tt0EDFyCiWzxANlx+2LJwpYj4zS1w==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/css-calc": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-XQKj5B7QiZcHiegCOCAzcAOJdhGgWOHbbu62h5e5mkHnn8lWcfiJhllkqWmxu5zWR9jucPHuo1iTB56P033hcg==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@csstools/css-parser-algorithms": "^4.0.0",
|
||||||
|
"@csstools/css-tokenizer": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/css-color-parser": {
|
||||||
|
"version": "4.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.3.tgz",
|
||||||
|
"integrity": "sha512-y4LpL+lmpuyKDiEFq2PnZUVFdAjsoB/qQJod79yLNokXyW7jewi+/WJ69EfItj8A2unWtxXnGjw6LYXgXu5ZjA==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@csstools/color-helpers": "^6.1.1",
|
||||||
|
"@csstools/css-calc": "^3.4.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@csstools/css-parser-algorithms": "^4.0.0",
|
||||||
|
"@csstools/css-tokenizer": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/css-parser-algorithms": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@csstools/css-tokenizer": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/css-syntax-patches-for-csstree": {
|
||||||
|
"version": "1.1.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.14.tgz",
|
||||||
|
"integrity": "sha512-HpbVXyrofRXpHpgkNIjU/3EWR4WJvOkO3emNK/L6X/mTJU7bGUI3AkkpoTNXznQLp0KRjLHELTGeKI5dIkI9JQ==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT-0",
|
||||||
|
"peerDependencies": {
|
||||||
|
"css-tree": "^3.2.1"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"css-tree": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@csstools/css-tokenizer": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-bPlN9S9O1A0euCpEWE4qnvB5YDuyYVsUTrxSgmAM1Is0j4tICHoVyOVAXfWMP/kS9ZrjvyIXWV2PmomiAXXqOw==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/csstools"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/csstools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@esbuild/aix-ppc64": {
|
"node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.28.2",
|
"version": "0.28.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
|
||||||
@@ -455,6 +642,24 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@exodus/bytes": {
|
||||||
|
"version": "1.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz",
|
||||||
|
"integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@noble/hashes": "^1.8.0 || ^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@noble/hashes": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@lit-labs/ssr-dom-shim": {
|
"node_modules/@lit-labs/ssr-dom-shim": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.6.0.tgz",
|
||||||
@@ -892,6 +1097,79 @@
|
|||||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/bidi-js": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"require-from-string": "^2.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/css-tree": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mdn-data": "2.27.1",
|
||||||
|
"source-map-js": "^1.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/data-urls": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-mimetype": "^5.0.0",
|
||||||
|
"whatwg-url": "^16.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/data-urls/node_modules/whatwg-url": {
|
||||||
|
"version": "16.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-16.0.1.tgz",
|
||||||
|
"integrity": "sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.11.0",
|
||||||
|
"tr46": "^6.0.0",
|
||||||
|
"webidl-conversions": "^8.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/decimal.js": {
|
||||||
|
"version": "10.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
|
||||||
|
"integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/entities": {
|
||||||
|
"version": "8.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz",
|
||||||
|
"integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.19.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esbuild": {
|
"node_modules/esbuild": {
|
||||||
"version": "0.28.2",
|
"version": "0.28.2",
|
||||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
|
||||||
@@ -967,6 +1245,66 @@
|
|||||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/html-encoding-sniffer": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.15.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.13.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-potential-custom-element-name": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/jsdom": {
|
||||||
|
"version": "30.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.1.tgz",
|
||||||
|
"integrity": "sha512-FahmoPK5vbPc+jxV1iErMHmAZypCZ942NHF4+qqaWAuvaKKTBZxawnmAtrbGWLU7MtlxfqIP0qw6aSI+aWGtLg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@asamuzakjp/css-color": "^7.0.0",
|
||||||
|
"@asamuzakjp/dom-selector": "^9.2.1",
|
||||||
|
"@bramus/specificity": "^2.4.2",
|
||||||
|
"@csstools/css-syntax-patches-for-csstree": "^1.1.13",
|
||||||
|
"@exodus/bytes": "^1.15.1",
|
||||||
|
"css-tree": "^3.2.1",
|
||||||
|
"data-urls": "^7.0.0",
|
||||||
|
"decimal.js": "^10.6.0",
|
||||||
|
"html-encoding-sniffer": "^7.0.0",
|
||||||
|
"is-potential-custom-element-name": "^1.0.1",
|
||||||
|
"lru-cache": "^11.5.2",
|
||||||
|
"parse5": "^8.0.1",
|
||||||
|
"saxes": "^6.0.0",
|
||||||
|
"tough-cookie": "^6.0.2",
|
||||||
|
"undici": "^8.10.2",
|
||||||
|
"w3c-xmlserializer": "^6.0.0",
|
||||||
|
"webidl-conversions": "^8.0.1",
|
||||||
|
"whatwg-mimetype": "^5.0.0",
|
||||||
|
"whatwg-url": "^17.1.1",
|
||||||
|
"xml-name-validator": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"canvas": "^3.2.3"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"canvas": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/lit": {
|
"node_modules/lit": {
|
||||||
"version": "3.3.3",
|
"version": "3.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/lit/-/lit-3.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/lit/-/lit-3.3.3.tgz",
|
||||||
@@ -998,6 +1336,23 @@
|
|||||||
"@types/trusted-types": "^2.0.2"
|
"@types/trusted-types": "^2.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/lru-cache": {
|
||||||
|
"version": "11.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz",
|
||||||
|
"integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdn-data": {
|
||||||
|
"version": "2.27.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz",
|
||||||
|
"integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "CC0-1.0"
|
||||||
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.3.19",
|
"version": "3.3.19",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
|
||||||
@@ -1017,6 +1372,19 @@
|
|||||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/parse5": {
|
||||||
|
"version": "8.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz",
|
||||||
|
"integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"entities": "^8.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
@@ -1066,6 +1434,26 @@
|
|||||||
"node": "^10 || ^12 || >=14"
|
"node": "^10 || ^12 || >=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/punycode": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/require-from-string": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "4.63.4",
|
"version": "4.63.4",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.4.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.4.tgz",
|
||||||
@@ -1112,6 +1500,19 @@
|
|||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/saxes": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"xmlchars": "^2.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=v12.22.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
@@ -1139,6 +1540,52 @@
|
|||||||
"url": "https://github.com/sponsors/SuperchupuDev"
|
"url": "https://github.com/sponsors/SuperchupuDev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tldts": {
|
||||||
|
"version": "7.4.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.14.tgz",
|
||||||
|
"integrity": "sha512-EahQoi+Q5oqmG3yxRHx+bwn36OaLbtw6jnTFcGjc8fcmktzTgk45xRnzAx8Ch87PFEiqRhoc3FWBmY+LBrvEGQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts-core": "^7.4.14"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"tldts": "bin/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tldts-core": {
|
||||||
|
"version": "7.4.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.14.tgz",
|
||||||
|
"integrity": "sha512-KYkjfJHnIC5t+Gy7hPrMHgJmWc/N9FfmS+fggRPSlpFckidpB9HD6OzPsSTkfDH+MpZgcu2tJPGgLfHl979N1Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/tough-cookie": {
|
||||||
|
"version": "6.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",
|
||||||
|
"integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts": "^7.0.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tr46": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"punycode": "^2.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.9.3",
|
"version": "5.9.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
@@ -1153,6 +1600,16 @@
|
|||||||
"node": ">=14.17"
|
"node": ">=14.17"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/undici": {
|
||||||
|
"version": "8.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici/-/undici-8.11.0.tgz",
|
||||||
|
"integrity": "sha512-AdzuGcAkzhbha3GgCSoUBx2P0quwym6qdFNCQz/fDGZc8w9XJ741wHUbt2kTmfPz+ZIOMkySFkiY7RXmiDDC8w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.19.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "7.3.6",
|
"version": "7.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz",
|
||||||
@@ -1227,6 +1684,71 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/w3c-xmlserializer": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"xml-name-validator": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "8.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",
|
||||||
|
"integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-mimetype": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "17.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.1.2.tgz",
|
||||||
|
"integrity": "sha512-TEZA+Zqxin7Jjsm2cjRohCmen5awh+hT6Zi3VZdqZlNRk7zvOI/9WpBFg/DWlA56bWnzwm6DuB8NS0EsxQH9uQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@exodus/bytes": "^1.15.1",
|
||||||
|
"tr46": "^6.0.0",
|
||||||
|
"webidl-conversions": "^8.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.14.0 || >=24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/xml-name-validator": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/xmlchars": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"lit": "^3.3.0"
|
"lit": "^3.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"jsdom": "^30.1.1",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"vite": "^7.1.5"
|
"vite": "^7.1.5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ function asNumber(value: unknown, fallback: number): number {
|
|||||||
return Number.isFinite(parsed) ? parsed : fallback;
|
return Number.isFinite(parsed) ? parsed : fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The slug a discovered roster entry carries, or "" when the entry is
|
||||||
|
* not an object with a non-empty slug string. */
|
||||||
|
function asRosterSlug(entry: unknown): string {
|
||||||
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const slug = (entry as Record<string, unknown>).slug;
|
||||||
|
return typeof slug === "string" ? slug.trim() : "";
|
||||||
|
}
|
||||||
|
|
||||||
function clampPercent(value: number): number {
|
function clampPercent(value: number): number {
|
||||||
if (!Number.isFinite(value)) {
|
if (!Number.isFinite(value)) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -892,15 +902,34 @@ export class NestQuestPartyBoardCard extends LitElement {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const order = this._config.child_order;
|
const order = this._config.child_order;
|
||||||
if (!Array.isArray(order)) {
|
if (Array.isArray(order)) {
|
||||||
|
return order
|
||||||
|
.filter(
|
||||||
|
(entry): entry is string =>
|
||||||
|
typeof entry === "string" && entry.trim().length > 0
|
||||||
|
)
|
||||||
|
.map((entry) => entry.trim());
|
||||||
|
}
|
||||||
|
return this._discoveredChildSlugs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zero-config discovery (Feature 20): the ordered child roster the
|
||||||
|
* integration publishes on the household rollup
|
||||||
|
* (custom_components/nestquest/sensor.py — ``child_roster``, the
|
||||||
|
* snapshot's sort_order, then id), each entry carrying the slug the
|
||||||
|
* per-child entity ids are built from. Consulted only when the
|
||||||
|
* config has no child_order — explicit configuration wins. */
|
||||||
|
private _discoveredChildSlugs(): string[] {
|
||||||
|
const household = this._state(
|
||||||
|
"sensor.nestquest_household_quests_due_today"
|
||||||
|
);
|
||||||
|
const roster = household?.attributes?.child_roster;
|
||||||
|
if (!Array.isArray(roster)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return order
|
return roster
|
||||||
.filter(
|
.map((entry) => asRosterSlug(entry))
|
||||||
(entry): entry is string =>
|
.filter((slug) => slug.length > 0);
|
||||||
typeof entry === "string" && entry.trim().length > 0
|
|
||||||
)
|
|
||||||
.map((entry) => entry.trim());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _plates(): ChildPlate[] {
|
private _plates(): ChildPlate[] {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import "./cards/party-board";
|
import "./cards/party-board";
|
||||||
import "./cards/quest-log";
|
import "./cards/quest-log";
|
||||||
import "./cards/admin";
|
import "./cards/admin";
|
||||||
|
import "./strategy";
|
||||||
|
|
||||||
const FONTS_HREF = "/nestquest-static/nestquest-fonts.css";
|
const FONTS_HREF = "/nestquest-static/nestquest-fonts.css";
|
||||||
if (!document.querySelector('link[data-nq-fonts=""]')) {
|
if (!document.querySelector('link[data-nq-fonts=""]')) {
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
import type { HassLike } from "./types";
|
||||||
|
|
||||||
|
type StateObject = {
|
||||||
|
state: unknown;
|
||||||
|
attributes?: Record<string, unknown> | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type RosterEntry = {
|
||||||
|
name: string;
|
||||||
|
slug: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type View = {
|
||||||
|
path?: string;
|
||||||
|
title?: string;
|
||||||
|
type: string;
|
||||||
|
cards: Record<string, unknown>[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type LovelaceConfig = {
|
||||||
|
views: View[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type StrategyConfig = Record<string, unknown>;
|
||||||
|
|
||||||
|
type StrategyClass = {
|
||||||
|
generate: (
|
||||||
|
config: StrategyConfig,
|
||||||
|
hass: HassLike | undefined
|
||||||
|
) => Promise<LovelaceConfig>;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
customStrategies?: Record<string, StrategyClass>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function asString(value: unknown): string {
|
||||||
|
return typeof value === "string" ? value.trim() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The slug a discovered roster entry carries, or "" when the entry is
|
||||||
|
* not an object with a non-empty slug string — the same shape check
|
||||||
|
* the party board applies to the same attribute. */
|
||||||
|
function asRosterSlug(entry: unknown): string {
|
||||||
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const slug = (entry as Record<string, unknown>).slug;
|
||||||
|
return typeof slug === "string" ? slug.trim() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The dashboard's URL path segment, used to COMPUTE the card paths the
|
||||||
|
* navigation needs. A dashboard lives at a single top-level segment
|
||||||
|
* (/<url_path>), so the first pathname segment is the dashboard root —
|
||||||
|
* this is where the strategy renders, and navigating back to it shows
|
||||||
|
* the first view (the party board). An explicit ``url_path`` in the
|
||||||
|
* strategy configuration wins for setups that need to pin it. */
|
||||||
|
function dashboardUrlPath(config: StrategyConfig): string {
|
||||||
|
const configured = asString(config.url_path).replace(/^\/+|\/+$/g, "");
|
||||||
|
if (configured) {
|
||||||
|
return configured;
|
||||||
|
}
|
||||||
|
const segment = window.location.pathname.split("/").filter(Boolean)[0];
|
||||||
|
return segment ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The display name a roster entry carries, or "" when it is not a
|
||||||
|
* non-empty string — the roster's ``name`` field (sensor.py
|
||||||
|
* ``_child_roster``), used for the quest-log view titles. */
|
||||||
|
function asRosterName(entry: unknown): string {
|
||||||
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const name = (entry as Record<string, unknown>).name;
|
||||||
|
return typeof name === "string" ? name.trim() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The ordered child roster the integration publishes on the household
|
||||||
|
* rollup (custom_components/nestquest/sensor.py — ``child_roster``,
|
||||||
|
* the snapshot's sort_order, then id). The same source the party
|
||||||
|
* board's plate discovery reads, consumed here at render time so the
|
||||||
|
* quest-log views exist for exactly the active children. */
|
||||||
|
function rosterEntries(hass: HassLike | undefined): RosterEntry[] {
|
||||||
|
const states = hass?.states as Record<string, StateObject> | undefined;
|
||||||
|
const household = states?.["sensor.nestquest_household_quests_due_today"];
|
||||||
|
const roster = household?.attributes?.child_roster;
|
||||||
|
if (!Array.isArray(roster)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return roster
|
||||||
|
.map((entry) => ({ slug: asRosterSlug(entry), name: asRosterName(entry) }))
|
||||||
|
.filter((entry) => entry.slug.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zero-config NestQuest dashboard strategy (Feature 20).
|
||||||
|
*
|
||||||
|
* A dashboard configured with ``strategy: { type: custom:nestquest-party }``
|
||||||
|
* gets its views GENERATED at render time from the household roster: one
|
||||||
|
* party-board view (the dashboard root) and one quest-log view per child,
|
||||||
|
* ordered by the roster's sort_order. The paths the cards navigate by are
|
||||||
|
* COMPUTED, not configured:
|
||||||
|
*
|
||||||
|
* - the board's ``quest_log_path`` is the dashboard root; tapping a crest
|
||||||
|
* pushes ``<root>/<slug>`` (party-board.ts ``_openQuestLog``);
|
||||||
|
* - each log view's ``path`` IS the child's slug, so the log resolves its
|
||||||
|
* child from the last pathname segment (quest-log.ts
|
||||||
|
* ``childSlugFromPath``) and its ``board_path`` back to the dashboard
|
||||||
|
* root (quest-log.ts ``_returnToBoard``).
|
||||||
|
*
|
||||||
|
* With zero children the board view still renders — the board card shows
|
||||||
|
* its own "not set up yet" notice for an empty roster, so no log views are
|
||||||
|
* needed. ``url_path`` and ``weather_entity`` may still be set explicitly
|
||||||
|
* in the strategy configuration; everything else is derived.
|
||||||
|
*/
|
||||||
|
export class NestQuestPartyStrategy {
|
||||||
|
static async generate(
|
||||||
|
config: StrategyConfig,
|
||||||
|
hass: HassLike | undefined
|
||||||
|
): Promise<LovelaceConfig> {
|
||||||
|
const root = `/${dashboardUrlPath(config)}`;
|
||||||
|
const weatherEntity = asString(config.weather_entity);
|
||||||
|
const boardCard: Record<string, unknown> = {
|
||||||
|
type: "custom:nestquest-party-board-card",
|
||||||
|
quest_log_path: root,
|
||||||
|
};
|
||||||
|
if (weatherEntity) {
|
||||||
|
boardCard.weather_entity = weatherEntity;
|
||||||
|
}
|
||||||
|
const logCard: Record<string, unknown> = {
|
||||||
|
type: "custom:nestquest-quest-log-card",
|
||||||
|
board_path: root,
|
||||||
|
};
|
||||||
|
if (weatherEntity) {
|
||||||
|
logCard.weather_entity = weatherEntity;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
views: [
|
||||||
|
{
|
||||||
|
path: "party",
|
||||||
|
title: "The Party",
|
||||||
|
type: "panel",
|
||||||
|
cards: [boardCard],
|
||||||
|
},
|
||||||
|
...rosterEntries(hass).map<View>((entry) => ({
|
||||||
|
path: entry.slug,
|
||||||
|
title: entry.name
|
||||||
|
? `${entry.name}'s Quest Log`
|
||||||
|
: `${entry.slug}'s Quest Log`,
|
||||||
|
type: "panel",
|
||||||
|
cards: [{ ...logCard }],
|
||||||
|
})),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.customStrategies = window.customStrategies ?? {};
|
||||||
|
window.customStrategies["nestquest-party"] = NestQuestPartyStrategy;
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* Render the built party-board card under jsdom and print its plates.
|
||||||
|
*
|
||||||
|
* Usage: node render-party-board.mjs < spec.json
|
||||||
|
*
|
||||||
|
* The spec JSON carries {bundle, tag, config, hass}; stdout receives one JSON
|
||||||
|
* object {plates, html} where plates is the ordered plate list the shadow DOM
|
||||||
|
* renders (name + present/away/unknown kind). The Python panel tests drive
|
||||||
|
* this harness so the assertions run against the exact bundle HACS ships.
|
||||||
|
*/
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { pathToFileURL } from "node:url";
|
||||||
|
import { JSDOM } from "jsdom";
|
||||||
|
|
||||||
|
const spec = JSON.parse(readFileSync(0, "utf8"));
|
||||||
|
|
||||||
|
const dom = new JSDOM("<!doctype html><html><body></body></html>", {
|
||||||
|
url: "http://homeassistant.local/nestquest/board",
|
||||||
|
pretendToBeVisual: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Expose the jsdom globals the Lit bundle expects. Node's own intrinsics
|
||||||
|
// (Object, Array, ...) are kept — only what globalThis lacks is copied.
|
||||||
|
for (const key of Object.getOwnPropertyNames(dom.window)) {
|
||||||
|
if (!(key in globalThis)) {
|
||||||
|
try {
|
||||||
|
globalThis[key] = dom.window[key];
|
||||||
|
} catch {
|
||||||
|
// jsdom getters may throw on access; the card does not need them.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globalThis.window = dom.window;
|
||||||
|
|
||||||
|
await import(pathToFileURL(spec.bundle).href);
|
||||||
|
|
||||||
|
const element = document.createElement(spec.tag);
|
||||||
|
element.setConfig(spec.config);
|
||||||
|
element.hass = spec.hass;
|
||||||
|
document.body.appendChild(element);
|
||||||
|
await element.updateComplete;
|
||||||
|
|
||||||
|
const plates = [
|
||||||
|
...element.shadowRoot.querySelectorAll(".plates .plate"),
|
||||||
|
].map((plate) => ({
|
||||||
|
name: plate.querySelector(".name")?.textContent?.trim() ?? "",
|
||||||
|
kind: plate.classList.contains("unknown")
|
||||||
|
? "unknown"
|
||||||
|
: plate.classList.contains("away")
|
||||||
|
? "away"
|
||||||
|
: "present",
|
||||||
|
}));
|
||||||
|
|
||||||
|
const payload = JSON.stringify({ plates, html: element.shadowRoot.innerHTML });
|
||||||
|
await new Promise((resolve) => process.stdout.write(payload, () => resolve()));
|
||||||
|
process.exit(0);
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Import the built bundle into jsdom and generate the dashboard strategy's
|
||||||
|
* views.
|
||||||
|
*
|
||||||
|
* Usage: node render-strategy.mjs < spec.json
|
||||||
|
*
|
||||||
|
* The spec JSON carries {bundle, url, config, hass}; stdout receives one
|
||||||
|
* JSON object {views} — the strategy output's views array with the paths
|
||||||
|
* and card configs the generated dashboard renders. The Python panel
|
||||||
|
* tests drive this harness so the assertions run against the exact bundle
|
||||||
|
* HACS ships.
|
||||||
|
*/
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { pathToFileURL } from "node:url";
|
||||||
|
import { JSDOM } from "jsdom";
|
||||||
|
|
||||||
|
const spec = JSON.parse(readFileSync(0, "utf8"));
|
||||||
|
|
||||||
|
const dom = new JSDOM("<!doctype html><html><body></body></html>", {
|
||||||
|
url: spec.url ?? "http://homeassistant.local/nestquest/party",
|
||||||
|
pretendToBeVisual: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Expose the jsdom globals the Lit bundle expects. Node's own intrinsics
|
||||||
|
// (Object, Array, ...) are kept — only what globalThis lacks is copied.
|
||||||
|
for (const key of Object.getOwnPropertyNames(dom.window)) {
|
||||||
|
if (!(key in globalThis)) {
|
||||||
|
try {
|
||||||
|
globalThis[key] = dom.window[key];
|
||||||
|
} catch {
|
||||||
|
// jsdom getters may throw on access; the strategy does not need them.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globalThis.window = dom.window;
|
||||||
|
|
||||||
|
await import(pathToFileURL(spec.bundle).href);
|
||||||
|
|
||||||
|
const strategy = window.customStrategies?.["nestquest-party"];
|
||||||
|
if (!strategy) {
|
||||||
|
console.error("nestquest-party strategy is not registered on the bundle");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const lovelace = await strategy.generate(spec.config, spec.hass);
|
||||||
|
const payload = JSON.stringify({ views: lovelace.views });
|
||||||
|
await new Promise((resolve) => process.stdout.write(payload, () => resolve()));
|
||||||
|
process.exit(0);
|
||||||
@@ -12,12 +12,100 @@ from custom_components.nestquest.const import (
|
|||||||
DOMAIN as DOMAIN_CONST,
|
DOMAIN as DOMAIN_CONST,
|
||||||
SERVICE_COMPLETE_QUEST,
|
SERVICE_COMPLETE_QUEST,
|
||||||
)
|
)
|
||||||
|
from custom_components.nestquest.dashboard import (
|
||||||
|
DASHBOARD_STRATEGY_TYPE,
|
||||||
|
DASHBOARD_URL_PATH,
|
||||||
|
async_register_dashboard,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _wire(entry, registry):
|
def _wire(entry, registry):
|
||||||
return wire_entry_to_registry(entry, registry)
|
return wire_entry_to_registry(entry, registry)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeDashboardStore:
|
||||||
|
"""Stand-in for a per-dashboard CONTENT manager (LovelaceStorage).
|
||||||
|
|
||||||
|
In the real API the dashboard CONFIG (the strategy reference) is
|
||||||
|
saved through THIS manager's ``async_save``, NOT through the
|
||||||
|
metadata collection — so every strategy-save assertion reads here.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.saved: list[dict] = []
|
||||||
|
self.config: dict | None = None
|
||||||
|
|
||||||
|
async def async_save(self, config: dict) -> None:
|
||||||
|
self.saved.append(dict(config))
|
||||||
|
self.config = dict(config)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeDashboardsCollection:
|
||||||
|
"""Stand-in mirroring the REAL Lovelace dashboards API shapes.
|
||||||
|
|
||||||
|
Faithful to ``homeassistant/components/lovelace`` +
|
||||||
|
``helpers/collection.py``: ``async_items()`` is a SYNC ``@callback``
|
||||||
|
(ObservableCollection.async_items returns list(data.values())),
|
||||||
|
``async_create_item`` IS async, and — mirroring lovelace's
|
||||||
|
``storage_dashboard_changed`` listener — a successful create
|
||||||
|
registers a fresh CONTENT manager under
|
||||||
|
``hass.data["lovelace"]["dashboards"][url_path]``, which is where
|
||||||
|
the dashboard config is then saved. Records ``async_create_item``
|
||||||
|
calls so tests can assert exactly what the setup path registered —
|
||||||
|
and that a reload registers nothing more.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, hass, items=None) -> None:
|
||||||
|
self.hass = hass
|
||||||
|
self.items = list(items or [])
|
||||||
|
self.created: list[dict] = []
|
||||||
|
#: url_path -> content manager, mirroring the real listener's
|
||||||
|
# registrations (pre-existing items included).
|
||||||
|
self.stores: dict[str, FakeDashboardStore] = {}
|
||||||
|
|
||||||
|
def async_items(self):
|
||||||
|
"""SYNC, like the real ``ObservableCollection.async_items``."""
|
||||||
|
return list(self.items)
|
||||||
|
|
||||||
|
async def async_create_item(self, item_config: dict) -> None:
|
||||||
|
# The real collection awaits validation and change notification
|
||||||
|
# around the item insertion; yield first so two concurrent
|
||||||
|
# callers without a single-flight guard would BOTH get here.
|
||||||
|
await asyncio.sleep(0)
|
||||||
|
self.created.append(dict(item_config))
|
||||||
|
self.items.append(dict(item_config))
|
||||||
|
self.stores[item_config["url_path"]] = FakeDashboardStore()
|
||||||
|
self.hass.data["lovelace"]["dashboards"][item_config["url_path"]] = (
|
||||||
|
self.stores[item_config["url_path"]]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _install_dashboard_collection(
|
||||||
|
hass, items=None
|
||||||
|
) -> FakeDashboardsCollection:
|
||||||
|
"""Install the REAL-API-shaped lovelace surfaces on the hass stub.
|
||||||
|
|
||||||
|
Mirrors what lovelace's ``async_setup`` leaves behind in storage
|
||||||
|
mode: ``hass.data["lovelace"]`` is a DICT with the metadata
|
||||||
|
collection under ``dashboards_collection`` and the per-url_path
|
||||||
|
CONTENT managers under ``dashboards``. Any pre-existing item gets
|
||||||
|
a content manager, exactly as lovelace's change listener would
|
||||||
|
have registered one when the dashboard was created.
|
||||||
|
"""
|
||||||
|
collection = FakeDashboardsCollection(hass, items)
|
||||||
|
hass.data["lovelace"] = {
|
||||||
|
"mode": "storage",
|
||||||
|
"dashboards": {},
|
||||||
|
"dashboards_collection": collection,
|
||||||
|
}
|
||||||
|
for item in collection.items:
|
||||||
|
url_path = item.get("url_path")
|
||||||
|
store = FakeDashboardStore()
|
||||||
|
collection.stores[url_path] = store
|
||||||
|
hass.data["lovelace"]["dashboards"][url_path] = store
|
||||||
|
return collection
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_stores_runtime_data_in_hass_data(hass, make_entry) -> None:
|
async def test_setup_stores_runtime_data_in_hass_data(hass, make_entry) -> None:
|
||||||
entry = _wire(make_entry(), hass.registry)
|
entry = _wire(make_entry(), hass.registry)
|
||||||
assert await async_setup_entry(hass, entry) is True
|
assert await async_setup_entry(hass, entry) is True
|
||||||
@@ -271,3 +359,161 @@ async def test_unload_shuts_coordinator_even_when_listener_removal_raises() -> N
|
|||||||
assert entry.runtime_data is None
|
assert entry.runtime_data is None
|
||||||
assert DOMAIN_CONST not in hass.data
|
assert DOMAIN_CONST not in hass.data
|
||||||
assert hass.time_change.size == 0
|
assert hass.time_change.size == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_creates_the_panel_dashboard(hass, make_entry) -> None:
|
||||||
|
"""A fresh install gets the storage-mode strategy dashboard via the
|
||||||
|
REAL two-step Lovelace sequence: the METADATA (url_path, title,
|
||||||
|
icon, sidebar, single-word allowance — nothing else: the real
|
||||||
|
create schema rejects unknown keys like ``strategy``) through the
|
||||||
|
collection, then the dashboard CONFIG (the strategy reference)
|
||||||
|
through the fresh dashboard's content manager."""
|
||||||
|
collection = _install_dashboard_collection(hass)
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
# Step 1: the metadata create through the collection.
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
created = collection.created[0]
|
||||||
|
assert created["url_path"] == DASHBOARD_URL_PATH
|
||||||
|
assert created["title"]
|
||||||
|
assert created["show_in_sidebar"] is True
|
||||||
|
assert created["allow_single_word"] is True
|
||||||
|
assert "icon" in created
|
||||||
|
# The create payload carries METADATA only: a ``strategy`` key is
|
||||||
|
# rejected by the real collection's create schema (the silent
|
||||||
|
# no-op the first implementation shipped).
|
||||||
|
assert "strategy" not in created
|
||||||
|
assert "mode" not in created
|
||||||
|
# Step 2: the strategy CONFIG saved through the content manager
|
||||||
|
# the create registered, with the custom strategy type.
|
||||||
|
store = hass.data["lovelace"]["dashboards"][DASHBOARD_URL_PATH]
|
||||||
|
assert store is collection.stores[DASHBOARD_URL_PATH]
|
||||||
|
assert store.saved == [{"strategy": {"type": DASHBOARD_STRATEGY_TYPE}}]
|
||||||
|
assert store.config == {"strategy": {"type": DASHBOARD_STRATEGY_TYPE}}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_reload_does_not_duplicate_the_dashboard(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""A reload (or a second entry) must not create a second dashboard:
|
||||||
|
the one under the stable url_path is reused as-is — BOTH steps are
|
||||||
|
skipped, so the strategy config is not re-saved either."""
|
||||||
|
collection = _install_dashboard_collection(hass)
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
store = hass.data["lovelace"]["dashboards"][DASHBOARD_URL_PATH]
|
||||||
|
assert len(store.saved) == 1
|
||||||
|
# A reload: setup again on the same hass (the reload cycle) —
|
||||||
|
# the existing dashboard must be left alone.
|
||||||
|
await async_unload_entry(hass, entry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
assert len(store.saved) == 1
|
||||||
|
# And a second entry on the same install.
|
||||||
|
other = _wire(make_entry(entry_id="other"), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, other) is True
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
assert len(store.saved) == 1
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_leaves_an_existing_user_dashboard_alone(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""A dashboard already occupying the stable url_path — the user's
|
||||||
|
own — is never overwritten, deleted or duplicated: no metadata
|
||||||
|
create AND no strategy save against its content manager."""
|
||||||
|
users_dashboard = {"url_path": DASHBOARD_URL_PATH, "title": "My Board"}
|
||||||
|
collection = _install_dashboard_collection(hass, items=[users_dashboard])
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert collection.created == []
|
||||||
|
assert collection.items[0] is users_dashboard
|
||||||
|
users_store = hass.data["lovelace"]["dashboards"][DASHBOARD_URL_PATH]
|
||||||
|
assert users_store.saved == []
|
||||||
|
assert users_store.config is None
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_succeeds_without_the_dashboards_collection(
|
||||||
|
hass, make_entry, caplog
|
||||||
|
) -> None:
|
||||||
|
"""YAML mode / lovelace not loaded: log a warning, continue setup."""
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert entry.entry_id in hass.data[DOMAIN]
|
||||||
|
assert any(
|
||||||
|
"dashboard" in record.message.lower()
|
||||||
|
and record.levelname == "WARNING"
|
||||||
|
for record in caplog.records
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_survives_a_failing_dashboards_collection(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""A collection that refuses the create (permissions, admin-only)
|
||||||
|
logs a warning and setup still succeeds — entities come up."""
|
||||||
|
class _RefusingCollection(FakeDashboardsCollection):
|
||||||
|
async def async_create_item(self, item_config):
|
||||||
|
raise PermissionError("not an admin")
|
||||||
|
|
||||||
|
collection = _RefusingCollection(hass)
|
||||||
|
hass.data["lovelace"] = {
|
||||||
|
"mode": "storage",
|
||||||
|
"dashboards": {},
|
||||||
|
"dashboards_collection": collection,
|
||||||
|
}
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert collection.created == []
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_survives_a_failing_content_manager_save(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""A content manager that refuses the config save after the
|
||||||
|
metadata create succeeded (storage write failure) logs a warning
|
||||||
|
and setup still succeeds — the dashboard exists, the strategy
|
||||||
|
simply was not persisted through it."""
|
||||||
|
class _RefusingStore(FakeDashboardStore):
|
||||||
|
async def async_save(self, config):
|
||||||
|
raise OSError("disk full")
|
||||||
|
|
||||||
|
class _StorelessCreateCollection(FakeDashboardsCollection):
|
||||||
|
async def async_create_item(self, item_config):
|
||||||
|
await asyncio.sleep(0)
|
||||||
|
self.created.append(dict(item_config))
|
||||||
|
self.items.append(dict(item_config))
|
||||||
|
self.stores[item_config["url_path"]] = _RefusingStore()
|
||||||
|
self.hass.data["lovelace"]["dashboards"][
|
||||||
|
item_config["url_path"]
|
||||||
|
] = self.stores[item_config["url_path"]]
|
||||||
|
|
||||||
|
collection = _StorelessCreateCollection(hass)
|
||||||
|
hass.data["lovelace"] = {
|
||||||
|
"mode": "storage",
|
||||||
|
"dashboards": {},
|
||||||
|
"dashboards_collection": collection,
|
||||||
|
}
|
||||||
|
entry = _wire(make_entry(), hass.registry)
|
||||||
|
assert await async_setup_entry(hass, entry) is True
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
store = hass.data["lovelace"]["dashboards"][DASHBOARD_URL_PATH]
|
||||||
|
assert store.saved == []
|
||||||
|
|
||||||
|
|
||||||
|
async def test_concurrent_registrations_create_the_dashboard_once(hass) -> None:
|
||||||
|
"""Two CONCURRENT registrations (the race two entry setups run)
|
||||||
|
must produce exactly ONE dashboard: the single-flight guard makes
|
||||||
|
the second caller's exists-check run after the first caller's
|
||||||
|
create completed, so it skips both steps. The fake's create
|
||||||
|
yields before recording, so without the guard both callers would
|
||||||
|
pass the exists-check and the dashboard would be created twice."""
|
||||||
|
collection = _install_dashboard_collection(hass)
|
||||||
|
results = await asyncio.gather(
|
||||||
|
async_register_dashboard(hass),
|
||||||
|
async_register_dashboard(hass),
|
||||||
|
)
|
||||||
|
assert results == [True, True]
|
||||||
|
assert len(collection.created) == 1
|
||||||
|
assert len(collection.stores[DASHBOARD_URL_PATH].saved) == 1
|
||||||
|
|||||||
+290
-2
@@ -5,16 +5,27 @@ the contract by reading the card sources and the built bundle, in the same
|
|||||||
spirit as test_frontend.py. They cover the states decided in
|
spirit as test_frontend.py. They cover the states decided in
|
||||||
design/PANEL-EMPTY-STATES.md and PANEL-SPEC.md, and guard the kid-facing
|
design/PANEL-EMPTY-STATES.md and PANEL-SPEC.md, and guard the kid-facing
|
||||||
bundles against ever gaining a parent-only service call.
|
bundles against ever gaining a parent-only service call.
|
||||||
|
|
||||||
|
The party board additionally has render tests: they drive
|
||||||
|
frontend/tests/render-party-board.mjs, which imports the built bundle into a
|
||||||
|
jsdom window and reports the ordered plates the shadow DOM renders, so the
|
||||||
|
zero-config discovery contract is asserted against the bundle HACS ships.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).parent.parent
|
REPO_ROOT = Path(__file__).parent.parent
|
||||||
FRONTEND_CARDS_DIR = REPO_ROOT / "frontend" / "src" / "cards"
|
FRONTEND_DIR = REPO_ROOT / "frontend"
|
||||||
|
FRONTEND_CARDS_DIR = FRONTEND_DIR / "src" / "cards"
|
||||||
PARTY_BOARD = FRONTEND_CARDS_DIR / "party-board.ts"
|
PARTY_BOARD = FRONTEND_CARDS_DIR / "party-board.ts"
|
||||||
QUEST_LOG = FRONTEND_CARDS_DIR / "quest-log.ts"
|
QUEST_LOG = FRONTEND_CARDS_DIR / "quest-log.ts"
|
||||||
BUNDLE_PATH = REPO_ROOT / "custom_components" / "nestquest" / "www" / "nestquest-cards.js"
|
BUNDLE_PATH = REPO_ROOT / "custom_components" / "nestquest" / "www" / "nestquest-cards.js"
|
||||||
|
RENDER_HARNESS = FRONTEND_DIR / "tests" / "render-party-board.mjs"
|
||||||
|
STRATEGY_HARNESS = FRONTEND_DIR / "tests" / "render-strategy.mjs"
|
||||||
|
STRATEGY_SOURCE = FRONTEND_DIR / "src" / "strategy.ts"
|
||||||
|
|
||||||
PANEL_SOURCES = (PARTY_BOARD, QUEST_LOG)
|
PANEL_SOURCES = (PARTY_BOARD, QUEST_LOG)
|
||||||
|
|
||||||
@@ -157,4 +168,281 @@ def test_panel_cards_reference_no_admin_only_services() -> None:
|
|||||||
assert BUNDLE_PATH.is_file()
|
assert BUNDLE_PATH.is_file()
|
||||||
bundle = _read(BUNDLE_PATH)
|
bundle = _read(BUNDLE_PATH)
|
||||||
assert "nestquest-party-board-card" in bundle
|
assert "nestquest-party-board-card" in bundle
|
||||||
assert "nestquest-quest-log-card" in bundle
|
assert "nestquest-quest-log-card" in bundle
|
||||||
|
|
||||||
|
|
||||||
|
def test_party_board_discovers_children_from_the_household_roster() -> None:
|
||||||
|
"""Feature 20: with no child_order configured, the board discovers
|
||||||
|
the ordered child slugs from the household rollup's child_roster
|
||||||
|
attribute; explicit configuration still wins."""
|
||||||
|
source = _read(PARTY_BOARD)
|
||||||
|
assert "child_roster" in source
|
||||||
|
assert "sensor.nestquest_household_quests_due_today" in source
|
||||||
|
# Discovery only fills in for a MISSING child_order; a supplied
|
||||||
|
# order array is honoured verbatim before the discovered list is
|
||||||
|
# ever consulted.
|
||||||
|
assert "Array.isArray(order)" in source
|
||||||
|
assert "_discoveredChildSlugs()" in source
|
||||||
|
|
||||||
|
|
||||||
|
# --- Render tests (built bundle under jsdom) ---------------------------------
|
||||||
|
|
||||||
|
#: The seeded three-child household, in the API's sort order: Ada and
|
||||||
|
#: Bo share one daily quest (Bo is away today), Cory has none.
|
||||||
|
ROSTER = [
|
||||||
|
{"child_id": 1, "name": "Ada", "slug": "ada"},
|
||||||
|
{"child_id": 2, "name": "Bo", "slug": "bo"},
|
||||||
|
{"child_id": 3, "name": "Cory", "slug": "cory"},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _state(state: str, **attributes) -> dict:
|
||||||
|
return {"state": state, "attributes": attributes}
|
||||||
|
|
||||||
|
|
||||||
|
def _three_child_states() -> dict:
|
||||||
|
"""The hass states a three-child household exposes.
|
||||||
|
|
||||||
|
Entity ids follow the documented naming contract
|
||||||
|
(design/ENTITIES-AND-SERVICES.md §1): the household rollup and the
|
||||||
|
per-child sensors slugged from the child names.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"sensor.nestquest_household_quests_due_today": _state(
|
||||||
|
"2",
|
||||||
|
children={"1": 1, "2": 1, "3": 0},
|
||||||
|
child_roster=ROSTER,
|
||||||
|
),
|
||||||
|
"sensor.nestquest_ada_quests_due_today": _state(
|
||||||
|
"1", child_name="Ada", present=True
|
||||||
|
),
|
||||||
|
"sensor.nestquest_ada_quests_completed_today": _state("0"),
|
||||||
|
"sensor.nestquest_ada_completion_pct_today": _state("0"),
|
||||||
|
"binary_sensor.nestquest_ada_present_today": _state("on"),
|
||||||
|
"sensor.nestquest_bo_quests_due_today": _state(
|
||||||
|
"1", child_name="Bo", present=False
|
||||||
|
),
|
||||||
|
"sensor.nestquest_bo_quests_completed_today": _state("0"),
|
||||||
|
"sensor.nestquest_bo_completion_pct_today": _state("0"),
|
||||||
|
"binary_sensor.nestquest_bo_present_today": _state("off"),
|
||||||
|
"sensor.nestquest_cory_quests_due_today": _state(
|
||||||
|
"0", child_name="Cory", present=True
|
||||||
|
),
|
||||||
|
"sensor.nestquest_cory_quests_completed_today": _state("0"),
|
||||||
|
"sensor.nestquest_cory_completion_pct_today": _state("100"),
|
||||||
|
"binary_sensor.nestquest_cory_present_today": _state("on"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _render_party_board(config: dict, states: dict) -> dict:
|
||||||
|
"""Render the built bundle's party board and return its plates.
|
||||||
|
|
||||||
|
Drives frontend/tests/render-party-board.mjs: the harness imports
|
||||||
|
the committed bundle (the artifact HACS ships) into a jsdom window,
|
||||||
|
mounts the card with the given config and hass snapshot, and prints
|
||||||
|
the ordered plates its shadow DOM renders.
|
||||||
|
"""
|
||||||
|
assert BUNDLE_PATH.is_file(), "bundle missing: run cd frontend && npm run build"
|
||||||
|
assert RENDER_HARNESS.is_file()
|
||||||
|
spec = {
|
||||||
|
"bundle": str(BUNDLE_PATH),
|
||||||
|
"tag": "nestquest-party-board-card",
|
||||||
|
"config": config,
|
||||||
|
"hass": {"config": {"time_zone": "UTC"}, "states": states},
|
||||||
|
}
|
||||||
|
completed = subprocess.run(
|
||||||
|
["node", str(RENDER_HARNESS)],
|
||||||
|
input=json.dumps(spec),
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=120,
|
||||||
|
)
|
||||||
|
assert completed.returncode == 0, (
|
||||||
|
f"render harness failed: {completed.stderr}"
|
||||||
|
)
|
||||||
|
return json.loads(completed.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
def test_party_board_renders_discovered_children_in_sort_order() -> None:
|
||||||
|
"""No child_order key: three plates render in the roster's sort
|
||||||
|
order (the coordinator snapshot's order), one per child."""
|
||||||
|
result = _render_party_board(
|
||||||
|
{"type": "custom:nestquest-party-board-card"},
|
||||||
|
_three_child_states(),
|
||||||
|
)
|
||||||
|
assert result["plates"] == [
|
||||||
|
{"name": "Ada", "kind": "present"},
|
||||||
|
{"name": "Bo", "kind": "away"},
|
||||||
|
{"name": "Cory", "kind": "present"},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_explicit_child_order_still_wins_over_discovery() -> None:
|
||||||
|
"""A supplied child_order keeps working: it overrides the household
|
||||||
|
roster's order and limits the plates to the configured slugs."""
|
||||||
|
result = _render_party_board(
|
||||||
|
{
|
||||||
|
"type": "custom:nestquest-party-board-card",
|
||||||
|
"child_order": ["bo", "ada"],
|
||||||
|
},
|
||||||
|
_three_child_states(),
|
||||||
|
)
|
||||||
|
assert [plate["name"] for plate in result["plates"]] == ["Bo", "Ada"]
|
||||||
|
assert "Cory" not in [plate["name"] for plate in result["plates"]]
|
||||||
|
|
||||||
|
# --- Dashboard strategy tests -------------------------------------------------
|
||||||
|
|
||||||
|
STRATEGY_NAME = "nestquest-party"
|
||||||
|
|
||||||
|
|
||||||
|
def _generate_dashboard(config: dict, states: dict, url: str | None = None) -> dict:
|
||||||
|
"""Generate the strategy's dashboard from the built bundle.
|
||||||
|
|
||||||
|
Drives frontend/tests/render-strategy.mjs: the harness imports the
|
||||||
|
committed bundle into a jsdom window at the given dashboard URL and
|
||||||
|
prints the views ``window.customStrategies["nestquest-party"].
|
||||||
|
generate(config, hass)`` returns.
|
||||||
|
"""
|
||||||
|
assert BUNDLE_PATH.is_file(), "bundle missing: run cd frontend && npm run build"
|
||||||
|
assert STRATEGY_HARNESS.is_file()
|
||||||
|
spec = {
|
||||||
|
"bundle": str(BUNDLE_PATH),
|
||||||
|
"url": url or "http://homeassistant.local/nestquest/party",
|
||||||
|
"config": config,
|
||||||
|
"hass": {"config": {"time_zone": "UTC"}, "states": states},
|
||||||
|
}
|
||||||
|
completed = subprocess.run(
|
||||||
|
["node", str(STRATEGY_HARNESS)],
|
||||||
|
input=json.dumps(spec),
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=120,
|
||||||
|
)
|
||||||
|
assert completed.returncode == 0, (
|
||||||
|
f"strategy harness failed: {completed.stderr}"
|
||||||
|
)
|
||||||
|
return json.loads(completed.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_is_registered_on_the_bundle() -> None:
|
||||||
|
"""The strategy ships in the same bundle as the cards and registers
|
||||||
|
itself under window.customStrategies so a dashboard can use
|
||||||
|
strategy: { type: custom:nestquest-party }."""
|
||||||
|
source = _read(STRATEGY_SOURCE)
|
||||||
|
assert "customStrategies" in source
|
||||||
|
assert f'["{STRATEGY_NAME}"]' in source or f'"{STRATEGY_NAME}"' in source
|
||||||
|
bundle = _read(BUNDLE_PATH)
|
||||||
|
assert "nestquest-party" in bundle
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_generates_views_for_three_children() -> None:
|
||||||
|
"""For the seeded three-child household the strategy generates one
|
||||||
|
party-board view plus one quest-log view per child in roster order,
|
||||||
|
with COMPUTED paths: the board view at the dashboard root, each log
|
||||||
|
view at the child's slug so quest-log.ts's childSlugFromPath reads
|
||||||
|
the child from the URL's last segment."""
|
||||||
|
result = _generate_dashboard({}, _three_child_states())
|
||||||
|
views = result["views"]
|
||||||
|
assert len(views) == 4
|
||||||
|
assert [view["path"] for view in views] == [
|
||||||
|
"party",
|
||||||
|
"ada",
|
||||||
|
"bo",
|
||||||
|
"cory",
|
||||||
|
]
|
||||||
|
assert [view["title"] for view in views] == [
|
||||||
|
"The Party",
|
||||||
|
"Ada's Quest Log",
|
||||||
|
"Bo's Quest Log",
|
||||||
|
"Cory's Quest Log",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_every_view_is_panel_type() -> None:
|
||||||
|
"""Every generated view carries ``type: "panel"``: Home Assistant
|
||||||
|
defaults an unspecified view to Masonry, which constrains the
|
||||||
|
1080px-tall NestQuest card to a narrow column (README's TouchHub
|
||||||
|
setup warns of exactly this); with a generated dashboard there is
|
||||||
|
no editor step left to set Panel by hand."""
|
||||||
|
result = _generate_dashboard({}, _three_child_states())
|
||||||
|
for view in result["views"]:
|
||||||
|
assert view["type"] == "panel"
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_log_view_titles_use_the_roster_display_name() -> None:
|
||||||
|
"""Quest-log view titles come from the roster's ``name`` field (the
|
||||||
|
child's display name), not the lowercased entity-id slug; the slug
|
||||||
|
stays the view's path."""
|
||||||
|
result = _generate_dashboard(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
"sensor.nestquest_household_quests_due_today": _state(
|
||||||
|
"0",
|
||||||
|
child_roster=[
|
||||||
|
{"child_id": 7, "name": "Milo", "slug": "milo"},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
views = result["views"]
|
||||||
|
assert len(views) == 2
|
||||||
|
assert views[1]["path"] == "milo"
|
||||||
|
assert views[1]["title"] == "Milo's Quest Log"
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_passes_weather_entity_through_to_the_cards() -> None:
|
||||||
|
"""An explicit ``weather_entity`` in the strategy configuration is
|
||||||
|
passed through to the generated card configs (both the board and
|
||||||
|
the quest log render the weather dock when it is set)."""
|
||||||
|
result = _generate_dashboard(
|
||||||
|
{"weather_entity": "weather.home"},
|
||||||
|
_three_child_states(),
|
||||||
|
)
|
||||||
|
views = result["views"]
|
||||||
|
for view in views:
|
||||||
|
assert view["cards"][0]["weather_entity"] == "weather.home"
|
||||||
|
# And without it, no weather_entity key is emitted at all.
|
||||||
|
unset = _generate_dashboard({}, _three_child_states())
|
||||||
|
for view in unset["views"]:
|
||||||
|
assert "weather_entity" not in view["cards"][0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_wires_navigation_between_the_views() -> None:
|
||||||
|
"""The board's quest_log_path and each log's board_path are computed
|
||||||
|
to the dashboard root the strategy renders at, so party-board.ts's
|
||||||
|
crest tap pushes <root>/<slug> and quest-log.ts's idle return goes
|
||||||
|
back to the board — neither path is configured by hand."""
|
||||||
|
dashboard_url = "http://homeassistant.local/nestquest"
|
||||||
|
root = "/nestquest"
|
||||||
|
result = _generate_dashboard(
|
||||||
|
{}, _three_child_states(), url=dashboard_url
|
||||||
|
)
|
||||||
|
views = result["views"]
|
||||||
|
board = views[0]["cards"][0]
|
||||||
|
assert board["type"] == "custom:nestquest-party-board-card"
|
||||||
|
assert board["quest_log_path"] == root
|
||||||
|
for slug, view in zip(("ada", "bo", "cory"), views[1:]):
|
||||||
|
assert view["cards"][0]["type"] == "custom:nestquest-quest-log-card"
|
||||||
|
assert view["cards"][0]["board_path"] == root
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_zero_children_still_generates_the_board() -> None:
|
||||||
|
"""With an empty roster (NestQuest not set up yet) the strategy
|
||||||
|
renders the board view alone — the board card shows its own
|
||||||
|
"not set up yet" notice for an empty roster — and never crashes."""
|
||||||
|
result = _generate_dashboard({}, {})
|
||||||
|
assert len(result["views"]) == 1
|
||||||
|
assert result["views"][0]["path"] == "party"
|
||||||
|
|
||||||
|
|
||||||
|
def test_strategy_config_overrides_still_apply() -> None:
|
||||||
|
"""Explicit strategy configuration wins where the design allows: an
|
||||||
|
explicit url_path pins the computed dashboard root."""
|
||||||
|
result = _generate_dashboard(
|
||||||
|
{"url_path": "/wallboard"},
|
||||||
|
_three_child_states(),
|
||||||
|
)
|
||||||
|
root = "/wallboard"
|
||||||
|
assert result["views"][0]["cards"][0]["quest_log_path"] == root
|
||||||
|
for view in result["views"][1:]:
|
||||||
|
assert view["cards"][0]["board_path"] == root
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from custom_components.nestquest import async_setup_entry, async_unload_entry
|
|||||||
from custom_components.nestquest.const import DOMAIN
|
from custom_components.nestquest.const import DOMAIN
|
||||||
from custom_components.nestquest.sensor import (
|
from custom_components.nestquest.sensor import (
|
||||||
MAX_STATE_LENGTH,
|
MAX_STATE_LENGTH,
|
||||||
|
_slugify,
|
||||||
_state_within_limit,
|
_state_within_limit,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -539,3 +540,115 @@ async def test_household_rollups_sum_the_active_children(
|
|||||||
assert cycle_day_entity.name == "NestQuest cycle day"
|
assert cycle_day_entity.name == "NestQuest cycle day"
|
||||||
assert cycle_day_entity.native_value == 4
|
assert cycle_day_entity.native_value == 4
|
||||||
assert cycle_day_entity.extra_state_attributes["today"] == _today_iso()
|
assert cycle_day_entity.extra_state_attributes["today"] == _today_iso()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_household_due_sensor_publishes_the_ordered_child_roster(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""Feature 20: the rollup carries the ordered child roster beside
|
||||||
|
the unchanged per-child ``children`` counts, so the panel cards can
|
||||||
|
discover the board without a configured child_order. The order is
|
||||||
|
the coordinator snapshot's (the API's sort_order, then id)."""
|
||||||
|
entry, _coordinator, _client = await _setup_entry(
|
||||||
|
hass, make_entry, _seeded_payload()
|
||||||
|
)
|
||||||
|
attributes = hass.entities[
|
||||||
|
"nestquest_household_quests_due_today"
|
||||||
|
].extra_state_attributes
|
||||||
|
assert attributes["child_roster"] == [
|
||||||
|
{"child_id": ADA, "name": "Ada", "slug": "ada"},
|
||||||
|
{"child_id": BO, "name": "Bo", "slug": "bo"},
|
||||||
|
{"child_id": CORY, "name": "Cory", "slug": "cory"},
|
||||||
|
]
|
||||||
|
# The pre-existing per-child counts attribute is untouched.
|
||||||
|
assert attributes["children"] == {
|
||||||
|
str(ADA): 1,
|
||||||
|
str(BO): 1,
|
||||||
|
str(CORY): 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_household_roster_tracks_the_snapshot_on_refresh(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""The roster re-derives from every snapshot: a reorder and a
|
||||||
|
rename in the API payload show up (with the re-derived slug) on the
|
||||||
|
next refresh, like the sensor names already do."""
|
||||||
|
reordered = _payload(
|
||||||
|
[
|
||||||
|
_child(CORY, "Cory"),
|
||||||
|
_child(ADA, "Ada", [_instance(7, ADA)]),
|
||||||
|
_child(BO, "Mirren", [_instance(8, BO)]),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
entry, coordinator, _client = await _setup_entry(
|
||||||
|
hass, make_entry, _seeded_payload(), reordered
|
||||||
|
)
|
||||||
|
roster_entity = hass.entities["nestquest_household_quests_due_today"]
|
||||||
|
assert [entry["slug"] for entry in roster_entity.extra_state_attributes["child_roster"]] == [
|
||||||
|
"ada",
|
||||||
|
"bo",
|
||||||
|
"cory",
|
||||||
|
]
|
||||||
|
|
||||||
|
await coordinator.async_refresh()
|
||||||
|
|
||||||
|
assert roster_entity.extra_state_attributes["child_roster"] == [
|
||||||
|
{"child_id": CORY, "name": "Cory", "slug": "cory"},
|
||||||
|
{"child_id": ADA, "name": "Ada", "slug": "ada"},
|
||||||
|
{"child_id": BO, "name": "Mirren", "slug": "mirren"},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def test_duplicate_display_names_get_registry_suffix_slugs(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""Two children may share a nickname (the children layer allows
|
||||||
|
it); the roster's slugs then mirror the registry's collision
|
||||||
|
suffixing (_2, _3, ...) in snapshot order, so both plates resolve."""
|
||||||
|
payload = _payload(
|
||||||
|
[
|
||||||
|
_child(ADA, "Ada", [_instance(7, ADA)]),
|
||||||
|
_child(BO, "Ada"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
entry, _coordinator, _client = await _setup_entry(hass, make_entry, payload)
|
||||||
|
assert hass.entities[
|
||||||
|
"nestquest_household_quests_due_today"
|
||||||
|
].extra_state_attributes["child_roster"] == [
|
||||||
|
{"child_id": ADA, "name": "Ada", "slug": "ada"},
|
||||||
|
{"child_id": BO, "name": "Ada", "slug": "ada_2"},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def test_empty_household_publishes_an_empty_roster(
|
||||||
|
hass, make_entry
|
||||||
|
) -> None:
|
||||||
|
"""An empty household is a valid 0: the roster is an empty list,
|
||||||
|
and the card's discovery of it renders the not-set-up notice."""
|
||||||
|
entry, _coordinator, _client = await _setup_entry(
|
||||||
|
hass, make_entry, _payload([])
|
||||||
|
)
|
||||||
|
attributes = hass.entities[
|
||||||
|
"nestquest_household_quests_due_today"
|
||||||
|
].extra_state_attributes
|
||||||
|
assert attributes["child_roster"] == []
|
||||||
|
assert attributes["children"] == {}
|
||||||
|
|
||||||
|
|
||||||
|
def test_slugify_mirrors_home_assistant_entity_id_derivation() -> None:
|
||||||
|
"""The slug mirror matches homeassistant.util.slugify for the names
|
||||||
|
children are registered with (verified against HA's own slugify)."""
|
||||||
|
assert _slugify("Ada") == "ada"
|
||||||
|
assert _slugify("Mary Jane") == "mary_jane"
|
||||||
|
assert _slugify("Mary-Jane") == "mary_jane"
|
||||||
|
assert _slugify("O'Brien") == "o_brien"
|
||||||
|
assert _slugify("Émilie") == "emilie"
|
||||||
|
assert _slugify("Åsa") == "asa"
|
||||||
|
assert _slugify(" Bo ") == "bo"
|
||||||
|
# HA's wrapper answers "unknown" when a name slugs to nothing.
|
||||||
|
assert _slugify(" ") == "unknown"
|
||||||
|
assert _slugify("?!?") == "unknown"
|
||||||
|
# The registry caps the entity_id at 64 characters, so the slugged
|
||||||
|
# object id alone is capped at 64 - len("sensor.").
|
||||||
|
assert _slugify("a" * 80) == "a" * (64 - len("sensor."))
|
||||||
|
|||||||
Reference in New Issue
Block a user