From b2af91c83e16555b30c8fed4d8f1c3bcf2d3e6a8 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 13 May 2020 18:51:26 +0200 Subject: [PATCH] Fixes for problems caused by not rebuilding (#5850) --- .../entity-rows/hui-sensor-entity-row.ts | 22 ++++++++++++++++--- src/panels/lovelace/hui-root.ts | 10 +++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts index a842909823..e59f9028e8 100644 --- a/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-sensor-entity-row.ts @@ -15,9 +15,14 @@ import { hasConfigOrEntityChanged } from "../common/has-changed"; import "../components/hui-generic-entity-row"; import "../components/hui-timestamp-display"; import "../components/hui-warning"; -import { EntityConfig, LovelaceRow } from "./types"; +import { LovelaceRow } from "./types"; +import { EntitiesCardEntityConfig } from "../cards/types"; +import { actionHandler } from "../common/directives/action-handler-directive"; +import { hasAction } from "../common/has-action"; +import { ActionHandlerEvent } from "../../../data/lovelace"; +import { handleAction } from "../common/handle-action"; -interface SensorEntityConfig extends EntityConfig { +interface SensorEntityConfig extends EntitiesCardEntityConfig { format?: "relative" | "date" | "time" | "datetime"; } @@ -59,7 +64,14 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow { return html` -
+
${stateObj.attributes.device_class === SENSOR_DEVICE_CLASS_TIMESTAMP && stateObj.state !== "unavailable" && @@ -81,6 +93,10 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow { `; } + private _handleAction(ev: ActionHandlerEvent) { + handleAction(this, this.hass!, this._config!, ev.detail.action); + } + static get styles(): CSSResult { return css` div { diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index e801a0c751..ad52c6a23b 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -424,18 +424,24 @@ class HUIRoot extends LitElement { } if (!oldLovelace || oldLovelace.editMode !== this.lovelace!.editMode) { + const views = this.config && this.config.views; + + // Adjust for higher header + if (!views || views.length < 2) { + fireEvent(this, "iron-resize"); + } + // Leave unused entities when leaving edit mode if ( this.lovelace!.mode === "storage" && viewPath === "hass-unused-entities" ) { - const views = this.config && this.config.views; navigate(this, `${this.route?.prefix}/${views[0]?.path || 0}`); newSelectView = 0; } } - if (!force) { + if (!force && huiView) { huiView.lovelace = this.lovelace; } }