From ffa96d789f7f62a34857a6286a14bb85b881c0e3 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 6 Aug 2024 16:12:36 +0200 Subject: [PATCH 1/4] Update weather card layout options (#21604) --- src/panels/lovelace/cards/hui-weather-forecast-card.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/hui-weather-forecast-card.ts b/src/panels/lovelace/cards/hui-weather-forecast-card.ts index fadca1dd5aef..0f0c5d76b5bf 100644 --- a/src/panels/lovelace/cards/hui-weather-forecast-card.ts +++ b/src/panels/lovelace/cards/hui-weather-forecast-card.ts @@ -430,6 +430,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard { this._config?.show_current !== false && this._config?.show_forecast !== false ) { + return { + grid_columns: 4, + grid_min_columns: 2, + grid_rows: 4, + grid_min_rows: 4, + }; + } + if (this._config?.show_forecast !== false) { return { grid_columns: 4, grid_min_columns: 2, @@ -441,7 +449,7 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard { grid_columns: 4, grid_min_columns: 2, grid_rows: 2, - grid_min_rows: 1, + grid_min_rows: 2, }; } From 7d218c89ae2d2c223240c5401605756c417bef2c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 6 Aug 2024 16:13:12 +0200 Subject: [PATCH 2/4] Improve state badge migration (#21603) --- src/panels/lovelace/badges/hui-badge.ts | 6 -- .../lovelace/badges/hui-state-label-badge.ts | 78 ++++--------------- .../badge-editor/hui-dialog-edit-badge.ts | 4 - .../hui-state-label-badge-editor.ts | 45 +++++++++++ 4 files changed, 61 insertions(+), 72 deletions(-) create mode 100644 src/panels/lovelace/editor/config-elements/hui-state-label-badge-editor.ts diff --git a/src/panels/lovelace/badges/hui-badge.ts b/src/panels/lovelace/badges/hui-badge.ts index bbcd083c5507..7637d2c464c1 100644 --- a/src/panels/lovelace/badges/hui-badge.ts +++ b/src/panels/lovelace/badges/hui-badge.ts @@ -57,9 +57,6 @@ export class HuiBadge extends ReactiveElement { } private _updateElement(config: LovelaceBadgeConfig) { - if (config.type === "state-label") { - config = { display_type: "complete", ...config, type: "entity" }; - } if (!this._element) { return; } @@ -69,9 +66,6 @@ export class HuiBadge extends ReactiveElement { } private _loadElement(config: LovelaceBadgeConfig) { - if (config.type === "state-label") { - config = { display_type: "complete", ...config, type: "entity" }; - } this._element = createBadgeElement(config); this._elementConfig = config; if (this.hass) { diff --git a/src/panels/lovelace/badges/hui-state-label-badge.ts b/src/panels/lovelace/badges/hui-state-label-badge.ts index 89751a720cb4..c3c273cc627a 100644 --- a/src/panels/lovelace/badges/hui-state-label-badge.ts +++ b/src/panels/lovelace/badges/hui-state-label-badge.ts @@ -1,71 +1,25 @@ -import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; -import { customElement, property, state } from "lit/decorators"; -import { ifDefined } from "lit/directives/if-defined"; +import { customElement } from "lit/decorators"; import "../../../components/entity/ha-state-label-badge"; -import { ActionHandlerEvent } from "../../../data/lovelace/action_handler"; -import { HomeAssistant } from "../../../types"; -import { actionHandler } from "../common/directives/action-handler-directive"; -import { handleAction } from "../common/handle-action"; -import { hasAction } from "../common/has-action"; -import { LovelaceBadge } from "../types"; -import { StateLabelBadgeConfig } from "./types"; +import { HuiStateLabelBadgeEditor } from "../editor/config-elements/hui-state-label-badge-editor"; +import { HuiEntityBadge } from "./hui-entity-badge"; +import { EntityBadgeConfig, StateLabelBadgeConfig } from "./types"; @customElement("hui-state-label-badge") -export class HuiStateLabelBadge extends LitElement implements LovelaceBadge { - @property({ attribute: false }) public hass?: HomeAssistant; - - @state() protected _config?: StateLabelBadgeConfig; - - public setConfig(config: StateLabelBadgeConfig): void { - this._config = config; +export class HuiStateLabelBadge extends HuiEntityBadge { + public static async getConfigElement(): Promise { + await import("../editor/config-elements/hui-state-label-badge-editor"); + return document.createElement("hui-state-label-badge-editor"); } - protected render() { - if (!this._config || !this.hass) { - return nothing; - } - - const stateObj = this.hass.states[this._config.entity!]; - - return html` - - `; - } - - private _handleAction(ev: ActionHandlerEvent) { - handleAction(this, this.hass!, this._config!, ev.detail.action!); - } + // @ts-ignore + public override setConfig(config: StateLabelBadgeConfig): void { + const entityBadgeConfig: EntityBadgeConfig = { + type: "entity", + entity: config.entity, + display_type: config.show_name === false ? "standard" : "complete", + }; - static get styles(): CSSResultGroup { - return css` - ha-state-label-badge:focus { - outline: none; - background: var(--divider-color); - border-radius: 4px; - } - ha-state-label-badge { - display: inline-block; - padding: 4px 2px 4px 2px; - margin: -4px -2px -4px -2px; - } - `; + this._config = entityBadgeConfig; } } diff --git a/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts b/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts index efd61b5309fa..b469ae9d189b 100644 --- a/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts +++ b/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts @@ -109,10 +109,6 @@ export class HuiDialogEditBadge this._badgeConfig = badge != null ? ensureBadgeConfig(badge) : badge; } - if (this._badgeConfig?.type === "state-label") { - this._badgeConfig = { ...this._badgeConfig, type: "entity" }; - } - this.large = false; if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) { this._badgeConfig = deepFreeze(this._badgeConfig); diff --git a/src/panels/lovelace/editor/config-elements/hui-state-label-badge-editor.ts b/src/panels/lovelace/editor/config-elements/hui-state-label-badge-editor.ts new file mode 100644 index 000000000000..230618ef47d0 --- /dev/null +++ b/src/panels/lovelace/editor/config-elements/hui-state-label-badge-editor.ts @@ -0,0 +1,45 @@ +import { customElement } from "lit/decorators"; +import { assert, assign, boolean, object, optional, string } from "superstruct"; +import "../../../../components/ha-form/ha-form"; +import { EntityBadgeConfig } from "../../badges/types"; +import "../hui-sub-element-editor"; +import { actionConfigStruct } from "../structs/action-struct"; +import { baseLovelaceBadgeConfig } from "../structs/base-badge-struct"; +import "./hui-card-features-editor"; +import { HuiEntityBadgeEditor } from "./hui-entity-badge-editor"; + +const badgeConfigStruct = assign( + baseLovelaceBadgeConfig, + object({ + entity: optional(string()), + name: optional(string()), + icon: optional(string()), + show_entity_picture: optional(boolean()), + tap_action: optional(actionConfigStruct), + show_name: optional(boolean()), + image: optional(string()), + }) +); + +@customElement("hui-state-label-badge-editor") +export class HuiStateLabelBadgeEditor extends HuiEntityBadgeEditor { + // @ts-ignore + public override setConfig(config: StateLabelBadgeConfig): void { + assert(config, badgeConfigStruct); + + const entityBadgeConfig: EntityBadgeConfig = { + type: "entity", + entity: config.entity, + display_type: config.show_name === false ? "standard" : "complete", + }; + + // @ts-ignore + this._config = entityBadgeConfig; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-state-label-badge-editor": HuiStateLabelBadgeEditor; + } +} From b23aacef841fc372986da41975ff1e7728ffd67d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 6 Aug 2024 16:33:54 +0200 Subject: [PATCH 3/4] Condition testing display fix (#21606) --- .../editor/conditions/ha-card-condition-editor.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/panels/lovelace/editor/conditions/ha-card-condition-editor.ts b/src/panels/lovelace/editor/conditions/ha-card-condition-editor.ts index fa9c8d54816f..5ab2ee26139c 100644 --- a/src/panels/lovelace/editor/conditions/ha-card-condition-editor.ts +++ b/src/panels/lovelace/editor/conditions/ha-card-condition-editor.ts @@ -235,9 +235,11 @@ export class HaCardConditionEditor extends LitElement { ? this.hass.localize( "ui.panel.lovelace.editor.condition-editor.testing_pass" ) - : this.hass.localize( - "ui.panel.lovelace.editor.condition-editor.testing_error" - ) + : this._testingResult === false + ? this.hass.localize( + "ui.panel.lovelace.editor.condition-editor.testing_error" + ) + : nothing } From 9c6aef033d4e432d936ceac42035e40101e1c8af Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 6 Aug 2024 16:48:29 +0200 Subject: [PATCH 4/4] Add indicator/alert to YAML integrations on integration page (#21607) --- .../integrations/ha-config-integration-page.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/panels/config/integrations/ha-config-integration-page.ts b/src/panels/config/integrations/ha-config-integration-page.ts index 8945c6265973..bf576443638b 100644 --- a/src/panels/config/integrations/ha-config-integration-page.ts +++ b/src/panels/config/integrations/ha-config-integration-page.ts @@ -13,6 +13,7 @@ import { mdiDevices, mdiDotsVertical, mdiDownload, + mdiFileCodeOutline, mdiHandExtendedOutline, mdiOpenInNew, mdiPackageVariant, @@ -329,6 +330,22 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) { )}` : ""} + ${normalEntries.length === 0 && + this._manifest && + !this._manifest.config_flow && + this.hass.config.components.find( + (comp) => comp.split(".")[0] === this.domain + ) + ? html`${this.hass.localize( + "ui.panel.config.integrations.config_entry.no_config_flow" + )}` + : ""}