From 0474a24df6c24b9c23ab683be79c995b7e112098 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 10 Jun 2025 12:20:10 +0200 Subject: [PATCH] Allow to open more info using query params (#25733) --- src/panels/lovelace/hui-root.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index 962a366767..6f3d727d4d 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -57,6 +57,7 @@ import { showAlertDialog, showConfirmationDialog, } from "../../dialogs/generic/show-dialog-box"; +import { showMoreInfoDialog } from "../../dialogs/more-info/show-ha-more-info-dialog"; import { QuickBarMode, showQuickBar, @@ -75,9 +76,9 @@ import { getLovelaceStrategy } from "./strategies/get-strategy"; import { isLegacyStrategyConfig } from "./strategies/legacy-strategy"; import type { Lovelace } from "./types"; import "./views/hui-view"; -import "./views/hui-view-container"; import type { HUIView } from "./views/hui-view"; import "./views/hui-view-background"; +import "./views/hui-view-container"; @customElement("hui-root") class HUIRoot extends LitElement { @@ -490,7 +491,16 @@ class HUIRoot extends LitElement { } else if (searchParams.conversation === "1") { this._clearParam("conversation"); this._showVoiceCommandDialog(); + } else if (searchParams["more-info-entity-id"]) { + const entityId = searchParams["more-info-entity-id"]; + this._clearParam("more-info-entity-id"); + // Wait for the next render to ensure the view is fully loaded + // because the more info dialog is closed when the url changes + afterNextRender(() => { + this._showMoreInfoDialog(entityId); + }); } + window.addEventListener("scroll", this._handleWindowScroll, { passive: true, }); @@ -730,6 +740,10 @@ class HUIRoot extends LitElement { showVoiceCommandDialog(this, this.hass, { pipeline_id: "last_used" }); } + private _showMoreInfoDialog(entityId: string): void { + showMoreInfoDialog(this, { entityId }); + } + private _handleEnableEditMode(ev: CustomEvent): void { if (!shouldHandleRequestSelectedEvent(ev)) { return;