From 7efeb09ba0028a747a65991d92641aa0f775cbcc Mon Sep 17 00:00:00 2001 From: Misiu Date: Wed, 26 Aug 2026 11:23:34 +0200 Subject: [PATCH 1/4] Add native widget selectors and weather provider --- WIDGET_CONTRACT.md | 34 +++- .../opendisplay_studio/composer.py | 33 +++- .../opendisplay_studio/data_providers.py | 171 ++++++++++++++++++ .../frontend/opendisplay-studio.js | 35 ++-- frontend-src/src/odx-app.ts | 23 ++- frontend-src/src/types.ts | 3 +- tests/test_data_providers.py | 109 ++++++++++- 7 files changed, 366 insertions(+), 42 deletions(-) diff --git a/WIDGET_CONTRACT.md b/WIDGET_CONTRACT.md index 42983a3..936ad15 100644 --- a/WIDGET_CONTRACT.md +++ b/WIDGET_CONTRACT.md @@ -9,10 +9,27 @@ data requirements Liquid template ``` -The panel builds controls from `fields`. Home Assistant-aware field types -currently include `entity` and `calendar`; the contract already represents an -`entities` multi-selector for future widgets. Configuration stores references, -never current values. +Widget packages are declarative and never contain executable Python. A package +can only request provider names registered by OpenDisplay Studio Integration. +This keeps installation reviewable and prevents a downloaded widget from +executing arbitrary code inside Home Assistant. + +The panel builds controls from `fields`. A field can contain a native Home +Assistant `selector` object, using the same schema as blueprint inputs. The +panel passes that object to `ha-form` without recreating selector behavior. +Legacy built-in fields can continue using the shorthand `type` property while +packages migrate. Configuration stores references, never current values. + +```yaml +fields: + - key: weather + label: Weather entity + required: true + selector: + entity: + filter: + domain: weather +``` Data requirements are declarative. A requirement names its provider, the configuration key containing its source, whether the source has cardinality @@ -62,7 +79,7 @@ A Table can use ordinary presentation fields plus a multi-entity requirement: Its normalized Liquid context can then contain five room-temperature rows without exposing the full Home Assistant state machine. -## Future Weather +## Weather Weather can declare a required forecast source and a second optional current temperature sensor. Both are resolved at render time: @@ -88,6 +105,7 @@ temperature sensor. Both are resolved at render time: } ``` -Adding that widget requires a `WeatherProvider` and its definition/template; -it does not change project storage, Media Source identity, the frontend/backend -transport, or the Renderer API. +The `weather_forecast` provider belongs to the integration. It uses the selected +entity's state for current conditions and the public `weather.get_forecasts` +action for forecasts, then exposes one normalized Liquid object. Multiple +widgets selecting the same entity share the same collected provider result. diff --git a/custom_components/opendisplay_studio/composer.py b/custom_components/opendisplay_studio/composer.py index 6963915..9ec4796 100644 --- a/custom_components/opendisplay_studio/composer.py +++ b/custom_components/opendisplay_studio/composer.py @@ -2,6 +2,7 @@ from __future__ import annotations +import asyncio from dataclasses import dataclass from time import perf_counter from typing import Any @@ -9,7 +10,12 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from .data_providers import ICON_PATHS, CalendarProvider, EntityStateProvider +from .data_providers import ( + ICON_PATHS, + CalendarProvider, + EntityStateProvider, + WeatherForecastProvider, +) from .liquid_renderer import LIQUID from .projects import Project from .widgets import TEMPLATES, definition, with_defaults @@ -122,10 +128,11 @@ def _calendar_value( def _collect_requirements( project: Project, -) -> tuple[set[str], dict[str, int]]: +) -> tuple[set[str], dict[str, int], set[str]]: """Compile widget declarations into one deduplicated screen request.""" entity_ids: set[str] = set() calendar_requests: dict[str, int] = {} + weather_requests: set[str] = set() for region in project["regions"]: widget = region.get("widget") if widget is None: @@ -142,7 +149,9 @@ def _collect_requirements( calendar_requests[entity_id] = max( calendar_requests.get(entity_id, 0), days ) - return entity_ids, calendar_requests + elif requirement["provider"] == "weather_forecast": + weather_requests.update(sources) + return entity_ids, calendar_requests, weather_requests def _resolve_widget_data( @@ -150,6 +159,7 @@ def _resolve_widget_data( config: dict[str, Any], entities: dict[str, dict[str, str]], calendars: dict[str, list[dict[str, str | bool | int]]], + weather: dict[str, dict[str, Any]], ) -> dict[str, Any]: """Hydrate declared requirements with normalized provider values.""" data: dict[str, Any] = {} @@ -188,6 +198,8 @@ def _resolve_widget_data( ) for source in sources ] + elif requirement["provider"] == "weather_forecast": + values = [weather.get(source) for source in sources] data[requirement["key"]] = ( values if requirement.get("cardinality") == "many" @@ -203,10 +215,13 @@ async def async_compose_project( ) -> ComposedProject: """Collect requirements once, render fragments, and create one screen.""" started = perf_counter() - entity_ids, calendar_requests = _collect_requirements(project) + entity_ids, calendar_requests, weather_requests = _collect_requirements(project) entities = EntityStateProvider(hass).get_many(entity_ids) try: - calendars = await CalendarProvider(hass).async_get_many(calendar_requests) + calendars, weather = await asyncio.gather( + CalendarProvider(hass).async_get_many(calendar_requests), + WeatherForecastProvider(hass).async_get_many(weather_requests), + ) except HomeAssistantError as err: raise ProjectComposeError("Could not resolve widget data") from err data_ms = (perf_counter() - started) * 1_000 @@ -222,7 +237,13 @@ async def async_compose_project( if widget is not None: widget_type = widget["type"] config = with_defaults(widget_type, widget["config"]) - data = _resolve_widget_data(widget_type, config, entities, calendars) + data = _resolve_widget_data( + widget_type, + config, + entities, + calendars, + weather, + ) if widget_type == "entity-state" and data.get("entity") is not None: title = str(config.get("title", "")).strip() data["entity"]["displayName"] = title or data["entity"]["name"] diff --git a/custom_components/opendisplay_studio/data_providers.py b/custom_components/opendisplay_studio/data_providers.py index d8fa6a8..f41d068 100644 --- a/custom_components/opendisplay_studio/data_providers.py +++ b/custom_components/opendisplay_studio/data_providers.py @@ -4,8 +4,15 @@ import asyncio from datetime import date, datetime, timedelta +from typing import Any from homeassistant.components.calendar import DATA_COMPONENT, CalendarEntity +from homeassistant.components.weather import ( + DOMAIN as WEATHER_DOMAIN, +) +from homeassistant.components.weather import ( + SERVICE_GET_FORECASTS, +) from homeassistant.core import HomeAssistant from homeassistant.util import dt as dt_util @@ -32,6 +39,44 @@ "mdi:water-percent": "humidity", } +WEATHER_CONDITION_LABELS = { + "clear-night": "Clear night", + "cloudy": "Cloudy", + "exceptional": "Exceptional", + "fog": "Fog", + "hail": "Hail", + "lightning": "Lightning", + "lightning-rainy": "Thunderstorms and rain", + "partlycloudy": "Partly cloudy", + "pouring": "Heavy rain", + "rainy": "Rain", + "snowy": "Snow", + "snowy-rainy": "Snow and rain", + "sunny": "Sunny", + "windy": "Windy", + "windy-variant": "Windy and cloudy", +} + +WEATHER_CONDITION_ICONS = { + "clear-night": "wi-night-clear.svg", + "cloudy": "wi-cloudy.svg", + "exceptional": "wi-na.svg", + "fog": "wi-fog.svg", + "hail": "wi-hail.svg", + "lightning": "wi-lightning.svg", + "lightning-rainy": "wi-thunderstorm.svg", + "partlycloudy": "wi-day-cloudy.svg", + "pouring": "wi-rain-wind.svg", + "rainy": "wi-rain.svg", + "snowy": "wi-snow.svg", + "snowy-rainy": "wi-rain-mix.svg", + "sunny": "wi-day-sunny.svg", + "windy": "wi-strong-wind.svg", + "windy-variant": "wi-cloudy-windy.svg", +} + +WEATHER_ICON_BASE_URL = "https://trmnl.com/images/plugins/weather" + def _entity_icon_path(entity_id: str, attributes: dict[str, object]) -> str: """Choose a deterministic local icon without external image requests.""" @@ -88,6 +133,132 @@ def get_many(self, entity_ids: set[str]) -> dict[str, dict[str, str]]: return result +def _weather_condition_label(condition: str) -> str: + """Return an English fallback label for a Home Assistant condition.""" + return WEATHER_CONDITION_LABELS.get( + condition, + condition.replace("-", " ").capitalize() if condition else "Unavailable", + ) + + +def _weather_icon(condition: str) -> str: + """Map a Home Assistant condition to a TRMNL weather icon.""" + filename = WEATHER_CONDITION_ICONS.get(condition, "wi-na.svg") + return f"{WEATHER_ICON_BASE_URL}/{filename}" + + +def _uv_label(value: object) -> str | None: + """Convert a numeric UV index into the conventional exposure category.""" + if not isinstance(value, int | float) or isinstance(value, bool): + return None + if value >= 11: + return "Extreme" + if value >= 8: + return "Very high" + if value >= 6: + return "High" + if value >= 3: + return "Moderate" + return "Low" + + +def _forecast_date_label(value: object, today: date) -> str: + """Create a compact local label for a forecast timestamp.""" + parsed = dt_util.parse_datetime(str(value)) if value else None + if parsed is None: + return "" + local_date = dt_util.as_local(parsed).date() + offset = (local_date - today).days + if offset == 0: + return "Today" + if offset == 1: + return "Tomorrow" + return local_date.strftime("%a") + + +class WeatherForecastProvider: + """Resolve current weather state and daily forecasts.""" + + def __init__(self, hass: HomeAssistant) -> None: + """Initialize the provider.""" + self._hass = hass + + async def async_get_many(self, entity_ids: set[str]) -> dict[str, dict[str, Any]]: + """Resolve selected weather entities with one forecast action call.""" + if not entity_ids: + return {} + + sorted_entity_ids = sorted(entity_ids) + response = await self._hass.services.async_call( + WEATHER_DOMAIN, + SERVICE_GET_FORECASTS, + {"type": "daily"}, + blocking=True, + target={"entity_id": sorted_entity_ids}, + return_response=True, + ) + forecast_response = response if isinstance(response, dict) else {} + today = dt_util.now().date() + result: dict[str, dict[str, Any]] = {} + + for entity_id in sorted_entity_ids: + state = self._hass.states.get(entity_id) + attributes = state.attributes if state is not None else {} + condition = state.state if state is not None else "unavailable" + response_item = forecast_response.get(entity_id, {}) + raw_forecasts = ( + response_item.get("forecast", []) + if isinstance(response_item, dict) + else [] + ) + forecasts: list[dict[str, Any]] = [] + if isinstance(raw_forecasts, list): + for item in raw_forecasts: + if not isinstance(item, dict): + continue + forecast_condition = str(item.get("condition") or "exceptional") + uv_index = item.get("uv_index") + forecasts.append( + { + "datetime": str(item.get("datetime") or ""), + "date_label": _forecast_date_label( + item.get("datetime"), today + ), + "condition": forecast_condition, + "condition_label": _weather_condition_label( + forecast_condition + ), + "icon": _weather_icon(forecast_condition), + "temperature": item.get("temperature"), + "templow": item.get("templow"), + "uv_index": uv_index, + "uv_label": _uv_label(uv_index), + "precipitation_probability": item.get( + "precipitation_probability" + ), + } + ) + + result[entity_id] = { + "entity_id": entity_id, + "name": str(attributes.get("friendly_name", entity_id)), + "condition": condition, + "condition_label": _weather_condition_label(condition), + "icon": _weather_icon(condition), + "temperature": attributes.get("temperature", "—"), + "temperature_unit": str(attributes.get("temperature_unit", "")), + "apparent_temperature": attributes.get("apparent_temperature"), + "humidity": attributes.get("humidity"), + "updated_at": ( + dt_util.as_local(state.last_updated).strftime("%H:%M") + if state is not None + else "" + ), + "forecast": forecasts, + } + return result + + class CalendarProvider: """Fetch and normalize events from requested calendar entities.""" diff --git a/custom_components/opendisplay_studio/frontend/opendisplay-studio.js b/custom_components/opendisplay_studio/frontend/opendisplay-studio.js index c025259..a5ef68e 100644 --- a/custom_components/opendisplay_studio/frontend/opendisplay-studio.js +++ b/custom_components/opendisplay_studio/frontend/opendisplay-studio.js @@ -3667,24 +3667,20 @@ var mt = (e) => { `; } renderOption(e) { - let t = this.selectedRegion?.widget, n = t?.config[e.key] ?? (t ? this.widgetDefinition(t.type)?.defaults[e.key] : void 0); - if (e.type === "entity" || e.type === "entities" || e.type === "calendar") { - let t = e.type === "calendar" ? { entity: { domain: "calendar" } } : { entity: e.type === "entities" ? { multiple: !0 } : {} }; - return E` + let t = this.selectedRegion?.widget, n = t?.config[e.key] ?? (t ? this.widgetDefinition(t.type)?.defaults[e.key] : void 0), r = e.selector ?? (e.type === "calendar" ? { entity: { filter: { domain: "calendar" } } } : e.type === "entities" ? { entity: { multiple: !0 } } : e.type === "entity" ? { entity: {} } : void 0); + return r ? E` this.updateWidgetValue(e, t.detail.value[e.key])} > - `; - } - return e.type === "toggle" ? E` + ` : e.type === "toggle" ? E`
this.updateWidgetOption(e, t)} />
` : e.type === "select" ? E`
@@ -3706,15 +3702,16 @@ var mt = (e) => { `; } updateWidgetValue(e, t) { - this.updateProject((n) => ({ - ...n, - regions: n.regions.map((n) => n.id !== this.selectedRegionId || !n.widget ? n : { - ...n, + let n = Array.isArray(t) ? t.map((e) => String(e)) : typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : String(t ?? ""); + this.updateProject((t) => ({ + ...t, + regions: t.regions.map((t) => t.id !== this.selectedRegionId || !t.widget ? t : { + ...t, widget: { - ...n.widget, + ...t.widget, config: { - ...n.widget.config, - [e.key]: Array.isArray(t) ? t.map((e) => String(e)) : String(t ?? "") + ...t.widget.config, + [e.key]: n } } }) diff --git a/frontend-src/src/odx-app.ts b/frontend-src/src/odx-app.ts index 63790ce..e6766b7 100644 --- a/frontend-src/src/odx-app.ts +++ b/frontend-src/src/odx-app.ts @@ -37,6 +37,7 @@ import type { PersistedState, ScreenProject, WidgetDefinition, + WidgetConfigValue, WidgetOption, } from './types' import { WIDGETS, getWidgetDefinition, widgetStyles } from './widgets/registry' @@ -797,10 +798,15 @@ export class OdxApp extends LitElement { const widget = this.selectedRegion?.widget const value = widget?.config[option.key] ?? (widget ? this.widgetDefinition(widget.type)?.defaults[option.key] : undefined) - if (option.type === 'entity' || option.type === 'entities' || option.type === 'calendar') { - const selector = option.type === 'calendar' - ? { entity: { domain: 'calendar' } } - : { entity: option.type === 'entities' ? { multiple: true } : {} } + const selector = option.selector + ?? (option.type === 'calendar' + ? { entity: { filter: { domain: 'calendar' } } } + : option.type === 'entities' + ? { entity: { multiple: true } } + : option.type === 'entity' + ? { entity: {} } + : undefined) + if (selector) { return html` String(item)) + : typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' + ? value + : String(value ?? '') this.updateProject((project) => ({ ...project, regions: project.regions.map((region) => { @@ -846,9 +857,7 @@ export class OdxApp extends LitElement { ...region.widget, config: { ...region.widget.config, - [option.key]: Array.isArray(value) - ? value.map((item) => String(item)) - : String(value ?? ''), + [option.key]: normalizedValue, }, }, } diff --git a/frontend-src/src/types.ts b/frontend-src/src/types.ts index 40f88bf..9384d26 100644 --- a/frontend-src/src/types.ts +++ b/frontend-src/src/types.ts @@ -88,7 +88,8 @@ export type WidgetFieldType = 'text' | 'number' | 'select' | 'toggle' | 'entity' export interface WidgetOption { key: string label: string - type: WidgetFieldType + type?: WidgetFieldType + selector?: Record min?: number max?: number step?: number diff --git a/tests/test_data_providers.py b/tests/test_data_providers.py index d4d15df..884f94b 100644 --- a/tests/test_data_providers.py +++ b/tests/test_data_providers.py @@ -1,6 +1,11 @@ """Tests for normalized Home Assistant widget providers.""" -from custom_components.opendisplay_studio.data_providers import EntityStateProvider +from unittest.mock import AsyncMock, patch + +from custom_components.opendisplay_studio.data_providers import ( + EntityStateProvider, + WeatherForecastProvider, +) def test_entity_provider_returns_normalized_current_state(hass) -> None: @@ -27,3 +32,105 @@ def test_entity_provider_returns_normalized_current_state(hass) -> None: ), } } + + +async def test_weather_provider_combines_entity_state_and_daily_forecast(hass) -> None: + hass.states.async_set( + "weather.home", + "partlycloudy", + { + "friendly_name": "Home", + "temperature": 18.4, + "temperature_unit": "°C", + "apparent_temperature": 17.2, + "humidity": 72, + }, + ) + service_response = { + "weather.home": { + "forecast": [ + { + "datetime": "2026-08-26T12:00:00+02:00", + "condition": "rainy", + "temperature": 20, + "templow": 13, + "uv_index": 3, + "precipitation_probability": 70, + } + ] + } + } + + with patch.object( + hass.services, + "async_call", + AsyncMock(return_value=service_response), + ) as async_call: + result = await WeatherForecastProvider(hass).async_get_many({"weather.home"}) + + async_call.assert_awaited_once_with( + "weather", + "get_forecasts", + {"type": "daily"}, + blocking=True, + target={"entity_id": ["weather.home"]}, + return_response=True, + ) + current = result["weather.home"] + assert current["entity_id"] == "weather.home" + assert current["name"] == "Home" + assert current["condition"] == "partlycloudy" + assert current["condition_label"] == "Partly cloudy" + assert current["temperature"] == 18.4 + assert current["temperature_unit"] == "°C" + assert current["apparent_temperature"] == 17.2 + assert current["humidity"] == 72 + assert current["updated_at"] + forecast = current["forecast"][0] + assert forecast["datetime"] == "2026-08-26T12:00:00+02:00" + assert forecast["condition"] == "rainy" + assert forecast["condition_label"] == "Rain" + assert forecast["icon"] == ("https://trmnl.com/images/plugins/weather/wi-rain.svg") + assert forecast["temperature"] == 20 + assert forecast["templow"] == 13 + assert forecast["uv_index"] == 3 + assert forecast["uv_label"] == "Moderate" + assert forecast["precipitation_probability"] == 70 + + +async def test_weather_provider_uses_explicit_nulls_for_optional_values(hass) -> None: + hass.states.async_set( + "weather.home", + "cloudy", + { + "friendly_name": "Home", + "temperature": 16, + "temperature_unit": "°C", + }, + ) + service_response = { + "weather.home": { + "forecast": [ + { + "datetime": "2026-08-27T12:00:00+02:00", + "condition": "cloudy", + "temperature": 19, + } + ] + } + } + + with patch.object( + hass.services, + "async_call", + AsyncMock(return_value=service_response), + ): + result = await WeatherForecastProvider(hass).async_get_many({"weather.home"}) + + current = result["weather.home"] + assert current["apparent_temperature"] is None + assert current["humidity"] is None + assert current["forecast"][0]["templow"] is None + assert current["forecast"][0]["uv_index"] is None + assert current["forecast"][0]["uv_label"] is None + assert current["forecast"][0]["precipitation_probability"] is None From 6dfd9ade39fd6aae6cf0292d4e3c286c3997dadb Mon Sep 17 00:00:00 2001 From: Misiu Date: Wed, 26 Aug 2026 11:33:50 +0200 Subject: [PATCH 2/4] Register live Weather widget --- CHANGELOG.md | 9 + README.md | 15 +- WIDGET_CONTRACT.md | 16 +- .../frontend/opendisplay-studio.js | 368 +++++++++------ .../opendisplay_studio/liquid_renderer.py | 2 +- .../opendisplay_studio/manifest.json | 2 +- .../opendisplay_studio/projects.py | 13 + .../widget_templates/weather.liquid | 439 ++++++++++++++++++ .../opendisplay_studio/widgets.py | 60 +++ frontend-src/src/odx-app.ts | 12 +- frontend-src/src/widgets/registry.ts | 2 + frontend-src/src/widgets/weather/styles.ts | 27 ++ frontend-src/src/widgets/weather/widget.ts | 38 ++ tests/test_composer.py | 52 +++ tests/test_projects.py | 40 ++ 15 files changed, 923 insertions(+), 172 deletions(-) create mode 100644 custom_components/opendisplay_studio/widget_templates/weather.liquid create mode 100644 frontend-src/src/widgets/weather/styles.ts create mode 100644 frontend-src/src/widgets/weather/widget.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b80baf3..c116c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Unreleased + +- Add the adaptive Weather widget with a native Home Assistant weather entity + selector and live designer preview. +- Resolve current conditions from entity state and daily forecasts through + `weather.get_forecasts`, deduplicated across regions. +- Allow widget packages to provide native Home Assistant selector schemas while + keeping executable provider code inside the integration. + ## 0.3.2 - Make the designer preview use the live Liquid/TRMNL HTML composed by the diff --git a/README.md b/README.md index 095c762..e832e08 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,10 @@ Home Assistant data. Open **OpenDisplay Studio** in the Home Assistant sidebar to create predefined or custom displays, edit their logical grids, compose rectangular regions, and -assign Entity State, Calendar, or Text widgets. Project configuration is stored -with Home Assistant's versioned `Store`; browser `localStorage` is not used. +assign Entity State, Calendar, Weather, or Text widgets. Weather configuration +uses Home Assistant's native entity selector and renders current conditions plus +the selected entity's daily forecast. Project configuration is stored with Home +Assistant's versioned `Store`; browser `localStorage` is not used. Draft projects remain private to the designer. A Ready project is exposed at a stable URI based on its immutable server-generated ID: @@ -21,12 +23,13 @@ media-source://opendisplay_studio/ ``` On every resolution the integration deduplicates widget data requirements, -reads current entity states and calendar events, renders widget Liquid -templates, composes one TRMNL Framework document, and sends that final HTML to -the Renderer. The Renderer App still knows only HTML, width, and height. +reads current entity states, calendar events, and requested weather forecasts, +renders widget Liquid templates, composes one TRMNL Framework document, and +sends that final HTML to the Renderer. The Renderer App still knows only HTML, +width, and height. See [the widget contract](WIDGET_CONTRACT.md) for the schema/data/template -boundary and the planned multi-entity Table and optional-source Weather model. +boundary, native Home Assistant selectors, and the controlled provider model. See [Stage 2 compatibility](STAGE2_COMPATIBILITY.md) for the Liquid/TRMNL compatibility baseline retained by Stage 3. diff --git a/WIDGET_CONTRACT.md b/WIDGET_CONTRACT.md index 936ad15..397c78a 100644 --- a/WIDGET_CONTRACT.md +++ b/WIDGET_CONTRACT.md @@ -81,25 +81,19 @@ without exposing the full Home Assistant state machine. ## Weather -Weather can declare a required forecast source and a second optional current -temperature sensor. Both are resolved at render time: +Weather declares one required entity. The provider combines its current state +with the requested daily forecast at render time: ```json { "dataRequirements": [ { - "key": "forecast", + "key": "weather", "provider": "weather_forecast", "configKey": "weather", "cardinality": "one", - "optional": false - }, - { - "key": "externalTemperature", - "provider": "entity_state", - "configKey": "temperatureEntity", - "cardinality": "one", - "optional": true + "optional": false, + "forecastType": "daily" } ] } diff --git a/custom_components/opendisplay_studio/frontend/opendisplay-studio.js b/custom_components/opendisplay_studio/frontend/opendisplay-studio.js index a5ef68e..f4e85a0 100644 --- a/custom_components/opendisplay_studio/frontend/opendisplay-studio.js +++ b/custom_components/opendisplay_studio/frontend/opendisplay-studio.js @@ -58,23 +58,23 @@ var e = globalThis, t = e.ShadowRoot && (e.ShadyCSS === void 0 || e.ShadyCSS.nat } return n; } -}, h = (e, t) => !l(e, t), oe = { +}, oe = (e, t) => !l(e, t), se = { attribute: !0, type: String, converter: m, reflect: !1, useDefault: !1, - hasChanged: h + hasChanged: oe }; Symbol.metadata ??= Symbol("metadata"), f.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap(); -var g = class extends HTMLElement { +var h = class extends HTMLElement { static addInitializer(e) { this._$Ei(), (this.l ??= []).push(e); } static get observedAttributes() { return this.finalize(), this._$Eh && [...this._$Eh.keys()]; } - static createProperty(e, t = oe) { + static createProperty(e, t = se) { if (t.state && (t.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((t = Object.create(t)).wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) { let n = Symbol(), r = this.getPropertyDescriptor(e, n, t); r !== void 0 && u(this.prototype, e, r); @@ -100,7 +100,7 @@ var g = class extends HTMLElement { }; } static getPropertyOptions(e) { - return this.elementProperties.get(e) ?? oe; + return this.elementProperties.get(e) ?? se; } static _$Ei() { if (this.hasOwnProperty(p("elementProperties"))) return; @@ -187,7 +187,7 @@ var g = class extends HTMLElement { requestUpdate(e, t, n, r = !1, i) { if (e !== void 0) { let a = this.constructor; - if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? h)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return; + if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? oe)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return; this.C(e, t, n); } !1 === this.isUpdatePending && (this._$ES = this._$EP()); @@ -251,40 +251,40 @@ var g = class extends HTMLElement { updated(e) {} firstUpdated(e) {} }; -g.elementStyles = [], g.shadowRootOptions = { mode: "open" }, g[p("elementProperties")] = /* @__PURE__ */ new Map(), g[p("finalized")] = /* @__PURE__ */ new Map(), ae?.({ ReactiveElement: g }), (f.reactiveElementVersions ??= []).push("2.1.2"); +h.elementStyles = [], h.shadowRootOptions = { mode: "open" }, h[p("elementProperties")] = /* @__PURE__ */ new Map(), h[p("finalized")] = /* @__PURE__ */ new Map(), ae?.({ ReactiveElement: h }), (f.reactiveElementVersions ??= []).push("2.1.2"); //#endregion //#region node_modules/lit-html/lit-html.js -var se = globalThis, ce = (e) => e, _ = se.trustedTypes, le = _ ? _.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, ue = "$lit$", v = `lit$${Math.random().toFixed(9).slice(2)}$`, de = "?" + v, fe = `<${de}>`, y = document, b = () => y.createComment(""), x = (e) => e === null || typeof e != "object" && typeof e != "function", S = Array.isArray, pe = (e) => S(e) || typeof e?.[Symbol.iterator] == "function", C = "[ \n\f\r]", w = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, me = /-->/g, he = />/g, T = RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), ge = /'/g, _e = /"/g, ve = /^(?:script|style|textarea|title)$/i, E = ((e) => (t, ...n) => ({ +var ce = globalThis, le = (e) => e, g = ce.trustedTypes, ue = g ? g.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, de = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, fe = "?" + _, pe = `<${fe}>`, v = document, y = () => v.createComment(""), b = (e) => e === null || typeof e != "object" && typeof e != "function", x = Array.isArray, me = (e) => x(e) || typeof e?.[Symbol.iterator] == "function", he = "[ \n\f\r]", S = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ge = /-->/g, _e = />/g, C = RegExp(`>|${he}(?:([^\\s"'>=/]+)(${he}*=${he}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), ve = /'/g, ye = /"/g, be = /^(?:script|style|textarea|title)$/i, w = ((e) => (t, ...n) => ({ _$litType$: e, strings: t, values: n -}))(1), D = Symbol.for("lit-noChange"), O = Symbol.for("lit-nothing"), ye = /* @__PURE__ */ new WeakMap(), k = y.createTreeWalker(y, 129); -function be(e, t) { - if (!S(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array"); - return le === void 0 ? t : le.createHTML(t); +}))(1), T = Symbol.for("lit-noChange"), E = Symbol.for("lit-nothing"), xe = /* @__PURE__ */ new WeakMap(), D = v.createTreeWalker(v, 129); +function Se(e, t) { + if (!x(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array"); + return ue === void 0 ? t : ue.createHTML(t); } -var xe = (e, t) => { - let n = e.length - 1, r = [], i, a = t === 2 ? "" : t === 3 ? "" : "", o = w; +var Ce = (e, t) => { + let n = e.length - 1, r = [], i, a = t === 2 ? "" : t === 3 ? "" : "", o = S; for (let t = 0; t < n; t++) { let n = e[t], s, c, l = -1, u = 0; - for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === w ? c[1] === "!--" ? o = me : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = T) : (ve.test(c[2]) && (i = RegExp("" ? (o = i ?? w, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? T : c[3] === "\"" ? _e : ge) : o === _e || o === ge ? o = T : o === me || o === he ? o = w : (o = T, i = void 0); - let d = o === T && e[t + 1].startsWith("/>") ? " " : ""; - a += o === w ? n + fe : l >= 0 ? (r.push(s), n.slice(0, l) + ue + n.slice(l) + v + d) : n + v + (l === -2 ? t : d); + for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === S ? c[1] === "!--" ? o = ge : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = C) : (be.test(c[2]) && (i = RegExp("" ? (o = i ?? S, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? C : c[3] === "\"" ? ye : ve) : o === ye || o === ve ? o = C : o === ge || o === _e ? o = S : (o = C, i = void 0); + let d = o === C && e[t + 1].startsWith("/>") ? " " : ""; + a += o === S ? n + pe : l >= 0 ? (r.push(s), n.slice(0, l) + de + n.slice(l) + _ + d) : n + _ + (l === -2 ? t : d); } - return [be(e, a + (e[n] || "") + (t === 2 ? "" : t === 3 ? "" : "")), r]; -}, Se = class e { + return [Se(e, a + (e[n] || "") + (t === 2 ? "" : t === 3 ? "" : "")), r]; +}, O = class e { constructor({ strings: t, _$litType$: n }, r) { let i; this.parts = []; - let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = xe(t, n); - if (this.el = e.createElement(l, r), k.currentNode = this.el.content, n === 2 || n === 3) { + let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = Ce(t, n); + if (this.el = e.createElement(l, r), D.currentNode = this.el.content, n === 2 || n === 3) { let e = this.el.content.firstChild; e.replaceWith(...e.childNodes); } - for (; (i = k.nextNode()) !== null && c.length < s;) { + for (; (i = D.nextNode()) !== null && c.length < s;) { if (i.nodeType === 1) { - if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith(ue)) { - let t = u[o++], n = i.getAttribute(e).split(v), r = /([.?@])?(.*)/.exec(t); + if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith(de)) { + let t = u[o++], n = i.getAttribute(e).split(_), r = /([.?@])?(.*)/.exec(t); c.push({ type: 1, index: a, @@ -292,48 +292,48 @@ var xe = (e, t) => { strings: n, ctor: r[1] === "." ? Te : r[1] === "?" ? Ee : r[1] === "@" ? De : j }), i.removeAttribute(e); - } else e.startsWith(v) && (c.push({ + } else e.startsWith(_) && (c.push({ type: 6, index: a }), i.removeAttribute(e)); - if (ve.test(i.tagName)) { - let e = i.textContent.split(v), t = e.length - 1; + if (be.test(i.tagName)) { + let e = i.textContent.split(_), t = e.length - 1; if (t > 0) { - i.textContent = _ ? _.emptyScript : ""; - for (let n = 0; n < t; n++) i.append(e[n], b()), k.nextNode(), c.push({ + i.textContent = g ? g.emptyScript : ""; + for (let n = 0; n < t; n++) i.append(e[n], y()), D.nextNode(), c.push({ type: 2, index: ++a }); - i.append(e[t], b()); + i.append(e[t], y()); } } } else if (i.nodeType === 8) { - if (i.data === de) c.push({ + if (i.data === fe) c.push({ type: 2, index: a }); else { let e = -1; - for (; (e = i.data.indexOf(v, e + 1)) !== -1;) c.push({ + for (; (e = i.data.indexOf(_, e + 1)) !== -1;) c.push({ type: 7, index: a - }), e += v.length - 1; + }), e += _.length - 1; } } a++; } } static createElement(e, t) { - let n = y.createElement("template"); + let n = v.createElement("template"); return n.innerHTML = e, n; } }; -function A(e, t, n = e, r) { - if (t === D) return t; - let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = x(t) ? void 0 : t._$litDirective$; - return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = A(e, i._$AS(e, t.values), i, r)), t; +function k(e, t, n = e, r) { + if (t === T) return t; + let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = b(t) ? void 0 : t._$litDirective$; + return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = k(e, i._$AS(e, t.values), i, r)), t; } -var Ce = class { +var we = class { constructor(e, t) { this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t; } @@ -344,28 +344,28 @@ var Ce = class { return this._$AM._$AU; } u(e) { - let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? y).importNode(t, !0); - k.currentNode = r; - let i = k.nextNode(), a = 0, o = 0, s = n[0]; + let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? v).importNode(t, !0); + D.currentNode = r; + let i = D.nextNode(), a = 0, o = 0, s = n[0]; for (; s !== void 0;) { if (a === s.index) { let t; - s.type === 2 ? t = new we(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new Oe(i, this, e)), this._$AV.push(t), s = n[++o]; + s.type === 2 ? t = new A(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new Oe(i, this, e)), this._$AV.push(t), s = n[++o]; } - a !== s?.index && (i = k.nextNode(), a++); + a !== s?.index && (i = D.nextNode(), a++); } - return k.currentNode = y, r; + return D.currentNode = v, r; } p(e) { let t = 0; for (let n of this._$AV) n !== void 0 && (n.strings === void 0 ? n._$AI(e[t]) : (n._$AI(e, n, t), t += n.strings.length - 2)), t++; } -}, we = class e { +}, A = class e { get _$AU() { return this._$AM?._$AU ?? this._$Cv; } constructor(e, t, n, r) { - this.type = 2, this._$AH = O, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0; + this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0; } get parentNode() { let e = this._$AA.parentNode, t = this._$AM; @@ -378,7 +378,7 @@ var Ce = class { return this._$AB; } _$AI(e, t = this) { - e = A(this, e, t), x(e) ? e === O || e == null || e === "" ? (this._$AH !== O && this._$AR(), this._$AH = O) : e !== this._$AH && e !== D && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? pe(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e); + e = k(this, e, t), b(e) ? e === E || e == null || e === "" ? (this._$AH !== E && this._$AR(), this._$AH = E) : e !== this._$AH && e !== T && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? me(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e); } O(e) { return this._$AA.parentNode.insertBefore(e, this._$AB); @@ -387,30 +387,30 @@ var Ce = class { this._$AH !== e && (this._$AR(), this._$AH = this.O(e)); } _(e) { - this._$AH !== O && x(this._$AH) ? this._$AA.nextSibling.data = e : this.T(y.createTextNode(e)), this._$AH = e; + this._$AH !== E && b(this._$AH) ? this._$AA.nextSibling.data = e : this.T(v.createTextNode(e)), this._$AH = e; } $(e) { - let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = Se.createElement(be(n.h, n.h[0]), this.options)), n); + let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = O.createElement(Se(n.h, n.h[0]), this.options)), n); if (this._$AH?._$AD === r) this._$AH.p(t); else { - let e = new Ce(r, this), n = e.u(this.options); + let e = new we(r, this), n = e.u(this.options); e.p(t), this.T(n), this._$AH = e; } } _$AC(e) { - let t = ye.get(e.strings); - return t === void 0 && ye.set(e.strings, t = new Se(e)), t; + let t = xe.get(e.strings); + return t === void 0 && xe.set(e.strings, t = new O(e)), t; } k(t) { - S(this._$AH) || (this._$AH = [], this._$AR()); + x(this._$AH) || (this._$AH = [], this._$AR()); let n = this._$AH, r, i = 0; - for (let a of t) i === n.length ? n.push(r = new e(this.O(b()), this.O(b()), this, this.options)) : r = n[i], r._$AI(a), i++; + for (let a of t) i === n.length ? n.push(r = new e(this.O(y()), this.O(y()), this, this.options)) : r = n[i], r._$AI(a), i++; i < n.length && (this._$AR(r && r._$AB.nextSibling, i), n.length = i); } _$AR(e = this._$AA.nextSibling, t) { for (this._$AP?.(!1, !0, t); e !== this._$AB;) { - let t = ce(e).nextSibling; - ce(e).remove(), e = t; + let t = le(e).nextSibling; + le(e).remove(), e = t; } } setConnected(e) { @@ -424,41 +424,41 @@ var Ce = class { return this._$AM._$AU; } constructor(e, t, n, r, i) { - this.type = 1, this._$AH = O, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = O; + this.type = 1, this._$AH = E, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = E; } _$AI(e, t = this, n, r) { let i = this.strings, a = !1; - if (i === void 0) e = A(this, e, t, 0), a = !x(e) || e !== this._$AH && e !== D, a && (this._$AH = e); + if (i === void 0) e = k(this, e, t, 0), a = !b(e) || e !== this._$AH && e !== T, a && (this._$AH = e); else { let r = e, o, s; - for (e = i[0], o = 0; o < i.length - 1; o++) s = A(this, r[n + o], t, o), s === D && (s = this._$AH[o]), a ||= !x(s) || s !== this._$AH[o], s === O ? e = O : e !== O && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s; + for (e = i[0], o = 0; o < i.length - 1; o++) s = k(this, r[n + o], t, o), s === T && (s = this._$AH[o]), a ||= !b(s) || s !== this._$AH[o], s === E ? e = E : e !== E && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s; } a && !r && this.j(e); } j(e) { - e === O ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? ""); + e === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? ""); } }, Te = class extends j { constructor() { super(...arguments), this.type = 3; } j(e) { - this.element[this.name] = e === O ? void 0 : e; + this.element[this.name] = e === E ? void 0 : e; } }, Ee = class extends j { constructor() { super(...arguments), this.type = 4; } j(e) { - this.element.toggleAttribute(this.name, !!e && e !== O); + this.element.toggleAttribute(this.name, !!e && e !== E); } }, De = class extends j { constructor(e, t, n, r, i) { super(e, t, n, r, i), this.type = 5; } _$AI(e, t = this) { - if ((e = A(this, e, t, 0) ?? O) === D) return; - let n = this._$AH, r = e === O && n !== O || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== O && (n === O || r); + if ((e = k(this, e, t, 0) ?? E) === T) return; + let n = this._$AH, r = e === E && n !== E || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== E && (n === E || r); r && this.element.removeEventListener(this.name, this, n), i && this.element.addEventListener(this.name, this, e), this._$AH = e; } handleEvent(e) { @@ -472,18 +472,18 @@ var Ce = class { return this._$AM._$AU; } _$AI(e) { - A(this, e); + k(this, e); } -}, ke = se.litHtmlPolyfillSupport; -ke?.(Se, we), (se.litHtmlVersions ??= []).push("3.3.3"); +}, ke = ce.litHtmlPolyfillSupport; +ke?.(O, A), (ce.litHtmlVersions ??= []).push("3.3.3"); var Ae = (e, t, n) => { let r = n?.renderBefore ?? t, i = r._$litPart$; if (i === void 0) { let e = n?.renderBefore ?? null; - r._$litPart$ = i = new we(t.insertBefore(b(), e), e, void 0, n ?? {}); + r._$litPart$ = i = new A(t.insertBefore(y(), e), e, void 0, n ?? {}); } return i._$AI(e), i; -}, M = globalThis, N = class extends g { +}, M = globalThis, N = class extends h { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } @@ -502,7 +502,7 @@ var Ae = (e, t, n) => { super.disconnectedCallback(), this._$Do?.setConnected(!1); } render() { - return D; + return T; } }; N._$litElement$ = !0, N.finalized = !0, M.litElementHydrateSupport?.({ LitElement: N }); @@ -519,7 +519,7 @@ var Me = (e) => (t, n) => { type: String, converter: m, reflect: !1, - hasChanged: h + hasChanged: oe }, Pe = (e = Ne, t, n) => { let { kind: r, metadata: i } = n, a = globalThis.litPropertyMetadata.get(i); if (a === void 0 && globalThis.litPropertyMetadata.set(i, a = /* @__PURE__ */ new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), a.set(n.name, e), r === "accessor") { @@ -636,9 +636,9 @@ var Le = { e.includes("-") || t ? n.setProperty(e, t ? r.slice(0, -11) : r, t ? Be : "") : n[e] = r; } } - return D; + return T; } -}), He = "M7 11H9V13H7V11M21 5V19C21 20.11 20.11 21 19 21H5C3.89 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H6V1H8V3H16V1H18V3H19C20.11 3 21 3.9 21 5M5 7H19V5H5V7M19 19V9H5V19H19M15 13V11H17V13H15M11 13V11H13V13H11M7 15H9V17H7V15M15 17V15H17V17H15M11 17V15H13V17H11Z", Ue = "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z", We = "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z", Ge = "M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z", Ke = "M18.5,4L19.66,8.35L18.7,8.61C18.25,7.74 17.79,6.87 17.26,6.43C16.73,6 16.11,6 15.5,6H13V16.5C13,17 13,17.5 13.33,17.75C13.67,18 14.33,18 15,18V19H9V18C9.67,18 10.33,18 10.67,17.75C11,17.5 11,17 11,16.5V6H8.5C7.89,6 7.27,6 6.74,6.43C6.21,6.87 5.75,7.74 5.3,8.61L4.34,8.35L5.5,4H18.5Z", qe = "M19 8C20.11 8 21 8.9 21 10V16.76C21.61 17.31 22 18.11 22 19C22 20.66 20.66 22 19 22C17.34 22 16 20.66 16 19C16 18.11 16.39 17.31 17 16.76V10C17 8.9 17.9 8 19 8M19 9C18.45 9 18 9.45 18 10V11H20V10C20 9.45 19.55 9 19 9M12 5.69L7 10.19V18H14.1L14 19L14.1 20H5V12H2L12 3L16.4 6.96C15.89 7.4 15.5 7.97 15.25 8.61L12 5.69Z", Je = "M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z", Ye = "M15 16L11 20H21V16H15M12.06 7.19L3 16.25V20H6.75L15.81 10.94L12.06 7.19M5.92 18H5V17.08L12.06 10L13 10.94L5.92 18M18.71 8.04C19.1 7.65 19.1 7 18.71 6.63L16.37 4.29C16.17 4.09 15.92 4 15.66 4C15.41 4 15.15 4.1 14.96 4.29L13.13 6.12L16.88 9.87L18.71 8.04Z", Xe = "M15 13V5A3 3 0 0 0 9 5V13A5 5 0 1 0 15 13M12 4A1 1 0 0 1 13 5V8H11V5A1 1 0 0 1 12 4Z", Ze = "M8 13C6.14 13 4.59 14.28 4.14 16H2V18H4.14C4.59 19.72 6.14 21 8 21S11.41 19.72 11.86 18H22V16H11.86C11.41 14.28 9.86 13 8 13M8 19C6.9 19 6 18.1 6 17C6 15.9 6.9 15 8 15S10 15.9 10 17C10 18.1 9.1 19 8 19M19.86 6C19.41 4.28 17.86 3 16 3S12.59 4.28 12.14 6H2V8H12.14C12.59 9.72 14.14 11 16 11S19.41 9.72 19.86 8H22V6H19.86M16 9C14.9 9 14 8.1 14 7C14 5.9 14.9 5 16 5S18 5.9 18 7C18 8.1 17.1 9 16 9Z", Qe = o` +}), He = "M7 11H9V13H7V11M21 5V19C21 20.11 20.11 21 19 21H5C3.89 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H6V1H8V3H16V1H18V3H19C20.11 3 21 3.9 21 5M5 7H19V5H5V7M19 19V9H5V19H19M15 13V11H17V13H15M11 13V11H13V13H11M7 15H9V17H7V15M15 17V15H17V17H15M11 17V15H13V17H11Z", Ue = "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z", We = "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z", Ge = "M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z", Ke = "M18.5,4L19.66,8.35L18.7,8.61C18.25,7.74 17.79,6.87 17.26,6.43C16.73,6 16.11,6 15.5,6H13V16.5C13,17 13,17.5 13.33,17.75C13.67,18 14.33,18 15,18V19H9V18C9.67,18 10.33,18 10.67,17.75C11,17.5 11,17 11,16.5V6H8.5C7.89,6 7.27,6 6.74,6.43C6.21,6.87 5.75,7.74 5.3,8.61L4.34,8.35L5.5,4H18.5Z", qe = "M19 8C20.11 8 21 8.9 21 10V16.76C21.61 17.31 22 18.11 22 19C22 20.66 20.66 22 19 22C17.34 22 16 20.66 16 19C16 18.11 16.39 17.31 17 16.76V10C17 8.9 17.9 8 19 8M19 9C18.45 9 18 9.45 18 10V11H20V10C20 9.45 19.55 9 19 9M12 5.69L7 10.19V18H14.1L14 19L14.1 20H5V12H2L12 3L16.4 6.96C15.89 7.4 15.5 7.97 15.25 8.61L12 5.69Z", Je = "M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z", Ye = "M15 16L11 20H21V16H15M12.06 7.19L3 16.25V20H6.75L15.81 10.94L12.06 7.19M5.92 18H5V17.08L12.06 10L13 10.94L5.92 18M18.71 8.04C19.1 7.65 19.1 7 18.71 6.63L16.37 4.29C16.17 4.09 15.92 4 15.66 4C15.41 4 15.15 4.1 14.96 4.29L13.13 6.12L16.88 9.87L18.71 8.04Z", Xe = "M15 13V5A3 3 0 0 0 9 5V13A5 5 0 1 0 15 13M12 4A1 1 0 0 1 13 5V8H11V5A1 1 0 0 1 12 4Z", Ze = "M8 13C6.14 13 4.59 14.28 4.14 16H2V18H4.14C4.59 19.72 6.14 21 8 21S11.41 19.72 11.86 18H22V16H11.86C11.41 14.28 9.86 13 8 13M8 19C6.9 19 6 18.1 6 17C6 15.9 6.9 15 8 15S10 15.9 10 17C10 18.1 9.1 19 8 19M19.86 6C19.41 4.28 17.86 3 16 3S12.59 4.28 12.14 6H2V8H12.14C12.59 9.72 14.14 11 16 11S19.41 9.72 19.86 8H22V6H19.86M16 9C14.9 9 14 8.1 14 7C14 5.9 14.9 5 16 5S18 5.9 18 7C18 8.1 17.1 9 16 9Z", Qe = "M12.74,5.47C15.1,6.5 16.35,9.03 15.92,11.46C17.19,12.56 18,14.19 18,16V16.17C18.31,16.06 18.65,16 19,16A3,3 0 0,1 22,19A3,3 0 0,1 19,22H6A4,4 0 0,1 2,18A4,4 0 0,1 6,14H6.27C5,12.45 4.6,10.24 5.5,8.26C6.72,5.5 9.97,4.24 12.74,5.47M11.93,7.3C10.16,6.5 8.09,7.31 7.31,9.07C6.85,10.09 6.93,11.22 7.41,12.13C8.5,10.83 10.16,10 12,10C12.7,10 13.38,10.12 14,10.34C13.94,9.06 13.18,7.86 11.93,7.3M13.55,3.64C13,3.4 12.45,3.23 11.88,3.12L14.37,1.82L15.27,4.71C14.76,4.29 14.19,3.93 13.55,3.64M6.09,4.44C5.6,4.79 5.17,5.19 4.8,5.63L4.91,2.82L7.87,3.5C7.25,3.71 6.65,4.03 6.09,4.44M18,9.71C17.91,9.12 17.78,8.55 17.59,8L19.97,9.5L17.92,11.73C18.03,11.08 18.05,10.4 18,9.71M3.04,11.3C3.11,11.9 3.24,12.47 3.43,13L1.06,11.5L3.1,9.28C3,9.93 2.97,10.61 3.04,11.3M19,18H16V16A4,4 0 0,0 12,12A4,4 0 0,0 8,16H6A2,2 0 0,0 4,18A2,2 0 0,0 6,20H19A1,1 0 0,0 20,19A1,1 0 0,0 19,18Z", $e = o` :host { --odx-blue: var(--primary-color, #03a9f4); --odx-blue-strong: #0086c5; @@ -2198,7 +2198,7 @@ var Le = { } `, L = "https://opendisplay.org/firmware/toolbox/index.html"; `${L}`, `${L}`, `${L}`, `${L}`; -var $e = (e) => e <= 1.6 ? { +var et = (e) => e <= 1.6 ? { landscape: { columns: 1, rows: 1 @@ -2263,11 +2263,11 @@ var $e = (e) => e <= 1.6 ? { nativeOrientation: r >= i ? "landscape" : "portrait", palettes: a === "bw" ? ["bw"] : ["bw", a], defaultPalette: a, - grid: $e(n), + grid: et(n), source: L, connectorPins: o, toolboxId: e -}), et = [ +}), tt = [ R("ep154-200x200", "1.54″ Monochrome · 200×200", 1.54, 200, 200, "bw", [24]), R("ep154-152x152", "1.54″ B/W/R · 152×152", 1.54, 152, 152, "bwr", [24]), R("ep154yr-200x200", "1.54″ B/W/R/Y · 200×200", 1.54, 200, 200, "bwry", [24]), @@ -2298,7 +2298,7 @@ var $e = (e) => e <= 1.6 ? { bwy: "Black / white / yellow", bwry: "Black / white / red / yellow", spectra6: "Spectra 6 · B/W/R/Y/B/G" -}, tt = "https://www.solum-group.com/esl-n-iot/product-lineup/professional-esl/newton-pro", B = "https://opendisplay.org/what-hardware-to-buy.html", V = (e, t, n, r, i, a, o, s, c, l) => ({ +}, nt = "https://www.solum-group.com/esl-n-iot/product-lineup/professional-esl/newton-pro", B = "https://opendisplay.org/what-hardware-to-buy.html", V = (e, t, n, r, i, a, o, s, c, l) => ({ id: e, manufacturer: t, family: "OpenDisplay", @@ -2330,7 +2330,7 @@ var $e = (e) => e <= 1.6 ? { portrait: o }, freezer: s, - source: tt + source: nt }), U = [ H("solum-newton-pro-1-6-v", "Newton Pro 1.6″ V", 1.6, 200, 200, { columns: 1, @@ -2615,8 +2615,8 @@ var $e = (e) => e <= 1.6 ? { columns: 3, rows: 3 }), - ...et -], W = (e) => U.find((t) => t.id === e) ?? U.find((e) => e.id === "solum-newton-pro-5-8") ?? U[0], nt = (e, t) => e.nativeOrientation === t ? { + ...tt +], W = (e) => U.find((t) => t.id === e) ?? U.find((e) => e.id === "solum-newton-pro-5-8") ?? U[0], rt = (e, t) => e.nativeOrientation === t ? { width: e.nativeWidth, height: e.nativeHeight } : { @@ -2632,7 +2632,7 @@ var $e = (e) => e <= 1.6 ? { columnSpan: 1 }); return t; -}, rt = (e, t) => t.row >= e.row && t.row < e.row + e.rowSpan && t.column >= e.column && t.column < e.column + e.columnSpan, it = (e, t, n) => { +}, it = (e, t) => t.row >= e.row && t.row < e.row + e.rowSpan && t.column >= e.column && t.column < e.column + e.columnSpan, at = (e, t, n) => { let r = Math.min(t.row, n.row), i = Math.min(t.column, n.column), a = Math.max(t.row, n.row), o = Math.max(t.column, n.column), s = e.filter((e) => e.row >= r && e.column >= i && e.row + e.rowSpan - 1 <= a && e.column + e.columnSpan - 1 <= o); if ((a - r + 1) * (o - i + 1) !== s.reduce((e, t) => e + t.rowSpan * t.columnSpan, 0) || s.length === 0) return null; let c = s.find((e) => e.widget)?.widget, l = new Set(s.map((e) => e.id)); @@ -2644,7 +2644,7 @@ var $e = (e) => e <= 1.6 ? { columnSpan: o - i + 1, widget: c }]; -}, at = (e, t) => { +}, ot = (e, t) => { let n = e.find((e) => e.id === t); if (!n || n.rowSpan === 1 && n.columnSpan === 1 && !n.label) return e; if (n.rowSpan === 1 && n.columnSpan === 1) return e.map((e) => e.id === t ? { @@ -2663,7 +2663,7 @@ var $e = (e) => e <= 1.6 ? { columnSpan: 1 }); return [...e.filter((e) => e.id !== t), ...r]; -}, ot = (e, t, n, r) => t.columns === n.rows && t.rows === n.columns ? e.map((e) => r === "clockwise" ? { +}, st = (e, t, n, r) => t.columns === n.rows && t.rows === n.columns ? e.map((e) => r === "clockwise" ? { ...e, row: e.column, column: t.rows - e.row - e.rowSpan + 2, @@ -2675,8 +2675,8 @@ var $e = (e) => e <= 1.6 ? { column: e.row, rowSpan: e.columnSpan, columnSpan: e.rowSpan -}) : K(n), q = (e, t) => ({ ...e.grid[t] }), st = "solum-newton-pro-5-8", ct = (e = "Kitchen display") => { - let t = W(st), n = "landscape", r = q(t, n), i = (/* @__PURE__ */ new Date()).toISOString(); +}) : K(n), q = (e, t) => ({ ...e.grid[t] }), ct = "solum-newton-pro-5-8", lt = (e = "Kitchen display") => { + let t = W(ct), n = "landscape", r = q(t, n), i = (/* @__PURE__ */ new Date()).toISOString(); return { id: G(), schemaVersion: 1, @@ -2692,15 +2692,15 @@ var $e = (e) => e <= 1.6 ? { createdAt: i, updatedAt: i }; -}, J = (e, t) => String(e[t] ?? ""), lt = (e, t) => Number(e[t] ?? 0), Y = (e, t = "") => E` +}, J = (e, t) => String(e[t] ?? ""), ut = (e, t) => Number(e[t] ?? 0), Y = (e, t = "") => w` -`, X = (e) => E` +`, X = (e) => w` -`, ut = [ +`, dt = [ { id: "calendar", version: 1, @@ -2818,15 +2818,15 @@ var $e = (e) => e <= 1.6 ? { "Family lunch" ] ].slice(0, n); - return E` + return w`
${Y(He)} ${J(e, "title")} - ${lt(e, "days")} days + ${ut(e, "days")} days
- ${r.map(([e, t, n]) => E` + ${r.map(([e, t, n]) => w`
${e} ${t} @@ -2923,7 +2923,7 @@ var $e = (e) => e <= 1.6 ? { type: "toggle" } ], - render: (e) => E` + render: (e) => w`
${Y(Xe, "Entity state")} ${J(e, "title") || J(e, "entity") || "Choose an entity"} @@ -3016,14 +3016,82 @@ var $e = (e) => e <= 1.6 ? { ] } ], - render: (e) => E` + render: (e) => w`
${J(e, "title")} ${J(e, "text")}
+ ` + }, + { + id: "weather", + version: 2, + name: "Weather", + description: "Current conditions and a daily Home Assistant forecast.", + icon: Qe, + styles: o` + .weather-widget-placeholder { + align-items: center; + justify-content: center; + gap: clamp(4px, 3cqh, 12px); + text-align: center; + } + + .weather-widget-placeholder svg { + width: clamp(24px, min(28cqw, 28cqh), 72px); + height: clamp(24px, min(28cqw, 28cqh), 72px); + } + + .weather-widget-placeholder strong { + font-size: clamp(12px, min(12cqw, 12cqh), 28px); + } + + .weather-widget-placeholder span { + max-width: 90%; + overflow: hidden; + font-size: clamp(8px, min(7cqw, 7cqh), 15px); + text-overflow: ellipsis; + white-space: nowrap; + } +`, + defaults: { + weather: "", + showHumidity: !0, + showFeelsLike: !0, + showForecast: !0 + }, + options: [ + { + key: "weather", + label: "Weather entity", + required: !0, + selector: { entity: { filter: { domain: "weather" } } } + }, + { + key: "showHumidity", + label: "Show humidity", + selector: { boolean: {} } + }, + { + key: "showFeelsLike", + label: "Show feels like", + selector: { boolean: {} } + }, + { + key: "showForecast", + label: "Show forecast", + selector: { boolean: {} } + } + ], + render: (e) => w` +
+ ${Y(Qe, "Weather")} + Weather + ${J(e, "weather") || "Choose a weather entity"} +
` } -], dt = (e) => ut.find((t) => t.id === e), ft = ut.map((e) => e.styles), pt = o` +], ft = (e) => dt.find((t) => t.id === e), pt = dt.map((e) => e.styles), mt = o` .widget { width: 100%; height: 100%; @@ -3076,7 +3144,7 @@ function Z(e, t, n, r) { } //#endregion //#region src/odx-app.ts -var mt = (e) => { +var ht = (e) => { let t = (/* @__PURE__ */ new Date()).toISOString(); return { ...structuredClone(e), @@ -3103,9 +3171,9 @@ var mt = (e) => { } static { this.styles = [ - Qe, - pt, - ...ft + $e, + mt, + ...pt ]; } firstUpdated() { @@ -3142,7 +3210,7 @@ var mt = (e) => { return this.project.regions.find((e) => e.id === this.selectedRegionId); } widgetDefinition(e) { - let t = dt(e), n = this.widgetMetadata.find((t) => t.id === e); + let t = ft(e), n = this.widgetMetadata.find((t) => t.id === e); return !t || !n ? t : { ...t, version: n.version, @@ -3161,7 +3229,7 @@ var mt = (e) => { this.store = e; } currentEntityStateSignature() { - return this.store.projects.length ? this.project.regions.flatMap((e) => e.widget?.type === "entity-state" ? [String(e.widget.config.entity ?? "")] : []).filter(Boolean).sort().map((e) => { + return this.store.projects.length ? this.project.regions.flatMap((e) => e.widget?.type === "entity-state" ? [String(e.widget.config.entity ?? "")] : e.widget?.type === "weather" ? [String(e.widget.config.weather ?? "")] : []).filter(Boolean).sort().map((e) => { let t = this.hass.states?.[e]; return `${e}:${t?.state ?? ""}:${t?.last_updated ?? ""}`; }).join("|") : ""; @@ -3263,7 +3331,7 @@ var mt = (e) => { }), this.previewHtml = "", this.schedulePreview(0); } async addProject() { - let e = ct(`Untitled display ${this.store.projects.length + 1}`); + let e = lt(`Untitled display ${this.store.projects.length + 1}`); try { let t = (await this.hass.callWS({ type: "opendisplay_studio/create_project", @@ -3279,7 +3347,7 @@ var mt = (e) => { } } async duplicateProject() { - let e = mt(this.project), t = (await this.hass.callWS({ + let e = ht(this.project), t = (await this.hass.callWS({ type: "opendisplay_studio/create_project", project: e })).project; @@ -3321,7 +3389,7 @@ var mt = (e) => { let n = W(e), r = q(n, this.canvasProject.orientation), i = r.columns === this.canvasProject.grid.columns && r.rows === this.canvasProject.grid.rows, a = this.canvasProject.regions.flatMap((e) => e.widget ? [e.widget] : []), o = i ? this.canvasProject.regions : K(r).map((e, t) => ({ ...e, widget: a[t] - })), s = nt(n, this.canvasProject.orientation); + })), s = rt(n, this.canvasProject.orientation); this.updateLayoutDraft((i) => ({ ...i, displayId: e, @@ -3357,10 +3425,10 @@ var mt = (e) => { let t = this.canvasProject.displayId === "custom" ? { columns: this.canvasProject.grid.rows, rows: this.canvasProject.grid.columns - } : q(this.canvasDisplay, e), n = e === "portrait" ? "clockwise" : "counterclockwise", r = ot(this.canvasProject.regions, this.canvasProject.grid, t, n), i = this.canvasProject.displayId === "custom" ? { + } : q(this.canvasDisplay, e), n = e === "portrait" ? "clockwise" : "counterclockwise", r = st(this.canvasProject.regions, this.canvasProject.grid, t, n), i = this.canvasProject.displayId === "custom" ? { width: this.canvasProject.height, height: this.canvasProject.width - } : nt(this.canvasDisplay, e); + } : rt(this.canvasDisplay, e); this.updateLayoutDraft((n) => ({ ...n, orientation: e, @@ -3399,7 +3467,7 @@ var mt = (e) => { }); } selectMergeCell(e) { - let t = this.canvasProject.regions.find((t) => rt(t, e)); + let t = this.canvasProject.regions.find((t) => it(t, e)); if (t && (t.label || t.rowSpan > 1 || t.columnSpan > 1)) return; if (!this.mergeAnchor) { this.mergeAnchor = e, this.mergeHover = e; @@ -3409,7 +3477,7 @@ var mt = (e) => { this.mergeAnchor = void 0, this.mergeHover = void 0, this.showToast("Remove the existing region before drawing across it"); return; } - let n = it(this.canvasProject.regions, this.mergeAnchor, e); + let n = at(this.canvasProject.regions, this.mergeAnchor, e); if (!n) { this.mergeAnchor = void 0, this.mergeHover = void 0, this.showToast("The selected rectangle crosses an existing merged region"); return; @@ -3429,7 +3497,7 @@ var mt = (e) => { let t = this.canvasProject.regions.find((t) => t.id === e); !t || t.rowSpan === 1 && t.columnSpan === 1 && !t.label || (this.updateLayoutDraft((t) => ({ ...t, - regions: at(t.regions, e) + regions: ot(t.regions, e) })), this.selectedRegionId = "", this.mergeAnchor = void 0, this.mergeHover = void 0, this.showToast("Region removed")); } assignWidget(e) { @@ -3472,7 +3540,7 @@ var mt = (e) => { })); } renderProjectRail() { - return E` + return w`
""" +WEATHER_TEMPLATE: Final = (TEMPLATE_DIRECTORY / "weather.liquid").read_text( + encoding="utf-8" +) + TEMPLATES: Final = { "entity-state": ENTITY_TEMPLATE, "calendar": CALENDAR_TEMPLATE, + "weather": WEATHER_TEMPLATE, "text": TEXT_TEMPLATE, } diff --git a/frontend-src/src/odx-app.ts b/frontend-src/src/odx-app.ts index e6766b7..1a71df0 100644 --- a/frontend-src/src/odx-app.ts +++ b/frontend-src/src/odx-app.ts @@ -191,9 +191,15 @@ export class OdxApp extends LitElement { private currentEntityStateSignature(): string { if (!this.store.projects.length) return '' return this.project.regions - .flatMap((region) => region.widget?.type === 'entity-state' - ? [String(region.widget.config.entity ?? '')] - : []) + .flatMap((region) => { + if (region.widget?.type === 'entity-state') { + return [String(region.widget.config.entity ?? '')] + } + if (region.widget?.type === 'weather') { + return [String(region.widget.config.weather ?? '')] + } + return [] + }) .filter(Boolean) .sort() .map((entityId) => { diff --git a/frontend-src/src/widgets/registry.ts b/frontend-src/src/widgets/registry.ts index c13ce59..6638a46 100644 --- a/frontend-src/src/widgets/registry.ts +++ b/frontend-src/src/widgets/registry.ts @@ -1,11 +1,13 @@ import { calendarWidget } from './calendar/widget' import { entityValueWidget } from './entity-value/widget' import { textNoteWidget } from './text-note/widget' +import { weatherWidget } from './weather/widget' export const WIDGETS = [ calendarWidget, entityValueWidget, textNoteWidget, + weatherWidget, ] export const getWidgetDefinition = (id: string) => diff --git a/frontend-src/src/widgets/weather/styles.ts b/frontend-src/src/widgets/weather/styles.ts new file mode 100644 index 0000000..d6527a4 --- /dev/null +++ b/frontend-src/src/widgets/weather/styles.ts @@ -0,0 +1,27 @@ +import { css } from 'lit' + +export const weatherStyles = css` + .weather-widget-placeholder { + align-items: center; + justify-content: center; + gap: clamp(4px, 3cqh, 12px); + text-align: center; + } + + .weather-widget-placeholder svg { + width: clamp(24px, min(28cqw, 28cqh), 72px); + height: clamp(24px, min(28cqw, 28cqh), 72px); + } + + .weather-widget-placeholder strong { + font-size: clamp(12px, min(12cqw, 12cqh), 28px); + } + + .weather-widget-placeholder span { + max-width: 90%; + overflow: hidden; + font-size: clamp(8px, min(7cqw, 7cqh), 15px); + text-overflow: ellipsis; + white-space: nowrap; + } +` diff --git a/frontend-src/src/widgets/weather/widget.ts b/frontend-src/src/widgets/weather/widget.ts new file mode 100644 index 0000000..0cac88a --- /dev/null +++ b/frontend-src/src/widgets/weather/widget.ts @@ -0,0 +1,38 @@ +import { html } from 'lit' +import { mdiWeatherPartlyCloudy } from '@mdi/js' +import type { WidgetDefinition } from '../../types' +import { configText, renderIcon } from '../shared' +import { weatherStyles } from './styles' + +export const weatherWidget: WidgetDefinition = { + id: 'weather', + version: 2, + name: 'Weather', + description: 'Current conditions and a daily Home Assistant forecast.', + icon: mdiWeatherPartlyCloudy, + styles: weatherStyles, + defaults: { + weather: '', + showHumidity: true, + showFeelsLike: true, + showForecast: true, + }, + options: [ + { + key: 'weather', + label: 'Weather entity', + required: true, + selector: { entity: { filter: { domain: 'weather' } } }, + }, + { key: 'showHumidity', label: 'Show humidity', selector: { boolean: {} } }, + { key: 'showFeelsLike', label: 'Show feels like', selector: { boolean: {} } }, + { key: 'showForecast', label: 'Show forecast', selector: { boolean: {} } }, + ], + render: (config) => html` +
+ ${renderIcon(mdiWeatherPartlyCloudy, 'Weather')} + Weather + ${configText(config, 'weather') || 'Choose a weather entity'} +
+ `, +} diff --git a/tests/test_composer.py b/tests/test_composer.py index 3b1fb64..337811c 100644 --- a/tests/test_composer.py +++ b/tests/test_composer.py @@ -27,6 +27,9 @@ def test_requirement_contract_supports_many_and_optional_sources() -> None: ) == ["sensor.office", "sensor.kitchen"] assert definition("text")["dataRequirements"] == [] assert definition("entity-state")["dataRequirements"][0]["optional"] is False + weather = definition("weather") + assert weather["fields"][0]["selector"]["entity"]["filter"]["domain"] == ("weather") + assert weather["dataRequirements"][0]["provider"] == "weather_forecast" def test_entity_tile_shape_uses_physical_region_ratio() -> None: @@ -124,3 +127,52 @@ async def test_provider_error_is_exposed_as_compose_error(hass) -> None: pytest.raises(ProjectComposeError), ): await async_compose_project(hass, project) + + +async def test_weather_widget_renders_normalized_home_assistant_data(hass) -> None: + project = { + "palette": "bw", + "width": 190, + "height": 228, + "grid": {"columns": 1, "rows": 1}, + "regions": [ + { + "id": "weather", + "row": 1, + "column": 1, + "rowSpan": 1, + "columnSpan": 1, + "widget": { + "type": "weather", + "version": 2, + "config": {"weather": "weather.home"}, + }, + } + ], + } + weather = { + "weather.home": { + "entity_id": "weather.home", + "name": "Home", + "condition": "rainy", + "condition_label": "Rain", + "icon": "https://trmnl.com/images/plugins/weather/wi-rain.svg", + "temperature": 12, + "temperature_unit": "°C", + "apparent_temperature": 9, + "humidity": 88, + "updated_at": "08:15", + "forecast": [], + } + } + + with patch( + "custom_components.opendisplay_studio.composer.WeatherForecastProvider.async_get_many", + AsyncMock(return_value=weather), + ) as get_many: + result = await async_compose_project(hass, project) + + get_many.assert_awaited_once_with({"weather.home"}) + assert "od-weather" in result.html + assert "12°" in result.html + assert "08:15" in result.html diff --git a/tests/test_projects.py b/tests/test_projects.py index 82572cb..3c77a94 100644 --- a/tests/test_projects.py +++ b/tests/test_projects.py @@ -52,6 +52,46 @@ def test_validation_rejects_overlapping_regions() -> None: validate_project(payload) +def test_weather_widget_config_is_normalized() -> None: + payload = project_payload() + payload["regions"][0]["widget"] = { + "type": "weather", + "version": 2, + "config": { + "weather": "weather.home", + "showHumidity": False, + "showFeelsLike": True, + "showForecast": True, + }, + } + + result = validate_project(payload) + + assert result["regions"][0]["widget"] == { + "type": "weather", + "version": 2, + "config": { + "weather": "weather.home", + "showHumidity": False, + "showFeelsLike": True, + "showForecast": True, + }, + } + + +def test_ready_weather_widget_requires_weather_entity() -> None: + payload = project_payload() + payload["status"] = "ready" + payload["regions"][0]["widget"] = { + "type": "weather", + "version": 2, + "config": {"weather": "sensor.outdoor_temperature"}, + } + + with pytest.raises(ProjectValidationError, match="weather entity"): + validate_project(payload) + + async def test_project_identity_survives_rename_and_ready(hass) -> None: store = ProjectStore(hass) with patch.object(store._store, "async_save", AsyncMock()): From 71d002c6e1863fc05d0abef4a7527e8edb6604f9 Mon Sep 17 00:00:00 2001 From: Misiu Date: Wed, 26 Aug 2026 11:39:38 +0200 Subject: [PATCH 3/4] Release version 0.3.3 --- CHANGELOG.md | 2 ++ custom_components/opendisplay_studio/const.py | 2 +- custom_components/opendisplay_studio/manifest.json | 2 +- frontend-src/package-lock.json | 4 ++-- frontend-src/package.json | 2 +- pyproject.toml | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c116c3b..205ac4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.3.3 + - Add the adaptive Weather widget with a native Home Assistant weather entity selector and live designer preview. - Resolve current conditions from entity state and daily forecasts through diff --git a/custom_components/opendisplay_studio/const.py b/custom_components/opendisplay_studio/const.py index e6d6701..8588c1f 100644 --- a/custom_components/opendisplay_studio/const.py +++ b/custom_components/opendisplay_studio/const.py @@ -6,7 +6,7 @@ DOMAIN = "opendisplay_studio" NAME = "OpenDisplay Studio" -INTEGRATION_VERSION = "0.3.2" +INTEGRATION_VERSION = "0.3.3" API_VERSION = 1 DEFAULT_WIDTH = 800 diff --git a/custom_components/opendisplay_studio/manifest.json b/custom_components/opendisplay_studio/manifest.json index d38d857..af6d0a1 100644 --- a/custom_components/opendisplay_studio/manifest.json +++ b/custom_components/opendisplay_studio/manifest.json @@ -11,5 +11,5 @@ "issue_tracker": "https://github.com/Misiu/OpenDisplay-Studio-Integration/issues", "requirements": ["python-liquid==2.3.1"], "single_config_entry": true, - "version": "0.3.2" + "version": "0.3.3" } diff --git a/frontend-src/package-lock.json b/frontend-src/package-lock.json index 661e0cf..38c8534 100644 --- a/frontend-src/package-lock.json +++ b/frontend-src/package-lock.json @@ -1,12 +1,12 @@ { "name": "opendisplay-studio-ha-panel", - "version": "0.3.2", + "version": "0.3.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "opendisplay-studio-ha-panel", - "version": "0.3.2", + "version": "0.3.3", "dependencies": { "@mdi/js": "^7.4.47", "lit": "^3.3.3" diff --git a/frontend-src/package.json b/frontend-src/package.json index 38aaf1e..8399f48 100644 --- a/frontend-src/package.json +++ b/frontend-src/package.json @@ -1,7 +1,7 @@ { "name": "opendisplay-studio-ha-panel", "private": true, - "version": "0.3.2", + "version": "0.3.3", "type": "module", "scripts": { "dev": "vite build --watch", diff --git a/pyproject.toml b/pyproject.toml index 098126f..5066687 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "opendisplay-studio-integration" -version = "0.3.2" +version = "0.3.3" requires-python = ">=3.14.2" [tool.pytest.ini_options] From f4f36c556dd7a8b77dd8d7948df1e25a4f1abce8 Mon Sep 17 00:00:00 2001 From: Misiu Date: Wed, 26 Aug 2026 11:42:47 +0200 Subject: [PATCH 4/4] Fix release validation tests --- tests/test_data_providers.py | 4 ++-- tests/test_release_version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_data_providers.py b/tests/test_data_providers.py index 884f94b..41e241f 100644 --- a/tests/test_data_providers.py +++ b/tests/test_data_providers.py @@ -62,7 +62,7 @@ async def test_weather_provider_combines_entity_state_and_daily_forecast(hass) - } with patch.object( - hass.services, + type(hass.services), "async_call", AsyncMock(return_value=service_response), ) as async_call: @@ -121,7 +121,7 @@ async def test_weather_provider_uses_explicit_nulls_for_optional_values(hass) -> } with patch.object( - hass.services, + type(hass.services), "async_call", AsyncMock(return_value=service_response), ): diff --git a/tests/test_release_version.py b/tests/test_release_version.py index c66461b..cdccc25 100644 --- a/tests/test_release_version.py +++ b/tests/test_release_version.py @@ -23,7 +23,7 @@ def test_release_rejects_mismatch(tmp_path) -> None: def test_panel_build_version_matches_release() -> None: - assert INTEGRATION_VERSION == "0.3.2" + assert INTEGRATION_VERSION == "0.3.3" def test_panel_does_not_bundle_home_assistant_component_implementations() -> None: