Skip to content

Commit fa32afd

Browse files
committed
Add Home Assistant Studio designer
1 parent 841c554 commit fa32afd

49 files changed

Lines changed: 11928 additions & 56 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/validate.yml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ jobs:
2626
- run: mypy custom_components/opendisplay_studio scripts
2727
- run: pytest
2828

29+
frontend:
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: frontend-src
34+
steps:
35+
- uses: actions/checkout@v7
36+
- uses: actions/setup-node@v6
37+
with:
38+
node-version: "24"
39+
cache: npm
40+
cache-dependency-path: frontend-src/package-lock.json
41+
- run: npm ci
42+
- run: npm test
43+
- run: npm run build
44+
- name: Verify committed panel bundle
45+
working-directory: .
46+
run: git diff --exit-code -- custom_components/opendisplay_studio/frontend/opendisplay-studio.js
47+
2948
hassfest:
3049
runs-on: ubuntu-latest
3150
steps:

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ __pycache__/
66
htmlcov/
77
*.pyc
88
.DS_Store
9+
frontend-src/node_modules/

‎ARCHITECTURE.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,27 @@ not yet use `system_managed` or `system_managed_config_entry`; Core issue
5151
[#174919](https://github.com/home-assistant/core/issues/174919) still tracks
5252
complete `AddonManager` support. The stored ownership flag leaves a migration
5353
path without making the POC depend on incomplete behavior.
54+
55+
## Stage 3 designer and render boundary
56+
57+
The bundled Lit panel is derived from the accepted `Misiu/odx` POC. It edits a
58+
local draft for responsive interactions, but Home Assistant's versioned
59+
`Store` is authoritative. Admin-only WebSocket commands create, update, list,
60+
and delete projects; stable IDs are always generated by the backend.
61+
62+
Ready projects are the only items returned by the Media Source. Resolving one
63+
compiles widget-declared data requirements, deduplicates sources across the
64+
whole screen, invokes Home Assistant-aware providers, renders Liquid fragments,
65+
and composes a single TRMNL document. The Renderer App contract remains
66+
`HTML + width + height -> PNG` and contains no project or HA concepts.
67+
68+
Panel registration follows the current Core Dynalite pattern: local static
69+
files, WebSocket commands, and an admin-only custom panel. Persistence uses
70+
`homeassistant.helpers.storage.Store` with atomic writes.
71+
72+
References:
73+
74+
- [Dynalite panel](https://github.com/home-assistant/core/blob/dev/homeassistant/components/dynalite/panel.py)
75+
- [Store helper](https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/storage.py)
76+
- [WebSocket decorators](https://github.com/home-assistant/core/blob/dev/homeassistant/components/websocket_api/decorators.py)
77+
- [Calendar integration](https://github.com/home-assistant/core/tree/dev/homeassistant/components/calendar)

‎CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 0.3.0
4+
5+
- Move the accepted ODX designer into an admin-only Home Assistant panel.
6+
- Add server-owned project IDs, versioned HA storage, Draft/Ready lifecycle,
7+
predefined/custom displays, editable grids, and graphical regions.
8+
- Add schema-driven Entity State, Calendar, and Text widget configuration with
9+
Home Assistant entity selectors.
10+
- Add declarative one/many/optional data requirements, deduplicated Entity State
11+
and Calendar providers, normalized widget data, and one-page Liquid/TRMNL
12+
composition.
13+
- Expose every Ready project at a stable dynamic Media Source URI.
14+
- Add frontend CI, TypeScript checks, Vitest coverage, and committed local panel
15+
bundle verification.
16+
317
## 0.2.0
418

519
- Add bounded Liquid processing before the Renderer call with separate timing.

‎README.md‎

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# OpenDisplay Studio Integration
22

3-
Home Assistant custom integration proving that renderable OpenDisplay Studio
4-
documents can be exposed as dynamic image Media Sources.
3+
Home Assistant custom integration with an ODX-derived graphical e-paper
4+
designer. Ready projects are dynamic image Media Sources rendered from current
5+
Home Assistant data.
56

67
[![Add the Renderer App repository to Home Assistant](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FMisiu%2FOpenDisplay-Studio-App)
78
[![Open this integration in HACS](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=Misiu&repository=OpenDisplay-Studio-Integration&category=integration)
89
[![Add OpenDisplay Studio to Home Assistant](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=opendisplay_studio)
910

10-
Stage 2 exposes ten dynamic Media Sources, including:
11-
12-
- `media-source://opendisplay_studio/test`
13-
- `media-source://opendisplay_studio/dashboard`
14-
- `media-source://opendisplay_studio/trmnl_typography`
15-
- `media-source://opendisplay_studio/trmnl_table`
16-
- `media-source://opendisplay_studio/trmnl_liquid`
17-
- `media-source://opendisplay_studio/trmnl_palette_bw`
18-
- `media-source://opendisplay_studio/trmnl_palette_bwr`
19-
- `media-source://opendisplay_studio/trmnl_palette_bwry`
20-
- `media-source://opendisplay_studio/trmnl_small`
21-
- `media-source://opendisplay_studio/trmnl_large`
22-
23-
Every resolution renders fresh HTML through the separate OpenDisplay Studio
24-
Renderer App and exposes the PNG through a short-lived, unguessable Home
25-
Assistant URL. The integration generates all final HTML, including Liquid
26-
processing and dynamic Home Assistant-local timestamps. The Renderer App only
27-
accepts final HTML and dimensions.
28-
29-
The catalog covers 296 x 128, 800 x 480, and 1200 x 825, plus BW, BWR, and
30-
BWRY Framework modes. See [Stage 2 compatibility](STAGE2_COMPATIBILITY.md) for
31-
the exact Liquid/TRMNL subset and known gaps.
11+
Open **OpenDisplay Studio** in the Home Assistant sidebar to create predefined
12+
or custom displays, edit their logical grids, compose rectangular regions, and
13+
assign Entity State, Calendar, or Text widgets. Project configuration is stored
14+
with Home Assistant's versioned `Store`; browser `localStorage` is not used.
15+
16+
Draft projects remain private to the designer. A Ready project is exposed at a
17+
stable URI based on its immutable server-generated ID:
18+
19+
```text
20+
media-source://opendisplay_studio/<project-id>
21+
```
22+
23+
On every resolution the integration deduplicates widget data requirements,
24+
reads current entity states and calendar events, renders widget Liquid
25+
templates, composes one TRMNL Framework document, and sends that final HTML to
26+
the Renderer. The Renderer App still knows only HTML, width, and height.
27+
28+
See [the widget contract](WIDGET_CONTRACT.md) for the schema/data/template
29+
boundary and the planned multi-entity Table and optional-source Weather model.
30+
See [Stage 2 compatibility](STAGE2_COMPATIBILITY.md) for the Liquid/TRMNL
31+
compatibility baseline retained by Stage 3.
3232

3333
## Home Assistant OS / Supervised installation
3434

@@ -84,6 +84,11 @@ ruff check .
8484
ruff format --check .
8585
mypy custom_components/opendisplay_studio scripts
8686
pytest
87+
88+
cd frontend-src
89+
npm ci
90+
npm test
91+
npm run build
8792
```
8893

8994
## License

‎WIDGET_CONTRACT.md‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# OpenDisplay Studio widget contract
2+
3+
Each widget definition owns four independent concerns:
4+
5+
```text
6+
identity and version
7+
configuration fields
8+
data requirements
9+
Liquid template
10+
```
11+
12+
The panel builds controls from `fields`. Home Assistant-aware field types
13+
currently include `entity` and `calendar`; the contract already represents an
14+
`entities` multi-selector for future widgets. Configuration stores references,
15+
never current values.
16+
17+
Data requirements are declarative. A requirement names its provider, the
18+
configuration key containing its source, whether the source has cardinality
19+
`one` or `many`, and whether it is optional. Range-based providers may name a
20+
second configuration key such as Calendar's `days`.
21+
22+
Example current Entity State requirement:
23+
24+
```json
25+
{
26+
"key": "entity",
27+
"provider": "entity_state",
28+
"configKey": "entity",
29+
"cardinality": "one",
30+
"optional": false
31+
}
32+
```
33+
34+
The composer aggregates every region before providers run. Two widgets asking
35+
for the same entity cause one state-machine lookup. Calendar requests for the
36+
same entity use the largest requested range, then each widget receives only its
37+
configured presentation range.
38+
39+
## Future Table
40+
41+
A Table can use ordinary presentation fields plus a multi-entity requirement:
42+
43+
```json
44+
{
45+
"fields": [
46+
{ "key": "entities", "type": "entities", "label": "Rows" },
47+
{ "key": "nameColumn", "type": "text", "label": "First column" },
48+
{ "key": "valueColumn", "type": "text", "label": "Second column" }
49+
],
50+
"dataRequirements": [
51+
{
52+
"key": "rows",
53+
"provider": "entity_state",
54+
"configKey": "entities",
55+
"cardinality": "many",
56+
"optional": false
57+
}
58+
]
59+
}
60+
```
61+
62+
Its normalized Liquid context can then contain five room-temperature rows
63+
without exposing the full Home Assistant state machine.
64+
65+
## Future Weather
66+
67+
Weather can declare a required forecast source and a second optional current
68+
temperature sensor. Both are resolved at render time:
69+
70+
```json
71+
{
72+
"dataRequirements": [
73+
{
74+
"key": "forecast",
75+
"provider": "weather_forecast",
76+
"configKey": "weather",
77+
"cardinality": "one",
78+
"optional": false
79+
},
80+
{
81+
"key": "externalTemperature",
82+
"provider": "entity_state",
83+
"configKey": "temperatureEntity",
84+
"cardinality": "one",
85+
"optional": true
86+
}
87+
]
88+
}
89+
```
90+
91+
Adding that widget requires a `WeatherProvider` and its definition/template;
92+
it does not change project storage, Media Source identity, the frontend/backend
93+
transport, or the Renderer API.

‎custom_components/opendisplay_studio/__init__.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
RENDER_CACHE_TTL_SECONDS,
3131
)
3232
from .http import RenderedImageView
33+
from .panel import async_register_panel
34+
from .projects import ProjectStore
3335
from .renderer import (
3436
RendererClient,
3537
RendererError,
3638
RendererHealth,
3739
)
40+
from .websocket import async_register_commands
3841

3942

4043
@dataclass(slots=True)
@@ -52,6 +55,7 @@ class OpenDisplayStudioData:
5255
"""Domain-wide state."""
5356

5457
cache: RenderCache
58+
projects: ProjectStore
5559

5660

5761
type OpenDisplayStudioConfigEntry = ConfigEntry[OpenDisplayStudioRuntimeData]
@@ -60,14 +64,19 @@ class OpenDisplayStudioData:
6064

6165

6266
async def async_setup(hass: HomeAssistant, _config: ConfigType) -> bool:
63-
"""Set up the temporary render endpoint once."""
67+
"""Set up storage, panel APIs, and the temporary render endpoint."""
68+
projects = ProjectStore(hass)
69+
await projects.async_load()
6470
hass.data[DOMAIN] = OpenDisplayStudioData(
6571
cache=RenderCache(
6672
ttl_seconds=RENDER_CACHE_TTL_SECONDS,
6773
max_items=RENDER_CACHE_MAX_ITEMS,
68-
)
74+
),
75+
projects=projects,
6976
)
7077
hass.http.register_view(RenderedImageView(hass))
78+
async_register_commands(hass)
79+
await async_register_panel(hass)
7180
return True
7281

7382

0 commit comments

Comments
 (0)