224 files

This commit is contained in:
Home Assistant Version Control
2026-07-27 13:30:34 +00:00
parent b5723aa856
commit e36b8a1a22
224 changed files with 9967 additions and 2663 deletions
@@ -88,6 +88,22 @@ def _sanitize_history(history: Any) -> list[dict[str, Any]]:
return out
@websocket_api.websocket_command({vol.Required("type"): f"{DOMAIN}/version"})
@websocket_api.async_response
async def ws_version(hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any]) -> None:
"""The installed integration version (manifest).
Roadmap guard 2 — stale-bundle handshake: the panel compares this against
the version esbuild stamped into its bundle and offers a reload when a
cached old frontend is talking to a newer backend (HA's service worker
updates stale-while-revalidate, so this happens routinely after updates).
"""
from homeassistant.loader import async_get_integration
integration = await async_get_integration(hass, DOMAIN)
connection.send_result(msg["id"], {"version": integration.version})
@websocket_api.websocket_command(
{
vol.Required("type"): f"{DOMAIN}/templates",
@@ -108,7 +124,7 @@ async def ws_get_templates(
curation): the pickers hide disabled ones client-side, while the Settings
section needs the full list to render the toggles.
"""
from ..helpers.i18n import normalize_language
from ..helpers.i18n import normalize_language, normalize_language_code
from ..templates import (
TEMPLATE_CATEGORIES,
TEMPLATES,
@@ -117,7 +133,7 @@ async def ws_get_templates(
)
disabled = get_disabled_template_ids(hass)
lang = (msg.get("language") or normalize_language(hass))[:2].lower()
lang = normalize_language_code(msg.get("language")) if msg.get("language") else normalize_language(hass)
result = {
"categories": {cat_id: {k: v for k, v in cat.items()} for cat_id, cat in TEMPLATE_CATEGORIES.items()},
@@ -554,6 +570,11 @@ async def ws_import_json(
wd = task_data.get("warning_days")
if not isinstance(wd, int) or wd < 0 or wd > 365:
task_data["warning_days"] = get_default_warning_days(hass)
# A rotation task must carry its effective assignee (imports from
# pre-seeding exports may lack one) — same rule as create/update.
from ..helpers.sanitize import seed_rotation_assignee
seed_rotation_assignee(task_data)
# Sanitize checklist: only keep string items within length budget,
# cap total items. Drops malformed entries silently rather than
# rejecting the whole import — same forgiving model as the other