Add 3D roof view card for optimizer power

The integration now serves solaredge-roof-card and loads it in every
frontend session. The card shows the building in 3D with the current
power in W and the Panel-Position on every panel; the colour runs from
dark (0 W) to bright (Skalenmaximum, default 460 W). Failed panels are
grey and hatched, a tap opens the more-info dialog.

scripts/convert_portal_layout.py turns the SolarEdge portal's physical
layout and site model into the card's layout once, so nothing depends
on the portal at runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jensandClaude Opus 5.5 committed 2026-11-19 13:25:47 +01:00
1 parent ec6ec30dff
commit ce03c05d84
23 files changed
+22051 -5

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
# Glossary
## Photovoltaik
**Panel**
Ein Solarmodul samt dem SolarEdge-Optimizer darunter, als eine Einheit betrachtet. Jedes Panel liefert eine eigene Leistung.
_Avoid_: Modul, Optimizer (wenn das Ganze gemeint ist)
**Panel-Position**
Die Kennung eines Panels in der Form Wechselrichter.String.Modul, z. B. `1.2.7`.
_Avoid_: Optimizer-ID, Seriennummer
**Dachfläche**
Eine zusammenhängende, gleich geneigte und gleich ausgerichtete Fläche, auf der Panels liegen (west1, west2, gaube, süd, ost1, ost2). In der Integration `solaredge_optimizers` heißt sie „Area“.
_Avoid_: Area, Feld, Teilfläche
**Aktuelle Leistung**
Die zuletzt gemessene Leistung eines Panels in Watt. Sie ist bis zu 10 Minuten alt, weil das Portal nicht häufiger abgefragt wird.
_Avoid_: Echtzeitwert, Ertrag (das ist Energie in Wh)
**Skalenmaximum**
Die Leistung, bei der ein Panel in der Dachansicht die hellste Farbe erreicht. Sie ist einstellbar und nicht dasselbe wie die Nennleistung des Moduls.
_Avoid_: Peak, Wp, Maximalleistung
**Ausgefallenes Panel**
Ein Panel, dessen Optimizer keinen Wert liefert. Das ist nicht dasselbe wie ein Panel, das 0 W meldet, etwa nachts.
_Avoid_: inaktives Panel, Panel mit 0 W
+57
View File
@@ -87,6 +87,52 @@ Flächen werden beim Speichern abgewiesen. Für Site `4886699` sind `west1`,
`west2`, `gaube`, `süd`, `ost1` und `ost2` bereits als Startwert hinterlegt.
Mit `{}` können alle Flächensensoren deaktiviert werden.
## Dachansicht (solaredge-roof-card)
Die Integration bringt eine Lovelace-Karte mit, die das Gebäude in 3D zeigt.
Auf jedem Panel stehen die aktuelle Leistung in W und die Panel-Position. Die
Integration lädt die Karte beim Start selbst; eine Dashboard-Ressource ist
nicht nötig.
- Die Farbe läuft von dunkel (0 W) bis hell (`max_power`, Standard 460 W).
- Ausgefallene Panels (kein Wert oder mehr als 30 Minuten älter als die neueste
Messung) sind grau schraffiert mit rotem Rand.
- Ein Tipp auf ein Panel öffnet den Detaildialog der Leistungsentität.
- „Stand“ ist der Zeitpunkt der neuesten Messung.
Die Karte findet die Entitäten über das Attribut `optimizer_id`. Die Geometrie
steht in der Kartenkonfiguration:
```yaml
type: custom:solaredge-roof-card
title: Dach # optional
max_power: 460 # optional, Skalenmaximum in W
layout:
roofs:
- name: west1
outline: [[x, y, z], ...] # Meter, x = Ost, y = Nord, z = Höhe
panels:
- id: "1.1.1"
roof: west1
corners: [[x, y, z], ...] # unten links, unten rechts, oben rechts, oben links
```
### Layout aus dem SolarEdge-Portal erzeugen
Das Portal liefert unter
`GET /services/layout/physical/site/{siteId}` das physische Layout. Dessen
`awsJsonModelDownloadLink` zeigt auf das 3D-Modell, das das Portal selbst
rendert. Beide Dokumente einmalig speichern (z. B. mit dem Portal-Client aus
`solaredge-optimizers/packages/solaredgeapi`) und umrechnen:
```shell
python scripts/convert_portal_layout.py physical.json model.json \
--areas areas.json > card.yaml
```
`areas.json` hat dasselbe Format wie die Flächen-Zuordnung und benennt die
Dachflächen. Die Ausgabe ist die vollständige Kartenkonfiguration.
## Entwicklung
```shell
@@ -94,3 +140,14 @@ uv sync
uv run ruff check .
uv run pytest
```
Die Karte liegt unter `frontend/`. Das gebaute Bundle in
`custom_components/solaredge_optimizers/frontend/` wird mit eingecheckt, damit
die Installation ohne Build auskommt:
```shell
cd frontend
bun install
bun run test
bun run build
```
@@ -7,8 +7,10 @@ from datetime import timedelta
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType
from .api import SolarEdgeOptimizerApiClient
from .const import (
@@ -19,11 +21,19 @@ from .const import (
LOGGER,
)
from .coordinator import SolarEdgeOptimizerCoordinator
from .frontend import async_register_card
PLATFORMS = [Platform.SENSOR]
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
type SolarEdgeOptimizerConfigEntry = ConfigEntry[SolarEdgeOptimizerCoordinator]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Serve the solaredge-roof-card."""
await async_register_card(hass)
return True
async def async_migrate_entry(
hass: HomeAssistant, entry: SolarEdgeOptimizerConfigEntry
) -> bool:
@@ -0,0 +1,35 @@
"""Serve the solaredge-roof-card from the integration."""
from __future__ import annotations
import hashlib
from pathlib import Path
from homeassistant.components.frontend import add_extra_js_url
from homeassistant.components.http import StaticPathConfig
from homeassistant.core import HomeAssistant
from .const import DOMAIN, LOGGER
CARD_FILE = Path(__file__).parent / "frontend" / "solaredge-roof-card.js"
CARD_URL = f"/{DOMAIN}/solaredge-roof-card.js"
def _file_hash(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()[:12]
async def async_register_card(hass: HomeAssistant) -> None:
"""Serve the card and load it in every frontend session."""
if hass.http is None or "frontend" not in hass.config.components:
LOGGER.debug("Frontend not loaded, solaredge-roof-card is not registered")
return
if not CARD_FILE.is_file():
LOGGER.warning("solaredge-roof-card bundle missing at %s", CARD_FILE)
return
version = await hass.async_add_executor_job(_file_hash, CARD_FILE)
await hass.http.async_register_static_paths(
[StaticPathConfig(CARD_URL, str(CARD_FILE), cache_headers=True)]
)
# The hash in the URL makes browsers load a new bundle after an update.
add_extra_js_url(hass, f"{CARD_URL}?v={version}")
File diff suppressed because it is too large. Load diff
@@ -1,12 +1,18 @@
{
"domain": "solaredge_optimizers",
"name": "SolarEdge Optimizers",
"codeowners": ["@jensneuber"],
"codeowners": [
"@jensneuber"
],
"after_dependencies": [
"frontend",
"http"
],
"config_flow": true,
"documentation": "https://git.jensneuber.de/jens/ha-solaredge-optimizers",
"integration_type": "hub",
"iot_class": "local_polling",
"issue_tracker": "https://git.jensneuber.de/jens/ha-solaredge-optimizers/issues",
"requirements": [],
"version": "0.4.0"
"version": "0.5.0"
}
+1
View File
@@ -0,0 +1 @@
node_modules/
+241
View File
@@ -0,0 +1,241 @@
{
"lockfileVersion": 2,
"configVersion": 1,
"workspaces": {
"": {
"name": "solaredge-roof-card",
"dependencies": {
"three": "0.180.0",
},
"devDependencies": {
"@types/three": "0.180.0",
"typescript": "5.9.3",
"vite": "7.1.12",
"vitest": "3.2.4",
},
},
},
"packages": {
"@dimforge/rapier3d-compat": ["@dimforge/rapier3d-compat@0.12.0", "", {}, "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow=="],
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.12", "", { "os": "aix", "cpu": "ppc64" }, "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA=="],
"@esbuild/android-arm": ["@esbuild/android-arm@0.25.12", "", { "os": "android", "cpu": "arm" }, "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg=="],
"@esbuild/android-arm64": ["@esbuild/android-arm64@0.25.12", "", { "os": "android", "cpu": "arm64" }, "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg=="],
"@esbuild/android-x64": ["@esbuild/android-x64@0.25.12", "", { "os": "android", "cpu": "x64" }, "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg=="],
"@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.25.12", "", { "os": "darwin", "cpu": "arm64" }, "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg=="],
"@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.25.12", "", { "os": "darwin", "cpu": "x64" }, "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA=="],
"@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.25.12", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg=="],
"@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.25.12", "", { "os": "freebsd", "cpu": "x64" }, "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ=="],
"@esbuild/linux-arm": ["@esbuild/linux-arm@0.25.12", "", { "os": "linux", "cpu": "arm" }, "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw=="],
"@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.25.12", "", { "os": "linux", "cpu": "arm64" }, "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ=="],
"@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.25.12", "", { "os": "linux", "cpu": "ia32" }, "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA=="],
"@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.25.12", "", { "os": "linux", "cpu": "none" }, "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng=="],
"@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.25.12", "", { "os": "linux", "cpu": "none" }, "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw=="],
"@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.25.12", "", { "os": "linux", "cpu": "ppc64" }, "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA=="],
"@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.25.12", "", { "os": "linux", "cpu": "none" }, "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w=="],
"@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.25.12", "", { "os": "linux", "cpu": "s390x" }, "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg=="],
"@esbuild/linux-x64": ["@esbuild/linux-x64@0.25.12", "", { "os": "linux", "cpu": "x64" }, "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw=="],
"@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.25.12", "", { "os": "none", "cpu": "arm64" }, "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg=="],
"@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.25.12", "", { "os": "none", "cpu": "x64" }, "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ=="],
"@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.25.12", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A=="],
"@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.25.12", "", { "os": "openbsd", "cpu": "x64" }, "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw=="],
"@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.25.12", "", { "os": "none", "cpu": "arm64" }, "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg=="],
"@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.25.12", "", { "os": "sunos", "cpu": "x64" }, "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w=="],
"@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.25.12", "", { "os": "win32", "cpu": "arm64" }, "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg=="],
"@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.25.12", "", { "os": "win32", "cpu": "ia32" }, "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ=="],
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.25.12", "", { "os": "win32", "cpu": "x64" }, "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA=="],
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.68.7", "", { "os": "android", "cpu": "arm" }, "sha512-ZL7MgOeMUiBum1bjzzyBotE3DuHVz+UUxcDVlLL7gpdhDM4RpjG4bZOIly7ensIcXw9jhWl7HTIIQ9KsgjykGQ=="],
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.68.7", "", { "os": "android", "cpu": "arm64" }, "sha512-cKZ2Hz/xt5DLY/vdUmMXEn3gnjLgwdeB/npHagbdTljLvBE6b/xKcPCcRWTiT0pHeVf8akl5Cb9K7ylRxbtHng=="],
"@rollup/rollup-android-x64": ["@rollup/rollup-android-x64@4.68.7", "", { "os": "android", "cpu": "x64" }, "sha512-P9vs1uCC2drepKKuiXrhY+r7ry/jtDCrBS8SUCYm2Rr7rVTR9eFH6XVAmD9TdfYFlDgRe5r1eH8tLQVuz+l/VA=="],
"@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.68.7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Lgu2AV7jbOTNNhkQ/OurNm7Snqu1Ux/3y7k8q47fbpPa3q63aIzKKp1xFzax5KH4pcdUzbnX/riuFsxKflsF+g=="],
"@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.68.7", "", { "os": "darwin", "cpu": "x64" }, "sha512-wKo6rOzla+/3rN8QBqTgcrsQMfyqwa3y14TvCTotLLib/ACWTxX1zWDTYze90s2RWtYiSfTlavHLmZv0Jsafrw=="],
"@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.68.7", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-vAeCwbFyEu/vBt9O/uHCHJSvwtOpTSssnM/PoZgn8rmvAkS+9ixaUfJZ2IP3ltom+rvpuQQEIEqltPY7qhC9lQ=="],
"@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.68.7", "", { "os": "freebsd", "cpu": "x64" }, "sha512-HvjSxOKI+6Si4ytmaoCEpjwDMrH/1s0uWeTAhdE5oXY8/RMI92hCePI/psZuJtY5EHWoT7MfyvTz0HBDZb1ZwQ=="],
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.68.7", "", { "os": "linux", "cpu": "arm", "libc": "glibc" }, "sha512-nz/Eu1sag3w5gPiKLJhAbKa4D9hUUJpDc9XzKXxGNHZqwgT2AbuVS2e4k9CIoLQp5dPhSN9ntiEVuz2jTzu1Gg=="],
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.68.7", "", { "os": "linux", "cpu": "arm", "libc": "musl" }, "sha512-05CEv2G/kI261A1WQBZL8gx6xXULjPfVnTKAkfnV/0uqHeLo+dNEOeUzMaiK/HDGR0Z1Nn7KJjm/34bNbNcfTA=="],
"@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.68.7", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-wrqk3EkxQt98lTdiYhjcaWmFHwvKiSgHFi7XmPTSF4X8+uGUTBOAc0CaynEvpUhBgkPRbwASrYoU/5uJPF+LFA=="],
"@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.68.7", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-DnuEUWvzeSxHxzu5lvrN+I/UzrcQkR/fQ4Bibetdp73Rf7aP0XgFpalSDuHmVWsCLETE+Lrl3GVOqIvFP7rcjw=="],
"@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.68.7", "", { "os": "linux", "cpu": "none", "libc": "glibc" }, "sha512-n0sr2s+rzVw8ntRucOxGhWeJ9lEl9KxCRzF3RmnZLE/tRnfKiloLuK8UqWrKFqVigEAh0IkRkPz5LVaV9/ZfvA=="],
"@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.68.7", "", { "os": "linux", "cpu": "none", "libc": "musl" }, "sha512-qDVJyMCbh7ekjt1kM9CZsyCFZvv5UW1QTIx3YfJ/gh8LkqpoPNpl9dCeYeOa+bsDOGTWZiMG2riXuoFSRISimQ=="],
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.68.7", "", { "os": "linux", "cpu": "ppc64", "libc": "glibc" }, "sha512-GiIOHHIzgpMoR5DT1pA1b9qMk5i0Ngg2FRj4D6XFSBC8e/axHuIdB7K/OBozO2RtCVAMnH1rXcuJrGScg+bvzA=="],
"@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.68.7", "", { "os": "linux", "cpu": "ppc64", "libc": "musl" }, "sha512-B132V2fwDl7UGLhvK6s3Ay7eNQ4dmDSDgsBm/Wwbz+Wgnunz0le4R2wzDp6TL5ExMu3MC1auJIrVtk2gOyxbyw=="],
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.68.7", "", { "os": "linux", "cpu": "none", "libc": "glibc" }, "sha512-3NueHQilbssjxgJMx9hXBV+U5keb3CBzmW5WhoBG3iSLFcmz9U2FVoG4MUYpZoZ+KSNMQPN2AA79dTxlEF0VxQ=="],
"@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.68.7", "", { "os": "linux", "cpu": "none", "libc": "musl" }, "sha512-8XRwbf76oAF1zZzg6OT8EY3swvCptZnLmiqMgO5+STyhTZ9s7rXa+tY8jESZW9IDyKACcVBGqa/RACDaLzRVjQ=="],
"@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.68.7", "", { "os": "linux", "cpu": "s390x", "libc": "glibc" }, "sha512-pvqqfjNdxVLvmovH681K5cPIL9DXj5n1RROaa0vb9JrtHddiScLrkHPRKj5flTKHF1M7xvRy0SS2yTRIc2TO0Q=="],
"@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.68.7", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-rsTjTf5HAm6F4sI6uUfJf2pc+7AWBKxgc2RveGvwB2OvVa1GezSSCDD1rtXPuFhcg3itPv7iHgcZsq/RwWvJ4Q=="],
"@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.68.7", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-VNLvsYMD5+zLCi5SohwDdL8PpicC9PnArLwyMJXXUcAduzrM3k9aZT9XiHw+mn5dOWr3UEyfyqJbOvxwJ2fCWQ=="],
"@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.68.7", "", { "os": "openbsd", "cpu": "x64" }, "sha512-7aOjdahkwiECWWOmjAemPd21yeQ18TW59DUiLWttzolMe5tDwHyBhlOfmxRUHOQnepTNkZ2Qwp1T6LxFZ5v7yQ=="],
"@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.68.7", "", { "os": "none", "cpu": "arm64" }, "sha512-BnNkTwE4FMCAoz3UYiJ6D6Y3pGozYIYZ2W+onH64uhiTI2iwD3KOaNSlkuHYfupZVemls3YTlvbPnuKwHsraiQ=="],
"@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.68.7", "", { "os": "win32", "cpu": "arm64" }, "sha512-OH8tGWsJcRW6Vn0dmndyWJGdQa46bH2/2/PVfleBGUWuBd5/HVkIvw2UslgBwUZdtV78bJaoCNBmYI5+bcTJ4A=="],
"@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.68.7", "", { "os": "win32", "cpu": "ia32" }, "sha512-SpYx5X9+2JOF3hXe1cRaiFn562h4AMJhfgxkyHyiuh9dJ7PanPm7FTp8GJReSbS9N+TfjRiBbKacVk1g35kKxg=="],
"@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.68.7", "", { "os": "win32", "cpu": "x64" }, "sha512-0ncKtQ55fqElV9Sk4cZ/4tiXVGlWxaH5PvDOlx1Sx8GuHIpSWgYrTcyrO51JnVFfy7LvAJiffkEg63ZHKwTMag=="],
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.68.7", "", { "os": "win32", "cpu": "x64" }, "sha512-XY9DYHO5UxxVR8G6AErXDlccQmDpvGTLgKHFpvkgsyjwG/PrQuInRjQQfpEzBRuT+bhBtwfS8yDe9sPhVcq/9A=="],
"@tweenjs/tween.js": ["@tweenjs/tween.js@23.1.3", "", {}, "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA=="],
"@types/chai": ["@types/chai@5.2.3", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="],
"@types/deep-eql": ["@types/deep-eql@4.0.2", "", {}, "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw=="],
"@types/estree": ["@types/estree@1.0.10", "", {}, "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g=="],
"@types/stats.js": ["@types/stats.js@0.17.4", "", {}, "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA=="],
"@types/three": ["@types/three@0.180.0", "", { "dependencies": { "@dimforge/rapier3d-compat": "~0.12.0", "@tweenjs/tween.js": "~23.1.3", "@types/stats.js": "*", "@types/webxr": "*", "@webgpu/types": "*", "fflate": "~0.8.2", "meshoptimizer": "~0.22.0" } }, "sha512-ykFtgCqNnY0IPvDro7h+9ZeLY+qjgUWv+qEvUt84grhenO60Hqd4hScHE7VTB9nOQ/3QM8lkbNE+4vKjEpUxKg=="],
"@types/webxr": ["@types/webxr@0.5.24", "", {}, "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg=="],
"@vitest/expect": ["@vitest/expect@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "tinyrainbow": "^2.0.0" } }, "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig=="],
"@vitest/mocker": ["@vitest/mocker@3.2.4", "", { "dependencies": { "@vitest/spy": "3.2.4", "estree-walker": "^3.0.3", "magic-string": "^0.30.17" }, "peerDependencies": { "msw": "^2.4.9", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "optionalPeers": ["msw", "vite"] }, "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ=="],
"@vitest/pretty-format": ["@vitest/pretty-format@3.2.4", "", { "dependencies": { "tinyrainbow": "^2.0.0" } }, "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA=="],
"@vitest/runner": ["@vitest/runner@3.2.4", "", { "dependencies": { "@vitest/utils": "3.2.4", "pathe": "^2.0.3", "strip-literal": "^3.0.0" } }, "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ=="],
"@vitest/snapshot": ["@vitest/snapshot@3.2.4", "", { "dependencies": { "@vitest/pretty-format": "3.2.4", "magic-string": "^0.30.17", "pathe": "^2.0.3" } }, "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ=="],
"@vitest/spy": ["@vitest/spy@3.2.4", "", { "dependencies": { "tinyspy": "^4.0.3" } }, "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw=="],
"@vitest/utils": ["@vitest/utils@3.2.4", "", { "dependencies": { "@vitest/pretty-format": "3.2.4", "loupe": "^3.1.4", "tinyrainbow": "^2.0.0" } }, "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA=="],
"@webgpu/types": ["@webgpu/types@0.1.74", "", {}, "sha512-lgiI4hbuLcI9unnm2cL/tvCaQU45dp0xcLWJh5uB/9MBGvIA4F8XIk7nSiBeg+K4xWGYwgZKn80LmERI5CxoTA=="],
"assertion-error": ["assertion-error@2.0.1", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="],
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
"chai": ["chai@5.3.3", "", { "dependencies": { "assertion-error": "^2.0.1", "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" } }, "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw=="],
"check-error": ["check-error@2.1.3", "", {}, "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA=="],
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
"deep-eql": ["deep-eql@5.0.2", "", {}, "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q=="],
"es-module-lexer": ["es-module-lexer@1.7.0", "", {}, "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA=="],
"esbuild": ["esbuild@0.25.12", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.12", "@esbuild/android-arm": "0.25.12", "@esbuild/android-arm64": "0.25.12", "@esbuild/android-x64": "0.25.12", "@esbuild/darwin-arm64": "0.25.12", "@esbuild/darwin-x64": "0.25.12", "@esbuild/freebsd-arm64": "0.25.12", "@esbuild/freebsd-x64": "0.25.12", "@esbuild/linux-arm": "0.25.12", "@esbuild/linux-arm64": "0.25.12", "@esbuild/linux-ia32": "0.25.12", "@esbuild/linux-loong64": "0.25.12", "@esbuild/linux-mips64el": "0.25.12", "@esbuild/linux-ppc64": "0.25.12", "@esbuild/linux-riscv64": "0.25.12", "@esbuild/linux-s390x": "0.25.12", "@esbuild/linux-x64": "0.25.12", "@esbuild/netbsd-arm64": "0.25.12", "@esbuild/netbsd-x64": "0.25.12", "@esbuild/openbsd-arm64": "0.25.12", "@esbuild/openbsd-x64": "0.25.12", "@esbuild/openharmony-arm64": "0.25.12", "@esbuild/sunos-x64": "0.25.12", "@esbuild/win32-arm64": "0.25.12", "@esbuild/win32-ia32": "0.25.12", "@esbuild/win32-x64": "0.25.12" }, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" } }, "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg=="],
"estree-walker": ["estree-walker@3.0.3", "", { "dependencies": { "@types/estree": "^1.0.0" } }, "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g=="],
"expect-type": ["expect-type@1.4.0", "", {}, "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA=="],
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
"fflate": ["fflate@0.8.3", "", {}, "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA=="],
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin", "hasInstallScript": true }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
"js-tokens": ["js-tokens@9.0.1", "", {}, "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ=="],
"loupe": ["loupe@3.2.1", "", {}, "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ=="],
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
"meshoptimizer": ["meshoptimizer@0.22.0", "", {}, "sha512-IebiK79sqIy+E4EgOr+CAw+Ke8hAspXKzBd0JdgEmPHiAwmvEj2S4h1rfvo+o/BnfEYd/jAOg5IeeIjzlzSnDg=="],
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
"nanoid": ["nanoid@3.3.20", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="],
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
"pathval": ["pathval@2.0.1", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="],
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
"picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="],
"postcss": ["postcss@8.5.33", "", { "dependencies": { "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" } }, "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ=="],
"rollup": ["rollup@4.68.7", "", { "dependencies": { "@types/estree": "^1.0.10" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.68.7", "@rollup/rollup-android-arm64": "4.68.7", "@rollup/rollup-android-x64": "4.68.7", "@rollup/rollup-darwin-arm64": "4.68.7", "@rollup/rollup-darwin-x64": "4.68.7", "@rollup/rollup-freebsd-arm64": "4.68.7", "@rollup/rollup-freebsd-x64": "4.68.7", "@rollup/rollup-linux-arm-gnueabihf": "4.68.7", "@rollup/rollup-linux-arm-musleabihf": "4.68.7", "@rollup/rollup-linux-arm64-gnu": "4.68.7", "@rollup/rollup-linux-arm64-musl": "4.68.7", "@rollup/rollup-linux-loong64-gnu": "4.68.7", "@rollup/rollup-linux-loong64-musl": "4.68.7", "@rollup/rollup-linux-ppc64-gnu": "4.68.7", "@rollup/rollup-linux-ppc64-musl": "4.68.7", "@rollup/rollup-linux-riscv64-gnu": "4.68.7", "@rollup/rollup-linux-riscv64-musl": "4.68.7", "@rollup/rollup-linux-s390x-gnu": "4.68.7", "@rollup/rollup-linux-x64-gnu": "4.68.7", "@rollup/rollup-linux-x64-musl": "4.68.7", "@rollup/rollup-openbsd-x64": "4.68.7", "@rollup/rollup-openharmony-arm64": "4.68.7", "@rollup/rollup-win32-arm64-msvc": "4.68.7", "@rollup/rollup-win32-ia32-msvc": "4.68.7", "@rollup/rollup-win32-x64-gnu": "4.68.7", "@rollup/rollup-win32-x64-msvc": "4.68.7", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-CxhzUIc+ocxPAWxHuff+PAluoW1otD6dHqqPK2h2Q38WA1VYk+3gizX6NEg5t2a8yNGQaiHM1R7V+qdwWuvp5Q=="],
"siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
"source-map-js": ["source-map-js@1.2.4", "", {}, "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA=="],
"stackback": ["stackback@0.0.2", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="],
"std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="],
"strip-literal": ["strip-literal@3.1.0", "", { "dependencies": { "js-tokens": "^9.0.1" } }, "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg=="],
"three": ["three@0.180.0", "", {}, "sha512-o+qycAMZrh+TsE01GqWUxUIKR1AL0S8pq7zDkYOQw8GqfX8b8VoCKYUoHbhiX5j+7hr8XsuHDVU6+gkQJQKg9w=="],
"tinybench": ["tinybench@2.9.0", "", {}, "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg=="],
"tinyexec": ["tinyexec@0.3.2", "", {}, "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA=="],
"tinyglobby": ["tinyglobby@0.2.17", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
"tinypool": ["tinypool@1.1.1", "", {}, "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg=="],
"tinyrainbow": ["tinyrainbow@2.0.0", "", {}, "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw=="],
"tinyspy": ["tinyspy@4.0.6", "", {}, "sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg=="],
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"vite": ["vite@7.1.12", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug=="],
"vite-node": ["vite-node@3.2.4", "", { "dependencies": { "cac": "^6.7.14", "debug": "^4.4.1", "es-module-lexer": "^1.7.0", "pathe": "^2.0.3", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "bin": { "vite-node": "vite-node.mjs" } }, "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg=="],
"vitest": ["vitest@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", "@vitest/mocker": "3.2.4", "@vitest/pretty-format": "^3.2.4", "@vitest/runner": "3.2.4", "@vitest/snapshot": "3.2.4", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "debug": "^4.4.1", "expect-type": "^1.2.1", "magic-string": "^0.30.17", "pathe": "^2.0.3", "picomatch": "^4.0.2", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.14", "tinypool": "^1.1.1", "tinyrainbow": "^2.0.0", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "@vitest/browser": "3.2.4", "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@types/debug", "@types/node", "@vitest/browser", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A=="],
"why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"name": "solaredge-roof-card",
"private": true,
"type": "module",
"scripts": {
"build": "tsc --noEmit && vite build",
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"three": "0.180.0"
},
"devDependencies": {
"@types/three": "0.180.0",
"typescript": "5.9.3",
"vite": "7.1.12",
"vitest": "3.2.4"
}
}
+30
View File
@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import { deriveWalls } from "./geometry";
import type { RoofConfig } from "./types";
describe("deriveWalls", () => {
it("puts walls under the outer edges of a gable roof but not under the ridge", () => {
const west: RoofConfig = {
name: "west",
outline: [
[0, 0, 9],
[0, 10, 9],
[-4, 10, 5],
[-4, 0, 5],
],
};
const east: RoofConfig = {
name: "ost",
outline: [
[0, 10, 9],
[0, 0, 9],
[4, 0, 5],
[4, 10, 5],
],
};
const walls = deriveWalls([west, east]);
expect(walls).toHaveLength(6);
const ridge = walls.filter((w) => w.from[0] === 0 && w.to[0] === 0);
expect(ridge).toHaveLength(0);
});
});
+71
View File
@@ -0,0 +1,71 @@
import type { Point3, RoofConfig } from "./types";
/** A wall below one roof edge, from the ground up to the edge. */
export interface Wall {
from: Point3;
to: Point3;
}
const EDGE_TOLERANCE_M = 0.02;
function samePlanPoint(a: Point3, b: Point3): boolean {
return Math.abs(a[0] - b[0]) < EDGE_TOLERANCE_M && Math.abs(a[1] - b[1]) < EDGE_TOLERANCE_M;
}
/**
* Walls of the building: every roof edge that no other roof shares in the
* ground plan is extruded down to the ground.
*/
export function deriveWalls(roofs: readonly RoofConfig[]): Wall[] {
const edges = roofs.map((roof) =>
roof.outline.map((point, i) => ({
from: point,
to: roof.outline[(i + 1) % roof.outline.length]!,
})),
);
const walls: Wall[] = [];
edges.forEach((roofEdges, roofIndex) => {
for (const edge of roofEdges) {
const shared = edges.some(
(other, otherIndex) =>
otherIndex !== roofIndex &&
other.some(
(o) =>
(samePlanPoint(o.from, edge.from) && samePlanPoint(o.to, edge.to)) ||
(samePlanPoint(o.from, edge.to) && samePlanPoint(o.to, edge.from)),
),
);
if (!shared) walls.push(edge);
}
});
return walls;
}
export interface Bounds {
min: Point3;
max: Point3;
}
export function bounds(points: readonly Point3[]): Bounds {
const min: Point3 = [Infinity, Infinity, Infinity];
const max: Point3 = [-Infinity, -Infinity, -Infinity];
for (const p of points) {
for (let i = 0; i < 3; i++) {
min[i] = Math.min(min[i]!, p[i]!);
max[i] = Math.max(max[i]!, p[i]!);
}
}
return { min, max };
}
function distance(a: Point3, b: Point3): number {
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}
/** Width (lower edge) and height (up-slope edge) of a panel in metres. */
export function panelSize(corners: readonly [Point3, Point3, Point3, Point3]): {
width: number;
height: number;
} {
return { width: distance(corners[0], corners[1]), height: distance(corners[0], corners[3]) };
}
+96
View File
@@ -0,0 +1,96 @@
import { describe, expect, it } from "vitest";
import {
DEFAULT_MAX_POWER,
findPowerEntities,
powerColor,
resolvePanelStates,
textColorFor,
} from "./panel-state";
import type { HassEntity } from "./types";
function sensor(
entityId: string,
state: string,
attributes: Record<string, unknown>,
): HassEntity {
return { entity_id: entityId, state, attributes };
}
const power = (id: string, state: string, lastMeasurement?: string) =>
sensor(`sensor.optimizer_${id.replaceAll(".", "_")}_aktuelle_leistung`, state, {
optimizer_id: id,
device_class: "power",
unit_of_measurement: "W",
last_measurement: lastMeasurement,
});
function statesOf(...entities: HassEntity[]): Record<string, HassEntity> {
return Object.fromEntries(entities.map((e) => [e.entity_id, e]));
}
describe("findPowerEntities", () => {
it("picks the power sensor of each panel, not the energy sensor", () => {
const states = statesOf(
power("1.1.1", "120"),
sensor("sensor.optimizer_1_1_1_tagesenergie", "800", {
optimizer_id: "1.1.1",
device_class: "energy",
}),
);
expect(findPowerEntities(states, ["1.1.1", "1.1.2"])).toEqual(
new Map([["1.1.1", "sensor.optimizer_1_1_1_aktuelle_leistung"]]),
);
});
});
describe("resolvePanelStates", () => {
const ids = ["1.1.1", "1.1.2", "1.1.3", "1.1.4"];
it("distinguishes a value, 0 W, an unavailable entity and a missing entity", () => {
const states = statesOf(
power("1.1.1", "123.4", "2026-11-19T12:00:00+00:00"),
power("1.1.2", "0", "2026-11-19T12:00:00+00:00"),
power("1.1.3", "unavailable"),
);
const { panels } = resolvePanelStates(states, findPowerEntities(states, ids), ids);
expect(panels.get("1.1.1")).toMatchObject({ status: "ok", power: 123.4 });
expect(panels.get("1.1.2")).toMatchObject({ status: "ok", power: 0 });
expect(panels.get("1.1.3")).toMatchObject({ status: "failed" });
expect(panels.get("1.1.4")).toEqual({ status: "failed", entityId: undefined });
});
it("reports the newest measurement and fails panels more than 30 minutes behind it", () => {
const states = statesOf(
power("1.1.1", "100", "2026-11-19T12:20:00+00:00"),
power("1.1.2", "100", "2026-11-19T12:00:00+00:00"),
power("1.1.3", "100", "2026-11-19T11:49:00+00:00"),
);
const panelIds = ["1.1.1", "1.1.2", "1.1.3"];
const { panels, newestMeasurement } = resolvePanelStates(
states,
findPowerEntities(states, panelIds),
panelIds,
);
expect(newestMeasurement).toBe(Date.parse("2026-11-19T12:20:00+00:00"));
expect(panels.get("1.1.2")?.status).toBe("ok");
expect(panels.get("1.1.3")?.status).toBe("failed");
});
});
describe("powerColor", () => {
it("runs from dark at 0 W to bright at the Skalenmaximum and clamps beyond", () => {
const luminance = ([r, g, b]: number[]) => 0.2126 * r! + 0.7152 * g! + 0.0722 * b!;
const dark = powerColor(0, DEFAULT_MAX_POWER);
const mid = powerColor(230, DEFAULT_MAX_POWER);
const bright = powerColor(460, DEFAULT_MAX_POWER);
expect(luminance(dark)).toBeLessThan(luminance(mid));
expect(luminance(mid)).toBeLessThan(luminance(bright));
expect(powerColor(900, DEFAULT_MAX_POWER)).toEqual(bright);
expect(powerColor(-5, DEFAULT_MAX_POWER)).toEqual(dark);
});
it("keeps the text readable", () => {
expect(textColorFor(powerColor(0, 460))).toBe("#ffffff");
expect(textColorFor(powerColor(460, 460))).toBe("#1b1b1f");
});
});
+119
View File
@@ -0,0 +1,119 @@
import type { HassEntity } from "./types";
/** A panel whose measurement is this much older than the newest one counts as failed. */
export const STALE_AFTER_MS = 30 * 60 * 1000;
export const DEFAULT_MAX_POWER = 460;
export type PanelState =
| { status: "ok"; entityId: string; power: number; lastMeasurement?: number }
| { status: "failed"; entityId?: string };
/** Find the power entity of every panel by its optimizer_id attribute. */
export function findPowerEntities(
states: Record<string, HassEntity>,
panelIds: readonly string[],
): Map<string, string> {
const wanted = new Set(panelIds);
const result = new Map<string, string>();
for (const entity of Object.values(states)) {
const id = entity.attributes.optimizer_id;
if (
typeof id === "string" &&
wanted.has(id) &&
entity.attributes.device_class === "power" &&
entity.entity_id.startsWith("sensor.")
) {
result.set(id, entity.entity_id);
}
}
return result;
}
function parseTime(value: unknown): number | undefined {
if (typeof value !== "string") return undefined;
const time = Date.parse(value);
return Number.isNaN(time) ? undefined : time;
}
/**
* Work out every panel's state.
*
* A panel is failed ("ausgefallen") when it has no entity, no numeric value,
* or a measurement more than STALE_AFTER_MS older than the newest panel's.
* 0 W is a valid value (night), not a failure.
*/
export function resolvePanelStates(
states: Record<string, HassEntity>,
entities: ReadonlyMap<string, string>,
panelIds: readonly string[],
): { panels: Map<string, PanelState>; newestMeasurement?: number } {
const readings = new Map<string, PanelState>();
let newest: number | undefined;
for (const id of panelIds) {
const entityId = entities.get(id);
const entity = entityId ? states[entityId] : undefined;
if (!entityId || !entity) {
readings.set(id, { status: "failed", entityId });
continue;
}
const power = Number(entity.state);
if (entity.state === "" || !Number.isFinite(power)) {
readings.set(id, { status: "failed", entityId });
continue;
}
const lastMeasurement = parseTime(entity.attributes.last_measurement);
if (lastMeasurement !== undefined && (newest === undefined || lastMeasurement > newest)) {
newest = lastMeasurement;
}
readings.set(id, { status: "ok", entityId, power, lastMeasurement });
}
if (newest !== undefined) {
for (const [id, reading] of readings) {
if (
reading.status === "ok" &&
reading.lastMeasurement !== undefined &&
newest - reading.lastMeasurement > STALE_AFTER_MS
) {
readings.set(id, { status: "failed", entityId: reading.entityId });
}
}
}
return { panels: readings, newestMeasurement: newest };
}
type Rgb = [number, number, number];
const COLOR_STOPS: Array<[number, Rgb]> = [
[0, [22, 32, 58]],
[0.5, [44, 104, 214]],
[1, [255, 214, 74]],
];
/** Colour for a power value: dark at 0 W, brightest at maxPower and above. */
export function powerColor(power: number, maxPower: number): Rgb {
const t = Math.min(1, Math.max(0, maxPower > 0 ? power / maxPower : 0));
for (let i = 1; i < COLOR_STOPS.length; i++) {
const [end, to] = COLOR_STOPS[i]!;
const [start, from] = COLOR_STOPS[i - 1]!;
if (t <= end) {
const f = (t - start) / (end - start);
return [0, 1, 2].map((c) => Math.round(from[c]! + (to[c]! - from[c]!) * f)) as Rgb;
}
}
return COLOR_STOPS[COLOR_STOPS.length - 1]![1];
}
/** Text colour that stays readable on the given background. */
export function textColorFor([r, g, b]: Rgb): string {
const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
return luminance > 0.55 ? "#1b1b1f" : "#ffffff";
}
export function formatPower(power: number): string {
return `${Math.round(power)} W`;
}
export function colorGradientCss(): string {
return COLOR_STOPS.map(([t, [r, g, b]]) => `rgb(${r},${g},${b}) ${t * 100}%`).join(", ");
}
+311
View File
@@ -0,0 +1,311 @@
import {
AmbientLight,
BufferAttribute,
BufferGeometry,
CanvasTexture,
CircleGeometry,
Color,
DirectionalLight,
DoubleSide,
Mesh,
MeshBasicMaterial,
MeshLambertMaterial,
PerspectiveCamera,
Raycaster,
Scene,
SRGBColorSpace,
Vector2,
Vector3,
WebGLRenderer,
} from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import { bounds, deriveWalls, panelSize } from "./geometry";
import { formatPower, powerColor, textColorFor, type PanelState } from "./panel-state";
import type { PanelConfig, Point3, RoofConfig } from "./types";
/** Model coordinates (x east, y north, z up) to three.js (y up, z south). */
function toThree([x, y, z]: Point3): Vector3 {
return new Vector3(x, z, -y);
}
function quadGeometry(points: Vector3[], withUv: boolean): BufferGeometry {
const geometry = new BufferGeometry();
const positions: number[] = [];
for (let i = 1; i < points.length - 1; i++) {
for (const p of [points[0]!, points[i]!, points[i + 1]!]) positions.push(p.x, p.y, p.z);
}
geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
if (withUv) {
const uv = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1];
geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uv), 2));
}
geometry.computeVertexNormals();
return geometry;
}
const PIXELS_PER_METRE = 220;
interface PanelView {
config: PanelConfig;
mesh: Mesh;
canvas: HTMLCanvasElement;
texture: CanvasTexture;
key?: string;
}
export interface SceneColors {
background: string;
ground: string;
wall: string;
roof: string;
}
export class RoofScene {
readonly element: HTMLCanvasElement;
private readonly renderer: WebGLRenderer;
private readonly scene = new Scene();
private readonly camera = new PerspectiveCamera(35, 1, 0.1, 500);
private readonly controls: OrbitControls;
private readonly panels = new Map<string, PanelView>();
private readonly target: Vector3;
private readonly homePosition: Vector3;
private renderQueued = false;
private pointerDown?: Vector2;
private readonly materials: { ground: MeshLambertMaterial; wall: MeshLambertMaterial; roof: MeshLambertMaterial };
constructor(
roofs: RoofConfig[],
panels: PanelConfig[],
colors: SceneColors,
private readonly onPanelClick: (panelId: string) => void,
) {
this.renderer = new WebGLRenderer({ antialias: true, alpha: true });
this.renderer.outputColorSpace = SRGBColorSpace;
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
this.element = this.renderer.domElement;
this.element.style.touchAction = "none";
this.scene.add(new AmbientLight(0xffffff, 1.6));
const sun = new DirectionalLight(0xffffff, 1.8);
sun.position.set(-8, 20, 12);
this.scene.add(sun);
this.materials = {
ground: new MeshLambertMaterial({ side: DoubleSide }),
wall: new MeshLambertMaterial({ side: DoubleSide }),
roof: new MeshLambertMaterial({ side: DoubleSide }),
};
this.setColors(colors);
const all = [...roofs.flatMap((r) => r.outline), ...panels.flatMap((p) => p.corners)];
const box = bounds(all);
const centre: Point3 = [
(box.min[0] + box.max[0]) / 2,
(box.min[1] + box.max[1]) / 2,
0,
];
const span = Math.max(box.max[0] - box.min[0], box.max[1] - box.min[1], box.max[2]);
const ground = new Mesh(new CircleGeometry(span * 1.6, 64), this.materials.ground);
ground.rotation.x = -Math.PI / 2;
ground.position.copy(toThree(centre));
ground.position.y = -0.01;
this.scene.add(ground);
for (const roof of roofs) {
this.scene.add(new Mesh(quadGeometry(roof.outline.map(toThree), false), this.materials.roof));
}
for (const wall of deriveWalls(roofs)) {
const points = [
toThree([wall.from[0], wall.from[1], 0]),
toThree([wall.to[0], wall.to[1], 0]),
toThree(wall.to),
toThree(wall.from),
];
this.scene.add(new Mesh(quadGeometry(points, false), this.materials.wall));
}
for (const panel of panels) this.addPanel(panel);
this.target = toThree([centre[0], centre[1], box.max[2] * 0.45]);
const distance = span * 2.3;
// Seen from the south-south-east and from above, like the portal.
this.homePosition = this.target
.clone()
.add(new Vector3(distance * 0.18, distance * 0.78, distance * 0.6));
this.camera.position.copy(this.homePosition);
this.controls = new OrbitControls(this.camera, this.element);
this.controls.target.copy(this.target);
this.controls.maxPolarAngle = Math.PI / 2 - 0.05;
this.controls.minDistance = span * 0.6;
this.controls.maxDistance = span * 5;
this.controls.addEventListener("change", () => this.requestRender());
this.controls.update();
this.element.addEventListener("pointerdown", (event) => {
this.pointerDown = new Vector2(event.clientX, event.clientY);
});
this.element.addEventListener("pointerup", (event) => this.handlePointerUp(event));
}
setColors(colors: SceneColors): void {
this.materials.ground.color = new Color(colors.ground);
this.materials.wall.color = new Color(colors.wall);
this.materials.roof.color = new Color(colors.roof);
this.requestRender();
}
private addPanel(config: PanelConfig): void {
const { width, height } = panelSize(config.corners);
const canvas = document.createElement("canvas");
canvas.width = Math.round(width * PIXELS_PER_METRE);
canvas.height = Math.round(height * PIXELS_PER_METRE);
const texture = new CanvasTexture(canvas);
texture.colorSpace = SRGBColorSpace;
texture.anisotropy = 4;
const material = new MeshBasicMaterial({ map: texture, side: DoubleSide });
const mesh = new Mesh(quadGeometry(config.corners.map(toThree), true), material);
mesh.userData.panelId = config.id;
this.scene.add(mesh);
this.panels.set(config.id, { config, mesh, canvas, texture });
}
/** Repaint the panels whose state changed. */
updatePanels(states: ReadonlyMap<string, PanelState>, maxPower: number): void {
let changed = false;
for (const [id, view] of this.panels) {
const state = states.get(id) ?? { status: "failed" as const };
const key =
state.status === "ok" ? `${Math.round(state.power)}|${maxPower}` : "failed";
if (key === view.key) continue;
view.key = key;
paintPanel(view.canvas, id, state, maxPower);
view.texture.needsUpdate = true;
changed = true;
}
if (changed) this.requestRender();
}
resetView(): void {
this.camera.position.copy(this.homePosition);
this.controls.target.copy(this.target);
this.controls.update();
}
setSize(width: number, height: number): void {
if (width <= 0 || height <= 0) return;
this.renderer.setSize(width, height, false);
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
this.render();
}
requestRender(): void {
if (this.renderQueued) return;
this.renderQueued = true;
requestAnimationFrame(() => {
this.renderQueued = false;
this.render();
});
}
private render(): void {
this.renderer.render(this.scene, this.camera);
}
private handlePointerUp(event: PointerEvent): void {
const start = this.pointerDown;
this.pointerDown = undefined;
if (!start || start.distanceTo(new Vector2(event.clientX, event.clientY)) > 6) return;
const rect = this.element.getBoundingClientRect();
const pointer = new Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1,
);
const raycaster = new Raycaster();
raycaster.setFromCamera(pointer, this.camera);
const meshes = [...this.panels.values()].map((p) => p.mesh);
const hit = raycaster.intersectObjects(meshes, false)[0];
const panelId = hit?.object.userData.panelId;
if (typeof panelId === "string") this.onPanelClick(panelId);
}
dispose(): void {
this.controls.dispose();
for (const view of this.panels.values()) {
view.texture.dispose();
view.mesh.geometry.dispose();
(view.mesh.material as MeshBasicMaterial).dispose();
}
this.scene.traverse((object) => {
if (object instanceof Mesh) object.geometry.dispose();
});
Object.values(this.materials).forEach((m) => m.dispose());
this.renderer.dispose();
}
}
function paintPanel(
canvas: HTMLCanvasElement,
panelId: string,
state: PanelState,
maxPower: number,
): void {
const ctx = canvas.getContext("2d");
if (!ctx) return;
const { width: w, height: h } = canvas;
const failed = state.status !== "ok";
const rgb = failed ? ([96, 100, 108] as const) : powerColor(state.power, maxPower);
const text = failed ? "#ffffff" : textColorFor([rgb[0], rgb[1], rgb[2]]);
ctx.fillStyle = `rgb(${rgb[0]},${rgb[1]},${rgb[2]})`;
ctx.fillRect(0, 0, w, h);
if (failed) {
ctx.strokeStyle = "rgba(255,255,255,0.18)";
ctx.lineWidth = Math.max(4, w / 40);
for (let x = -h; x < w; x += w / 6) {
ctx.beginPath();
ctx.moveTo(x, h);
ctx.lineTo(x + h, 0);
ctx.stroke();
}
} else {
// Cell grid, like a real module.
ctx.strokeStyle = "rgba(255,255,255,0.12)";
ctx.lineWidth = 2;
const cols = w > h ? 8 : 4;
const rows = w > h ? 4 : 8;
for (let i = 1; i < cols; i++) {
ctx.beginPath();
ctx.moveTo((w / cols) * i, 0);
ctx.lineTo((w / cols) * i, h);
ctx.stroke();
}
for (let i = 1; i < rows; i++) {
ctx.beginPath();
ctx.moveTo(0, (h / rows) * i);
ctx.lineTo(w, (h / rows) * i);
ctx.stroke();
}
}
const border = Math.max(6, Math.min(w, h) / 22);
ctx.strokeStyle = failed ? "#e5484d" : "rgba(10,14,24,0.85)";
ctx.lineWidth = border;
ctx.strokeRect(border / 2, border / 2, w - border, h - border);
// The canvas top maps to the panel's upper (up-slope) edge, so text reads
// upright when looking up the roof.
const value = failed ? "–" : formatPower(state.power);
const base = Math.min(w, h);
ctx.fillStyle = text;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `700 ${Math.round(base * 0.3)}px system-ui, sans-serif`;
ctx.fillText(value, w / 2, h * 0.44, w * 0.9);
ctx.font = `500 ${Math.round(base * 0.16)}px system-ui, sans-serif`;
ctx.globalAlpha = 0.85;
ctx.fillText(panelId, w / 2, h * 0.78, w * 0.9);
ctx.globalAlpha = 1;
}
+192
View File
@@ -0,0 +1,192 @@
import {
colorGradientCss,
DEFAULT_MAX_POWER,
findPowerEntities,
resolvePanelStates,
} from "./panel-state";
import { RoofScene, type SceneColors } from "./scene";
import type { Hass, RoofCardConfig } from "./types";
const CARD_TYPE = "solaredge-roof-card";
const RESET_ICON =
"M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z";
class SolarEdgeRoofCard extends HTMLElement {
private config?: RoofCardConfig;
private _hass?: Hass;
private scene?: RoofScene;
private resizeObserver?: ResizeObserver;
private entities = new Map<string, string>();
private entityCount = -1;
private readonly root: ShadowRoot;
private stage?: HTMLDivElement;
private status?: HTMLSpanElement;
private legendMax?: HTMLSpanElement;
constructor() {
super();
this.root = this.attachShadow({ mode: "open" });
}
static getStubConfig(): Partial<RoofCardConfig> {
return { layout: { roofs: [], panels: [] } };
}
setConfig(config: RoofCardConfig): void {
if (!config?.layout || !Array.isArray(config.layout.panels) || !Array.isArray(config.layout.roofs)) {
throw new Error("layout.roofs und layout.panels fehlen");
}
if (config.max_power !== undefined && !(Number(config.max_power) > 0)) {
throw new Error("max_power muss größer als 0 sein");
}
this.config = config;
this.entityCount = -1;
this.teardownScene();
this.renderShell();
if (this.isConnected) this.setupScene();
}
set hass(hass: Hass) {
this._hass = hass;
this.update();
}
getCardSize(): number {
return 8;
}
getGridOptions(): Record<string, number> {
return { columns: 12, min_columns: 6, min_rows: 6 };
}
connectedCallback(): void {
if (this.config && !this.scene) this.setupScene();
}
disconnectedCallback(): void {
this.teardownScene();
}
private get maxPower(): number {
return Number(this.config?.max_power ?? DEFAULT_MAX_POWER);
}
private renderShell(): void {
const title = this.config?.title ?? "Dach";
this.root.innerHTML = `
<style>
:host { display: block; }
ha-card { overflow: hidden; height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 12px 12px 4px 16px; }
h2 { margin: 0; font-size: 16px; font-weight: 500; flex: 1; color: var(--primary-text-color); }
.status { font-size: 13px; color: var(--secondary-text-color); white-space: nowrap; }
button { border: none; background: none; padding: 6px; border-radius: 50%; cursor: pointer;
color: var(--secondary-text-color); display: flex; }
button:hover { background: var(--secondary-background-color); }
button svg { width: 20px; height: 20px; fill: currentColor; }
.stage { position: relative; flex: 1; min-height: 280px; aspect-ratio: 4 / 3; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
footer { display: flex; align-items: center; gap: 8px; padding: 4px 16px 12px;
font-size: 12px; color: var(--secondary-text-color); }
.legend { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, ${colorGradientCss()}); }
.failed { width: 12px; height: 12px; border-radius: 2px; background: rgb(96,100,108);
outline: 2px solid #e5484d; outline-offset: -2px; margin-left: 12px; }
</style>
<ha-card>
<header>
<h2></h2>
<span class="status"></span>
<button type="button" title="Ansicht zurücksetzen" aria-label="Ansicht zurücksetzen">
<svg viewBox="0 0 24 24"><path d="${RESET_ICON}"></path></svg>
</button>
</header>
<div class="stage"></div>
<footer>
<span>0 W</span><span class="legend"></span><span class="max"></span>
<span class="failed"></span><span>ausgefallen</span>
</footer>
</ha-card>`;
this.root.querySelector("h2")!.textContent = title;
this.stage = this.root.querySelector<HTMLDivElement>(".stage")!;
this.status = this.root.querySelector<HTMLSpanElement>(".status")!;
this.legendMax = this.root.querySelector<HTMLSpanElement>(".max")!;
this.legendMax.textContent = `${this.maxPower} W`;
this.root.querySelector("button")!.addEventListener("click", () => this.scene?.resetView());
}
private sceneColors(): SceneColors {
const style = getComputedStyle(this);
const dark = this._hass && (this._hass as { themes?: { darkMode?: boolean } }).themes?.darkMode;
return {
background: style.getPropertyValue("--card-background-color") || "#fff",
ground: dark ? "#2a2f2a" : "#cfd6c8",
wall: dark ? "#8a8d92" : "#e4e2dc",
roof: dark ? "#4b4f56" : "#7b7f86",
};
}
private setupScene(): void {
if (!this.config || !this.stage) return;
const { roofs, panels } = this.config.layout;
this.scene = new RoofScene(roofs, panels, this.sceneColors(), (panelId) =>
this.openMoreInfo(panelId),
);
this.stage.append(this.scene.element);
this.resizeObserver = new ResizeObserver(() => {
if (!this.stage || !this.scene) return;
this.scene.setSize(this.stage.clientWidth, this.stage.clientHeight);
});
this.resizeObserver.observe(this.stage);
this.update();
}
private teardownScene(): void {
this.resizeObserver?.disconnect();
this.resizeObserver = undefined;
this.scene?.element.remove();
this.scene?.dispose();
this.scene = undefined;
}
private update(): void {
const hass = this._hass;
const config = this.config;
if (!hass || !config) return;
const panelIds = config.layout.panels.map((p) => p.id);
const stateCount = Object.keys(hass.states).length;
if (stateCount !== this.entityCount) {
this.entities = findPowerEntities(hass.states, panelIds);
this.entityCount = stateCount;
}
const { panels, newestMeasurement } = resolvePanelStates(hass.states, this.entities, panelIds);
this.scene?.updatePanels(panels, this.maxPower);
if (this.status) {
const language = hass.locale?.language ?? hass.language ?? "de";
this.status.textContent =
newestMeasurement === undefined
? "Stand: –"
: `Stand: ${new Date(newestMeasurement).toLocaleTimeString(language, {
hour: "2-digit",
minute: "2-digit",
})}`;
}
}
private openMoreInfo(panelId: string): void {
const entityId = this.entities.get(panelId);
if (!entityId) return;
this.dispatchEvent(
new CustomEvent("hass-more-info", { detail: { entityId }, bubbles: true, composed: true }),
);
}
}
if (!customElements.get(CARD_TYPE)) {
customElements.define(CARD_TYPE, SolarEdgeRoofCard);
const cards = ((window as unknown as { customCards?: unknown[] }).customCards ??= []);
cards.push({
type: CARD_TYPE,
name: "SolarEdge Dach",
description: "3D-Dachansicht mit der aktuellen Leistung jedes Panels",
});
}
+40
View File
@@ -0,0 +1,40 @@
/** A point in metres: x = east, y = north, z = up. */
export type Point3 = [number, number, number];
export interface RoofConfig {
/** Name of the Dachfläche, e.g. "west1". */
name: string;
/** Outline of the roof surface in drawing order. */
outline: Point3[];
}
export interface PanelConfig {
/** Panel-Position, e.g. "1.2.7". */
id: string;
roof?: string;
/** Lower left, lower right, upper right, upper left (upper = up-slope). */
corners: [Point3, Point3, Point3, Point3];
}
export interface RoofCardConfig {
type: string;
title?: string;
/** Skalenmaximum in W: power at which a panel reaches the brightest colour. */
max_power?: number;
layout: {
roofs: RoofConfig[];
panels: PanelConfig[];
};
}
export interface HassEntity {
entity_id: string;
state: string;
attributes: Record<string, unknown>;
}
export interface Hass {
states: Record<string, HassEntity>;
locale?: { language?: string };
language?: string;
}
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"strict": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,
"types": []
},
"include": ["src", "vite.config.ts"]
}
+19
View File
@@ -0,0 +1,19 @@
import { defineConfig } from "vite";
export default defineConfig({
build: {
lib: {
entry: "src/solaredge-roof-card.ts",
formats: ["es"],
fileName: () => "solaredge-roof-card.js",
},
outDir: "../custom_components/solaredge_optimizers/frontend",
emptyOutDir: true,
target: "es2022",
minify: true,
sourcemap: false,
},
test: {
environment: "node",
},
});
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "ha-solaredge-optimizers"
version = "0.4.0"
version = "0.5.0"
description = "Home Assistant custom integration for SolarEdge optimizer data"
readme = "README.md"
requires-python = ">=3.14.2"
+392
View File
@@ -0,0 +1,392 @@
"""Convert the SolarEdge portal's site model into a solaredge-roof-card layout.
The SolarEdge Monitoring portal renders its 3D site view from two documents:
* ``GET /services/layout/physical/site/{siteId}`` (the *physical layout*), which
lists the strings with their optimizers in display order and links to
* the *site model* (``awsJsonModelDownloadLink``), which holds roof polygons,
vertex heights and module groups in metres (x = east, y = north, z = up).
This script reads both files once and prints the ``layout`` block for the card
configuration. Nothing in Home Assistant depends on the portal afterwards.
Usage::
python scripts/convert_portal_layout.py physical.json model.json \
[--areas areas.json] > layout.yaml
``areas.json`` uses the same format as the integration's area mapping
(``{"west1": ["1.1.1", ...]}``) and names the roofs after the areas of the
panels on them.
"""
from __future__ import annotations
import argparse
import json
import math
import sys
from collections import Counter
from dataclasses import dataclass
from typing import Any
MODULE_OFFSET_M = 0.05
"""Height of a panel above its roof surface, so the two never z-fight."""
FLAT_ROOF_SLOPE = 0.02
"""Roofs with a smaller slope (rise per metre) count as flat."""
type Point2 = tuple[float, float]
type Point3 = tuple[float, float, float]
@dataclass(frozen=True)
class Plane:
"""Roof plane z = a*x + b*y + c."""
a: float
b: float
c: float
def z(self, x: float, y: float) -> float:
"""Return the plane height at (x, y)."""
return self.a * x + self.b * y + self.c
@dataclass(frozen=True)
class Panel:
"""One panel with its corners in the card's coordinate system."""
panel_id: str
roof_id: str
corners: tuple[Point3, Point3, Point3, Point3]
"""Lower left, lower right, upper right, upper left (upper = up-slope)."""
def decode_module_handle(handle: int) -> tuple[int, int]:
"""Return (row, column) of a module handle id.
The low 32 bits are the module group id, followed by an 11-bit signed row
and an 11-bit signed column.
"""
upper = handle >> 32
row = upper & 0x7FF
column = (upper >> 11) & 0x7FF
if row >= 1024:
row -= 2048
if column >= 1024:
column -= 2048
return row, column
def polygon_outline(model: dict[str, Any], polygon_id: str) -> list[Point3]:
"""Return the polygon's vertices in edge order."""
vertices = model["vertices"]
edges = model["edges"]
pairs = [
(edges[edge_id]["vertexAId"], edges[edge_id]["vertexBId"])
for edge_id in model["polygons"][polygon_id]["edgeIds"]
]
loop = [pairs[0][0], pairs[0][1]]
remaining = pairs[1:]
while remaining:
edge = next((pair for pair in remaining if loop[-1] in pair), None)
if edge is None:
msg = f"Polygon {polygon_id} is not a closed loop"
raise ValueError(msg)
remaining.remove(edge)
loop.append(edge[1] if edge[0] == loop[-1] else edge[0])
if loop[0] == loop[-1]:
loop.pop()
return [
(
vertices[vertex_id]["position"]["x"],
vertices[vertex_id]["position"]["y"],
vertices[vertex_id]["heightWithoutPolygonGroups"],
)
for vertex_id in loop
]
def fit_plane(points: list[Point3]) -> Plane:
"""Least-squares plane through the points."""
n = len(points)
sx = sum(p[0] for p in points)
sy = sum(p[1] for p in points)
sz = sum(p[2] for p in points)
sxx = sum(p[0] * p[0] for p in points)
syy = sum(p[1] * p[1] for p in points)
sxy = sum(p[0] * p[1] for p in points)
sxz = sum(p[0] * p[2] for p in points)
syz = sum(p[1] * p[2] for p in points)
a, b, c = _solve3(
[[sxx, sxy, sx], [sxy, syy, sy], [sx, sy, float(n)]], [sxz, syz, sz]
)
return Plane(a, b, c)
def _solve3(matrix: list[list[float]], rhs: list[float]) -> list[float]:
rows = [row[:] + [value] for row, value in zip(matrix, rhs, strict=True)]
for col in range(3):
pivot = max(range(col, 3), key=lambda r: abs(rows[r][col]))
rows[col], rows[pivot] = rows[pivot], rows[col]
for r in range(3):
if r != col:
factor = rows[r][col] / rows[col][col]
rows[r] = [
x - factor * y for x, y in zip(rows[r], rows[col], strict=True)
]
return [rows[i][3] / rows[i][i] for i in range(3)]
def point_in_polygon(point: Point2, outline: list[Point3], tolerance: float) -> bool:
"""Return whether the point lies inside or within tolerance of the outline."""
x, y = point
inside = False
edges = list(zip(outline, outline[1:] + outline[:1], strict=True))
for (x1, y1, _), (x2, y2, _) in edges:
if (y1 > y) != (y2 > y) and x < (x2 - x1) * (y - y1) / (y2 - y1) + x1:
inside = not inside
if inside:
return True
for (x1, y1, _), (x2, y2, _) in edges:
dx, dy = x2 - x1, y2 - y1
t = max(0.0, min(1.0, ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy)))
if math.hypot(x - x1 - t * dx, y - y1 - t * dy) <= tolerance:
return True
return False
def module_group_panels(
group: dict[str, Any],
details: dict[str, Any],
module_size: tuple[float, float],
row_sign: int,
rotation: float,
) -> list[tuple[int, list[Point2], Point2]]:
"""Place the modules of one group on the ground plan.
Returns (handle, plan corners, up-slope unit vector) per module. Columns run
along the eave, rows up the slope; the group position is the outer corner of
module (0, 0). The up-slope vector is the direction in which the module
rises, taken from its azimuth.
"""
azimuth = details["azimuth"]
tilt = details["tilt"]
up = (-math.sin(azimuth), -math.cos(azimuth))
along = (-math.cos(azimuth), math.sin(azimuth))
length, width = module_size
if group["orientation"] == "PORTRAIT":
cell_w, cell_h = width, length
else:
cell_w, cell_h = length, width
# The portal measures columns along -along, so its rotation runs the other way.
cos_r, sin_r = math.cos(rotation), -math.sin(rotation)
cos_t = math.cos(tilt)
origin = (group["position"]["x"], group["position"]["y"])
def to_plan(u: float, v: float) -> Point2:
u, v = u * cos_r - v * sin_r, u * sin_r + v * cos_r
v *= cos_t
return (
origin[0] + u * along[0] + v * up[0],
origin[1] + u * along[1] + v * up[1],
)
result = []
for handle in details["moduleHandleIds"]:
row, column = decode_module_handle(handle)
u0 = column * (cell_w + group["columnSpacing"])
v0 = row_sign * row * (cell_h + group["rowSpacing"])
v_low = v0 if row_sign > 0 else v0 - cell_h
corners = [
to_plan(u0, v_low),
to_plan(u0 + cell_w, v_low),
to_plan(u0 + cell_w, v_low + cell_h),
to_plan(u0, v_low + cell_h),
]
result.append((handle, corners, up))
return result
def _order_corners(corners: list[Point2], up: Point2) -> list[Point2]:
"""Order corners lower-left, lower-right, upper-right, upper-left.
Seen from above with up-slope pointing up, "right" is up rotated clockwise.
"""
right = (up[1], -up[0])
cx = sum(p[0] for p in corners) / 4
cy = sum(p[1] for p in corners) / 4
def key(p: Point2) -> tuple[bool, bool]:
dx, dy = p[0] - cx, p[1] - cy
return (dx * up[0] + dy * up[1] > 0, dx * right[0] + dy * right[1] > 0)
by_key = {key(p): p for p in corners}
return [
by_key[(False, False)],
by_key[(False, True)],
by_key[(True, True)],
by_key[(True, False)],
]
def convert(
physical: dict[str, Any],
site_model: dict[str, Any],
areas: dict[str, list[str]] | None = None,
) -> dict[str, Any]:
"""Build the card layout from the portal documents."""
model = site_model["modelData"]
group_details = site_model["moduleGroupDetails"]
module_model = next(iter(model["moduleModels"].values()))
module_size = (module_model["length"] / 1000, module_model["width"] / 1000)
devices = physical["physicalDevicesMap"]
serial_to_panel_id: dict[str, str] = {}
strings = devices["strings"].values()
inverters = devices["inverters"]
for string in strings:
inverter_seq = inverters[string["inverterId"]]["sequenceNumber"]
for position, optimizer_key in enumerate(string["optimizerIds"], start=1):
serial = devices["optimizers"][str(optimizer_key)]["serialNumber"]
serial_to_panel_id[serial] = (
f"{inverter_seq}.{string['sequenceNumber']}.{position}"
)
handle_to_panel_id = {
int(optimizer["moduleIds"][0]): serial_to_panel_id[optimizer["serialNumber"]]
for optimizer in model["optimizers"].values()
if optimizer["moduleIds"] and optimizer["serialNumber"] in serial_to_panel_id
}
outlines = {pid: polygon_outline(model, pid) for pid in model["polygons"]}
planes = {pid: fit_plane(points) for pid, points in outlines.items()}
panels: list[Panel] = []
for group_id, details in group_details.items():
group = model["moduleGroups"][group_id]
polygon_id = group["polygonId"]
outline = outlines[polygon_id]
# The portal flips the row direction for some groups (seen on a rotated
# group on a flat roof). Pick the direction that keeps the modules on
# their roof.
plane = planes[polygon_id]
# On a flat roof the module azimuth already fixes the grid direction and
# facetRotation is an absolute angle that would rotate it a second time.
flat = math.hypot(plane.a, plane.b) < FLAT_ROOF_SLOPE
rotation = 0.0 if flat else group["facetRotation"]
candidates = [
module_group_panels(group, details, module_size, sign, rotation)
for sign in (1, -1)
]
placed = max(
candidates,
key=lambda modules: sum(
point_in_polygon(corner, outline, 0.05)
for _, corners, _ in modules
for corner in corners
),
)
module_tilt = math.tan(details["tilt"])
for handle, corners, up in placed:
panel_id = handle_to_panel_id.get(handle)
if panel_id is None:
continue
ordered = _order_corners(corners, up)
cx = sum(p[0] for p in ordered) / 4
cy = sum(p[1] for p in ordered) / 4
base = plane.z(cx, cy) + MODULE_OFFSET_M
corners3 = tuple(
(
p[0],
p[1],
base + ((p[0] - cx) * up[0] + (p[1] - cy) * up[1]) * module_tilt,
)
for p in ordered
)
panels.append(Panel(panel_id, polygon_id, corners3))
roof_names = _roof_names(outlines, panels, areas or {})
panels.sort(
key=lambda panel: tuple(int(part) for part in panel.panel_id.split("."))
)
return {
"module_power": module_model["stcPower"],
"roofs": [
{"name": roof_names[pid], "outline": [_round3(p) for p in outline]}
for pid, outline in outlines.items()
],
"panels": [
{
"id": panel.panel_id,
"roof": roof_names[panel.roof_id],
"corners": [_round3(p) for p in panel.corners],
}
for panel in panels
],
}
def _roof_names(
outlines: dict[str, list[Point3]],
panels: list[Panel],
areas: dict[str, list[str]],
) -> dict[str, str]:
panel_area = {
panel_id: area for area, panel_ids in areas.items() for panel_id in panel_ids
}
names: dict[str, str] = {}
for index, polygon_id in enumerate(outlines, start=1):
votes = Counter(
panel_area[panel.panel_id]
for panel in panels
if panel.roof_id == polygon_id and panel.panel_id in panel_area
)
names[polygon_id] = votes.most_common(1)[0][0] if votes else f"dach{index}"
return names
def _round3(point: Point3) -> list[float]:
return [round(value, 3) for value in point]
def to_yaml(layout: dict[str, Any]) -> str:
"""Render the layout as a compact YAML block for the card configuration."""
lines = [
"type: custom:solaredge-roof-card",
f"max_power: {layout['module_power']:g}",
"layout:",
" roofs:",
]
for roof in layout["roofs"]:
lines.append(f" - name: {json.dumps(roof['name'], ensure_ascii=False)}")
lines.append(f" outline: {json.dumps(roof['outline'])}")
lines.append(" panels:")
for panel in layout["panels"]:
lines.append(f' - id: "{panel["id"]}"')
lines.append(f" roof: {json.dumps(panel['roof'], ensure_ascii=False)}")
lines.append(f" corners: {json.dumps(panel['corners'])}")
return "\n".join(lines) + "\n"
def main(argv: list[str] | None = None) -> int:
"""Run the converter."""
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("physical", help="physical layout response (JSON)")
parser.add_argument("model", help="site model from awsJsonModelDownloadLink")
parser.add_argument("--areas", help="area mapping JSON used to name roofs")
args = parser.parse_args(argv)
with open(args.physical, encoding="utf-8") as file:
physical = json.load(file)
with open(args.model, encoding="utf-8") as file:
site_model = json.load(file)
areas = None
if args.areas:
with open(args.areas, encoding="utf-8") as file:
areas = json.load(file)
sys.stdout.write(to_yaml(convert(physical, site_model, areas)))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+107
View File
@@ -0,0 +1,107 @@
"""Tests for the portal layout converter."""
from __future__ import annotations
import math
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parents[1] / "scripts"))
from convert_portal_layout import ( # noqa: E402
convert,
decode_module_handle,
point_in_polygon,
)
GROUP_ID = 2686254341
def handle(row: int, column: int, group: int = GROUP_ID) -> int:
"""Encode a module handle like the portal does."""
return (((column & 0x7FF) << 11) | (row & 0x7FF)) << 32 | group
def test_decode_module_handle() -> None:
"""Decode signed row and column from a module handle."""
assert decode_module_handle(GROUP_ID) == (0, 0)
assert decode_module_handle(handle(3, 2)) == (3, 2)
assert decode_module_handle(handle(-1, -2)) == (-1, -2)
def _vertex(x: float, y: float, z: float) -> dict:
return {"position": {"x": x, "y": y}, "heightWithoutPolygonGroups": z}
def _site() -> tuple[dict, dict]:
"""East-facing roof, 30 degrees, eave at x=4 (z=3), ridge at x=0."""
tilt = math.radians(30)
ridge = 3 + 4 * math.tan(tilt)
model = {
"vertices": {
"1": _vertex(0, 0, ridge),
"2": _vertex(4, 0, 3),
"3": _vertex(4, 6, 3),
"4": _vertex(0, 6, ridge),
},
"edges": {
"a": {"vertexAId": "1", "vertexBId": "2"},
"b": {"vertexAId": "2", "vertexBId": "3"},
"c": {"vertexAId": "3", "vertexBId": "4"},
"d": {"vertexAId": "4", "vertexBId": "1"},
},
"polygons": {"p": {"edgeIds": ["a", "b", "c", "d"]}},
"moduleGroups": {
str(GROUP_ID): {
"polygonId": "p",
"facetRotation": 0.0,
"rowSpacing": 0.03,
"columnSpacing": 0.03,
"position": {"x": 3.8, "y": 0.2},
"orientation": "LANDSCAPE",
}
},
"moduleModels": {"1": {"stcPower": 460.0, "length": 1762.0, "width": 1134.0}},
"optimizers": {
"o1": {"serialNumber": "A", "moduleIds": [str(handle(0, 0))]},
"o2": {"serialNumber": "B", "moduleIds": [str(handle(0, 1))]},
},
}
site_model = {
"modelData": model,
"moduleGroupDetails": {
str(GROUP_ID): {
"azimuth": math.radians(90),
"tilt": tilt,
"moduleHandleIds": [handle(0, 0), handle(0, 1)],
}
},
}
physical = {
"physicalDevicesMap": {
"inverters": {"i": {"sequenceNumber": 1}},
"strings": {
"s": {"sequenceNumber": 1, "inverterId": "i", "optimizerIds": [1, 2]}
},
"optimizers": {"1": {"serialNumber": "A"}, "2": {"serialNumber": "B"}},
}
}
return physical, site_model
def test_convert_places_panels_on_their_roof() -> None:
"""Panels get their Panel-Position, lie on the roof and rise up the slope."""
physical, site_model = _site()
layout = convert(physical, site_model, {"ost": ["1.1.1", "1.1.2"]})
assert layout["module_power"] == 460.0
assert [roof["name"] for roof in layout["roofs"]] == ["ost"]
assert [panel["id"] for panel in layout["panels"]] == ["1.1.1", "1.1.2"]
outline = [tuple(p) for p in layout["roofs"][0]["outline"]]
for panel in layout["panels"]:
lower_left, _, _, upper_left = panel["corners"]
assert upper_left[2] > lower_left[2]
for x, y, z in panel["corners"]:
assert point_in_polygon((x, y), outline, 0.01)
roof_z = 3 + (4 - x) * math.tan(math.radians(30))
assert math.isclose(z, roof_z + 0.05, abs_tol=0.01)
+33
View File
@@ -0,0 +1,33 @@
"""Tests for serving the solaredge-roof-card."""
from __future__ import annotations
from unittest.mock import AsyncMock, MagicMock, patch
from homeassistant.core import HomeAssistant
from custom_components.solaredge_optimizers import frontend
async def test_card_is_served_and_loaded(hass: HomeAssistant) -> None:
"""Register the bundle as static path and as extra frontend module."""
hass.http = MagicMock(async_register_static_paths=AsyncMock())
hass.config.components.add("frontend")
with patch.object(frontend, "add_extra_js_url") as add_url:
await frontend.async_register_card(hass)
(paths,), _ = hass.http.async_register_static_paths.call_args
assert paths[0].url_path == "/solaredge_optimizers/solaredge-roof-card.js"
assert paths[0].path.endswith("frontend/solaredge-roof-card.js")
(_, url), _ = add_url.call_args
assert url.startswith("/solaredge_optimizers/solaredge-roof-card.js?v=")
async def test_card_is_skipped_without_frontend(hass: HomeAssistant) -> None:
"""Do nothing when Home Assistant runs without frontend."""
hass.http = MagicMock(async_register_static_paths=AsyncMock())
with patch.object(frontend, "add_extra_js_url") as add_url:
await frontend.async_register_card(hass)
hass.http.async_register_static_paths.assert_not_called()
add_url.assert_not_called()
Generated
+2 -2
View File
@@ -1,5 +1,5 @@
version = 1
revision = 3
revision = 5
requires-python = ">=3.14.2"
[[package]]
@@ -943,7 +943,7 @@ wheels = [
[[package]]
name = "ha-solaredge-optimizers"
version = "0.4.0"
version = "0.5.0"
source = { virtual = "." }
[package.dev-dependencies]