Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions .github/workflows/version-consistency.yml

This file was deleted.

88 changes: 22 additions & 66 deletions custom_components/lotus_view_studio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Lotus View Studio: visual dashboard editing suite for Home Assistant."""

import json
from inspect import signature
from pathlib import Path

Expand All @@ -16,30 +15,17 @@
DOMAIN,
LEGACY_BRAND_URL,
LEGACY_URL_BASE,
MODULE_URL,
PANEL_ICON,
PANEL_PATH,
PANEL_TITLE,
URL_BASE,
VERSIONED_BRAND_URL,
VERSIONED_URL_BASE,
)
from .digicode_security import DigicodeSecurityManager, register_websocket_commands
from .preferences import LotusVisualPreferences, register_preference_websocket_commands

_COMPONENT_DIR = Path(__file__).parent
_FRONTEND_DIR = _COMPONENT_DIR / "frontend"
_BRAND_DIR = _COMPONENT_DIR / "brand"
_MANIFEST_PATH = _COMPONENT_DIR / "manifest.json"


def _package_version() -> str:
"""Return the integration version declared by manifest.json."""
manifest = json.loads(_MANIFEST_PATH.read_text(encoding="utf-8"))
version = str(manifest.get("version", "")).strip()
if not version:
raise ValueError("Lotus View Studio manifest.json does not declare a version")
return version

_FRONTEND_DIR = Path(__file__).parent / "frontend"
_BRAND_DIR = Path(__file__).parent / "brand"

CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)

Expand All @@ -55,11 +41,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.config_entries.async_update_entry(entry, title=PANEL_TITLE)

data = hass.data.setdefault(DOMAIN, {})
package_version = _package_version()
versioned_url_base = f"{VERSIONED_URL_BASE}/{package_version}"
versioned_brand_url = f"{VERSIONED_BRAND_URL}/{package_version}"
module_url = f"{versioned_url_base}/lotus-visual.js"

if not data.get("digicode_security"):
digicode_security = DigicodeSecurityManager(hass)
await digicode_security.async_load()
Expand All @@ -70,50 +51,28 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await preferences.async_load()
register_preference_websocket_commands(hass, preferences)
data["preferences"] = preferences

registered_versions = data.setdefault("static_versions", set())
if package_version not in registered_versions:
static_paths = [
# Versioned routes use their own namespace, so they never overlap
# compatibility routes left by an earlier Lotus release.
StaticPathConfig(versioned_url_base, str(_FRONTEND_DIR), cache_headers=True),
StaticPathConfig(versioned_brand_url, str(_BRAND_DIR), cache_headers=True),
]

# Releases before 0.13.0b4 used a single static_registered flag and
# registered these aliases already. Honor that state during an in-place
# integration reload so routes are never registered twice.
compat_registered = bool(
data.get("compat_static_registered") or data.get("static_registered")
if not data.get("static_registered"):
await hass.http.async_register_static_paths(
[
StaticPathConfig(URL_BASE, str(_FRONTEND_DIR), cache_headers=False),
StaticPathConfig(BRAND_URL, str(_BRAND_DIR), cache_headers=False),
# Compatibility aliases for browser caches / manually registered
# resources from Lotus Visual releases prior to 0.12.0.
StaticPathConfig(LEGACY_URL_BASE, str(_FRONTEND_DIR), cache_headers=False),
StaticPathConfig(LEGACY_BRAND_URL, str(_BRAND_DIR), cache_headers=False),
]
)
if not compat_registered:
static_paths.extend(
[
StaticPathConfig(URL_BASE, str(_FRONTEND_DIR), cache_headers=False),
StaticPathConfig(BRAND_URL, str(_BRAND_DIR), cache_headers=False),
StaticPathConfig(
LEGACY_URL_BASE, str(_FRONTEND_DIR), cache_headers=False
),
StaticPathConfig(
LEGACY_BRAND_URL, str(_BRAND_DIR), cache_headers=False
),
]
)

await hass.http.async_register_static_paths(static_paths)
registered_versions.add(package_version)
data["compat_static_registered"] = True
data.pop("static_registered", None)

frontend.add_extra_js_url(hass, module_url)
data["static_registered"] = True

frontend.add_extra_js_url(hass, MODULE_URL)

panel_kwargs = {
"hass": hass,
"frontend_url_path": PANEL_PATH,
"webcomponent_name": "lotus-visual-manager",
"sidebar_title": PANEL_TITLE,
"sidebar_icon": PANEL_ICON,
"module_url": module_url,
"module_url": MODULE_URL,
"require_admin": True,
}

Expand All @@ -125,19 +84,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

await panel_custom.async_register_panel(**panel_kwargs)

data[entry.entry_id] = {"module_url": module_url}
data[entry.entry_id] = {"module_url": MODULE_URL}
return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Lotus View Studio."""
frontend.async_remove_panel(hass, PANEL_PATH, warn_if_unknown=False)
entry_data = hass.data.get(DOMAIN, {}).get(entry.entry_id, {})
module_url = entry_data.get("module_url")
if module_url:
try:
frontend.remove_extra_js_url(hass, module_url)
except (KeyError, ValueError):
pass
try:
frontend.remove_extra_js_url(hass, MODULE_URL)
except (KeyError, ValueError):
pass
hass.data.get(DOMAIN, {}).pop(entry.entry_id, None)
return True
4 changes: 2 additions & 2 deletions custom_components/lotus_view_studio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

DOMAIN = "lotus_view_studio"
LEGACY_DOMAIN = "lotus_visual"
VERSION = "0.13.0b3"
URL_BASE = "/lotus_view_studio_static"
BRAND_URL = "/lotus_view_studio_brand"
VERSIONED_URL_BASE = "/lotus_view_studio_static_v"
VERSIONED_BRAND_URL = "/lotus_view_studio_brand_v"
LEGACY_URL_BASE = "/lotus_visual_static"
LEGACY_BRAND_URL = "/lotus_visual_brand"
PANEL_PATH = "lotus-view-studio"
PANEL_TITLE = "Lotus View Studio"
PANEL_ICON = "lotus:lotus"
MODULE_URL = f"{URL_BASE}/lotus-visual.js?v={VERSION}"
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* and already-mounted pickers are rebuilt once.
*/

import { registerLotusCards } from "./lotus-card-registry.js";
import { lotusDebug, lotusSetHass } from "./lotus-i18n.js";
import { registerLotusCards } from "./lotus-card-registry.js?v=0.13.0b3";
import { lotusDebug, lotusSetHass } from "./lotus-i18n.js?v=0.13.0b3";

const PATCHED = Symbol.for("lotusVisual.cardPickerPatched.v1");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Lotus View Studio custom-card registry.
*/
import { lotusT } from "./lotus-i18n.js";
import { lotusT } from "./lotus-i18n.js?v=0.13.0b3";

export const LOTUS_STACK_CARD_ENTRY = Object.freeze({
type: "lotus-visual-stack",
Expand Down
5 changes: 2 additions & 3 deletions custom_components/lotus_view_studio/frontend/lotus-core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
import { lotusT } from "./lotus-i18n.js";
import { lotusT } from "./lotus-i18n.js?v=0.13.0b3";

export const LOTUS_VISUAL_VERSION = LOTUS_PACKAGE_VERSION;
export const LOTUS_VISUAL_VERSION = "0.13.0b3";
export const LOTUS_LAYOUT_KEY = "lotus";
export const LOTUS_LEGACY_LAYOUT_KEYS = Object.freeze(["lotus_visual_layout"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* 3) application-layer RSA-OAEP transport + server-side salted PIN hash.
*/

import { deepClone, clamp } from "./lotus-core.js";
import { lotusDebug, lotusSetHass, lotusT } from "./lotus-i18n.js";
import { deepClone, clamp } from "./lotus-core.js?v=0.13.0b3";
import { lotusDebug, lotusSetHass, lotusT } from "./lotus-i18n.js?v=0.13.0b3";

const LOTUS_DIGICODE_VERSION = "1.3.7";
const LOTUS_DIGICODE_TYPE = "custom:lotus-digicode-card";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
/*
* Lotus View Studio direct-create bridge
* Lotus View Studio direct-create bridge — v0.13.0b3
*
* Goal
* ----
Expand Down Expand Up @@ -204,7 +203,7 @@ function installCaptureBridge() {
.catch(() => {});

window.LotusVisual = Object.assign(window.LotusVisual || {}, {
directCreateBridge: LOTUS_PACKAGE_VERSION,
directCreateBridge: "0.13.0b3",
directCreateMode: "capture-import-before-dialog",
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
/*
* Lotus View Studio edit-dialog bridge
* Lotus View Studio edit-dialog bridge — v0.13.0b3
*
* Home Assistant's native hui-dialog-edit-card owns two columns on desktop:
* - .element-editor (ha-scrollbar)
Expand All @@ -26,7 +25,7 @@ import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
* frontend. Non-Lotus cards are not changed.
*/

import { lotusDebug, lotusSetHass, lotusT } from "./lotus-i18n.js";
import { lotusDebug, lotusSetHass, lotusT } from "./lotus-i18n.js?v=0.13.0b3";

const PATCHED = Symbol.for("lotusVisual.editDialogBridge.v0837");
const CAPTURE_INSTALLED = Symbol.for("lotusVisual.editDialogCapture.v0837");
Expand Down Expand Up @@ -935,7 +934,7 @@ function installBridge() {
.catch(() => {});

window.LotusVisual = Object.assign(window.LotusVisual || {}, {
editDialogBridge: LOTUS_PACKAGE_VERSION,
editDialogBridge: "0.13.0b3",
editDialogMode: "visual-preview-yaml-code-only",
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
/* European language pack for Lotus View Studio. */
export const LOTUS_EUROPE_VERSION = LOTUS_PACKAGE_VERSION;
/* European language pack for Lotus View Studio 0.13.0b3. */
export const LOTUS_EUROPE_VERSION = "0.13.0b3";
export const LOTUS_EUROPE_LANGUAGES = Object.freeze([
{ value: "nl", nativeName: "Nederlands", englishName: "Dutch" },
{ value: "pl", nativeName: "Polski", englishName: "Polish" },
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions custom_components/lotus_view_studio/frontend/lotus-i18n.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
import {
LOTUS_EXTRA_LANGUAGES,
LOTUS_EXTRA_EXACT,
LOTUS_EXTRA_REPLACEMENTS,
LOTUS_EXTRA_SELECTOR_LABELS,
LOTUS_RTL_LANGUAGES,
} from "./lotus-i18n-extra.js";
} from "./lotus-i18n-extra.js?v=0.13.0b3";
import {
LOTUS_EUROPE_LANGUAGES,
LOTUS_EUROPE_EXACT,
LOTUS_EUROPE_REPLACEMENTS,
LOTUS_EUROPE_SELECTOR_LABELS,
} from "./lotus-i18n-europe.js";
} from "./lotus-i18n-europe.js?v=0.13.0b3";

/*
* Lotus View Studio internationalization core.
* The UI follows the Home Assistant user locale by default and supports
* a per-user manual override persisted by the Lotus View Studio backend.
*/

export const LOTUS_I18N_VERSION = LOTUS_PACKAGE_VERSION;
export const LOTUS_I18N_VERSION = "0.13.0b3";

export const LOTUS_LANGUAGES = Object.freeze([
{ value: "auto", nativeName: "Automatique — Home Assistant", englishName: "Automatic — Home Assistant" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LOTUS_PACKAGE_VERSION } from "./lotus-version.js";
/*
* Lotus View Studio native picture-elements responsive bridge
* Lotus View Studio native picture-elements responsive bridge — v0.13.0b3
*
* Lotus Stack is deliberately saved as a native Home Assistant picture-elements
* card. Native state-icon/state-label elements do not know the logical Lotus
Expand Down Expand Up @@ -198,6 +197,6 @@ if (labelClass) installLabelBridge(labelClass);
else customElements.whenDefined("hui-state-label-element").then(() => installLabelBridge(customElements.get("hui-state-label-element")));

window.LotusVisual = Object.assign(window.LotusVisual || {}, {
iconSizeBridge: LOTUS_PACKAGE_VERSION,
stackResponsiveBridge: LOTUS_PACKAGE_VERSION,
iconSizeBridge: "0.13.0b3",
stackResponsiveBridge: "0.13.0b3",
});
Loading
Loading