From 4e9b11872898044a996fedf0856fcb3a9f635eb3 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:42:01 -0700 Subject: [PATCH 01/10] Ensure energy card titles always displayed (#18432) --- src/panels/energy/ha-panel-energy.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/panels/energy/ha-panel-energy.ts b/src/panels/energy/ha-panel-energy.ts index 74ae7dfd7b6c..c9cf85f45bce 100644 --- a/src/panels/energy/ha-panel-energy.ts +++ b/src/panels/energy/ha-panel-energy.ts @@ -48,6 +48,9 @@ class PanelEnergy extends LitElement { if (oldHass?.locale !== this.hass.locale) { this._setLovelace(); } + if (oldHass && oldHass.localize !== this.hass.localize) { + this._reloadView(); + } } protected render(): TemplateResult { From d3cc57d8b4f5403ca2d4ddc0b877d74cadf1cb45 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 12:53:17 +0200 Subject: [PATCH 02/10] Don't use lookbehind assertion in slugify (#18438) --- src/common/string/slugify.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/string/slugify.ts b/src/common/string/slugify.ts index ddf378059cbf..b7ddfed77c90 100644 --- a/src/common/string/slugify.ts +++ b/src/common/string/slugify.ts @@ -14,7 +14,7 @@ export const slugify = (value: string, delimiter = "_") => { .toString() .toLowerCase() .replace(p, (c) => b.charAt(a.indexOf(c))) // Replace special characters - .replace(/(?<=\d),(?=\d)/g, "") // Remove Commas between numbers + .replace(/(\d),(?=\d)/g, "$1") // Remove Commas between numbers .replace(/[^a-z0-9]+/g, delimiter) // Replace all non-word characters .replace(new RegExp(`(${delimiter})\\1+`, "g"), "$1") // Replace multiple delimiters with single delimiter .replace(new RegExp(`^${delimiter}+`), "") // Trim delimiter from start of text From 951b88ab4cb43704410d2f4a04e2d35d224944cb Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:27:01 +0200 Subject: [PATCH 03/10] Fix change entity in dev tools state (#18441) --- src/panels/developer-tools/state/developer-tools-state.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/panels/developer-tools/state/developer-tools-state.ts b/src/panels/developer-tools/state/developer-tools-state.ts index 6265b89f1eb0..a47960a44288 100644 --- a/src/panels/developer-tools/state/developer-tools-state.ts +++ b/src/panels/developer-tools/state/developer-tools-state.ts @@ -125,7 +125,7 @@ class HaPanelDevState extends LitElement { autofocus .hass=${this.hass} .value=${this._entityId} - @change=${this._entityIdChanged} + @value-changed=${this._entityIdChanged} allow-custom-entity item-label-path="entity_id" > @@ -347,7 +347,8 @@ class HaPanelDevState extends LitElement { ev.preventDefault(); } - private _entityIdChanged() { + private _entityIdChanged(ev: CustomEvent) { + this._entityId = ev.detail.value; if (!this._entityId) { this._entity = undefined; this._state = ""; From 1a2312460ad9edf8704066236a267ef5e13796ee Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 27 Oct 2023 13:29:00 +0200 Subject: [PATCH 04/10] Disable resource panel in safe mode (#18437) --- .../resources/ha-config-lovelace-resources.ts | 62 ++++++++++++++++++- src/panels/lovelace/common/load-resources.ts | 5 -- src/translations/en.json | 2 + 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts b/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts index a1733e094040..5dc3abbcfe75 100644 --- a/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts +++ b/src/panels/config/lovelace/resources/ha-config-lovelace-resources.ts @@ -1,5 +1,12 @@ import { mdiPlus } from "@mdi/js"; -import { html, LitElement, PropertyValues, TemplateResult } from "lit"; +import { + css, + CSSResultGroup, + html, + LitElement, + PropertyValues, + TemplateResult, +} from "lit"; import { customElement, property, state } from "lit/decorators"; import memoize from "memoize-one"; import { stringCompare } from "../../../../common/string/compare"; @@ -7,6 +14,7 @@ import { DataTableColumnContainer, RowClickedEvent, } from "../../../../components/data-table/ha-data-table"; +import "../../../../components/ha-card"; import "../../../../components/ha-fab"; import "../../../../components/ha-svg-icon"; import { @@ -21,7 +29,9 @@ import { showConfirmationDialog, } from "../../../../dialogs/generic/show-dialog-box"; import "../../../../layouts/hass-loading-screen"; +import "../../../../layouts/hass-subpage"; import "../../../../layouts/hass-tabs-subpage-data-table"; +import { haStyle } from "../../../../resources/styles"; import { HomeAssistant, Route } from "../../../../types"; import { loadLovelaceResources } from "../../../lovelace/common/load-resources"; import { lovelaceTabs } from "../ha-config-lovelace"; @@ -72,6 +82,36 @@ export class HaConfigLovelaceRescources extends LitElement { return html` `; } + if (this.hass.config.safe_mode) { + return html` + +
+ +
+

+ ${this.hass.localize( + "ui.panel.config.lovelace.resources.unavailable" + )} +

+

+ ${this.hass.localize( + "ui.panel.config.lovelace.resources.unavailable_safe_mode" + )} +

+
+
+
+
+ `; + } + return html` , hass: HomeAssistant ) => { - // Don't load ressources on safe mode - // Sometimes, hass.config is null but it should not. - if (hass.config?.safe_mode) { - return; - } resources.forEach((resource) => { const normalizedUrl = new URL( resource.url, diff --git a/src/translations/en.json b/src/translations/en.json index c99285a8c0b9..13edc9aa8ec5 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2140,6 +2140,8 @@ "js": "JavaScript file (deprecated)", "module": "JavaScript module" }, + "unavailable": "Resources unavailable", + "unavailable_safe_mode": "Resources are not available in safe mode", "picker": { "headers": { "url": "URL", From 9207f6c4073e3ba6cb7f1fd8706b59a6bcd9a15a Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 27 Oct 2023 13:29:41 +0200 Subject: [PATCH 05/10] Fix unit of measurement not displayed in entity settings (#18440) --- src/panels/config/entities/entity-registry-settings-editor.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/panels/config/entities/entity-registry-settings-editor.ts b/src/panels/config/entities/entity-registry-settings-editor.ts index 42c64edd64df..0241542addea 100644 --- a/src/panels/config/entities/entity-registry-settings-editor.ts +++ b/src/panels/config/entities/entity-registry-settings-editor.ts @@ -200,6 +200,8 @@ export class EntityRegistrySettingsEditor extends LitElement { this._name = this.entry.name || ""; this._icon = this.entry.icon || ""; + this._deviceClass = + this.entry.device_class || this.entry.original_device_class; this._origEntityId = this.entry.entity_id; this._areaId = this.entry.area_id; this._entityId = this.entry.entity_id; From 4f09485b20047945e4f16bd9dd68b66eeb54fd56 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 15:47:37 +0200 Subject: [PATCH 06/10] =?UTF-8?q?Update=20todo=20list=20items=20when=20ent?= =?UTF-8?q?ity=20changes,=20only=20refresh=20on=20shopping=20=E2=80=A6=20(?= =?UTF-8?q?#18445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lovelace/cards/hui-todo-list-card.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/cards/hui-todo-list-card.ts b/src/panels/lovelace/cards/hui-todo-list-card.ts index f2d38bc64f83..68af5f2b5914 100644 --- a/src/panels/lovelace/cards/hui-todo-list-card.ts +++ b/src/panels/lovelace/cards/hui-todo-list-card.ts @@ -135,10 +135,14 @@ export class HuiTodoListCard public hassSubscribe(): Promise[] { return [ - this.hass!.connection.subscribeEvents( - () => this._fetchData(), - "shopping_list_updated" - ), + this.hass!.connection.subscribeEvents(() => { + if ( + this._entityId && + this.hass!.entities[this._entityId]?.platform === "shopping_list" + ) { + this._fetchData(); + } + }, "shopping_list_updated"), ]; } @@ -159,6 +163,15 @@ export class HuiTodoListCard ) { applyThemesOnElement(this, this.hass.themes, this._config.theme); } + + if ( + this._entityId && + oldHass && + oldHass.states[this._entityId] !== this.hass.states[this._entityId] && + this.hass.entities[this._entityId]?.platform !== "shopping_list" + ) { + this._fetchData(); + } } protected render() { From 54758b596297cf5127ad073f58418c5e835007ea Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 15:47:47 +0200 Subject: [PATCH 07/10] Don't override ranges provided by parent (#18444) --- src/components/ha-date-range-picker.ts | 14 +++++++++----- .../components/hui-energy-period-selector.ts | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/ha-date-range-picker.ts b/src/components/ha-date-range-picker.ts index 966d429d408c..ed5403872f07 100644 --- a/src/components/ha-date-range-picker.ts +++ b/src/components/ha-date-range-picker.ts @@ -46,6 +46,8 @@ export class HaDateRangePicker extends LitElement { @property() public ranges?: DateRangePickerRanges | false; + @state() private _ranges?: DateRangePickerRanges; + @property() public autoApply = false; @property() public timePicker = true; @@ -93,7 +95,7 @@ export class HaDateRangePicker extends LitElement { } ); - this.ranges = { + this._ranges = { [this.hass.localize("ui.components.date-range-picker.ranges.today")]: [ calcDate(today, startOfDay, this.hass.locale, this.hass.config, { weekStartsOn, @@ -206,15 +208,15 @@ export class HaDateRangePicker extends LitElement { .path=${mdiCalendar} >`} - ${this.ranges + ${this.ranges !== false && (this.ranges || this._ranges) ? html`
- ${Object.keys(this.ranges).map( - (name) => html` ${name} ` + ${Object.keys(this.ranges || this._ranges!).map( + (name) => html`${name}` )}
` @@ -234,7 +236,9 @@ export class HaDateRangePicker extends LitElement { } private _setDateRange(ev: CustomEvent) { - const dateRange = Object.values(this.ranges!)[ev.detail.index]; + const dateRange = Object.values(this.ranges || this._ranges!)[ + ev.detail.index + ]; const dateRangePicker = this._dateRangePicker; dateRangePicker.clickRange(dateRange); dateRangePicker.clickedApply(); diff --git a/src/panels/lovelace/components/hui-energy-period-selector.ts b/src/panels/lovelace/components/hui-energy-period-selector.ts index aa78828abfe1..c06d3ab21063 100644 --- a/src/panels/lovelace/components/hui-energy-period-selector.ts +++ b/src/panels/lovelace/components/hui-energy-period-selector.ts @@ -65,7 +65,7 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) { @state() _endDate?: Date; - @state() private _ranges?: DateRangePickerRanges; + @state() private _ranges: DateRangePickerRanges = {}; @state() private _compare = false; From 40983619d6b9b6bf8c2ec1089ad535f22672995f Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 15:48:01 +0200 Subject: [PATCH 08/10] Reload when entering safe mode (#18443) --- src/state/connection-mixin.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/state/connection-mixin.ts b/src/state/connection-mixin.ts index 08113c821a2c..c3cced5705c8 100644 --- a/src/state/connection-mixin.ts +++ b/src/state/connection-mixin.ts @@ -274,6 +274,10 @@ export const connectionMixin = >( // on reconnect always fetch config as we might miss an update while we were disconnected // @ts-ignore this.hass!.callWS({ type: "get_config" }).then((config: HassConfig) => { + if (config.safe_mode) { + // @ts-ignore Firefox supports forceGet + location.reload(true); + } this._updateHass({ config }); this.checkDataBaseMigration(); }); From c25755bfcd1f8d1ea576c643b18023311ebc54d5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 16:33:02 +0200 Subject: [PATCH 09/10] Translate todo panel title, update assist title/icon (#18442) --- src/components/ha-button.ts | 4 ++++ src/components/ha-dialog.ts | 2 ++ src/panels/todo/ha-panel-todo.ts | 35 ++++++++++++++++++++++++-------- src/translations/en.json | 5 ++--- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/components/ha-button.ts b/src/components/ha-button.ts index 473d08dd1589..b58f32c8b5c3 100644 --- a/src/components/ha-button.ts +++ b/src/components/ha-button.ts @@ -20,6 +20,10 @@ export class HaButton extends Button { .trailing-icon { display: flex; } + .slot-container { + width: 100%; + overflow: hidden; + } `, ]; } diff --git a/src/components/ha-dialog.ts b/src/components/ha-dialog.ts index f061931322a4..feaceec93daf 100644 --- a/src/components/ha-dialog.ts +++ b/src/components/ha-dialog.ts @@ -94,6 +94,8 @@ export class HaDialog extends DialogBase { } .mdc-dialog__title { padding: 24px 24px 0 24px; + text-overflow: ellipsis; + overflow: hidden; } .mdc-dialog__actions { padding: 12px 24px 12px 24px; diff --git a/src/panels/todo/ha-panel-todo.ts b/src/panels/todo/ha-panel-todo.ts index 8dbdd77e8c7c..abafcbf6035c 100644 --- a/src/panels/todo/ha-panel-todo.ts +++ b/src/panels/todo/ha-panel-todo.ts @@ -2,10 +2,10 @@ import { ResizeController } from "@lit-labs/observers/resize-controller"; import "@material/mwc-list"; import { mdiChevronDown, + mdiCommentProcessingOutline, mdiDelete, mdiDotsVertical, mdiInformationOutline, - mdiMicrophone, mdiPlus, } from "@mdi/js"; import { @@ -173,11 +173,13 @@ class PanelTodo extends LitElement { .x=${this.mobile ? 0 : undefined} > - ${this._entityId - ? this._entityId in this.hass.states - ? computeStateName(this.hass.states[this._entityId]) - : this._entityId - : ""} +
+ ${this._entityId + ? this._entityId in this.hass.states + ? computeStateName(this.hass.states[this._entityId]) + : this._entityId + : ""} +
` - : "Lists"} + : this.hass.localize("panel.todo")} ${listItems} @@ -216,8 +218,9 @@ class PanelTodo extends LitElement { : nothing}
  • - - ${this.hass.localize("ui.panel.todo.start_conversation")} + + + ${this.hass.localize("ui.panel.todo.assist")} ${entityRegistryEntry?.platform === "local_todo" ? html`
  • @@ -335,11 +338,18 @@ class PanelTodo extends LitElement { :host([mobile]) .lists { --mdc-menu-min-width: 100vw; } + :host(:not([mobile])) .lists ha-list-item { + max-width: calc(100vw - 120px); + } :host([mobile]) ha-button-menu { --mdc-shape-medium: 0 0 var(--mdc-shape-medium) var(--mdc-shape-medium); } + ha-button-menu { + max-width: 100%; + } ha-button-menu ha-button { + max-width: 100%; --mdc-theme-primary: currentColor; --mdc-typography-button-text-transform: none; --mdc-typography-button-font-size: var( @@ -360,6 +370,13 @@ class PanelTodo extends LitElement { ); --button-height: 40px; } + ha-button-menu ha-button div { + text-overflow: ellipsis; + width: 100%; + overflow: hidden; + white-space: nowrap; + display: block; + } `, ]; } diff --git a/src/translations/en.json b/src/translations/en.json index 13edc9aa8ec5..e3047241c3d5 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -4522,7 +4522,6 @@ "never_triggered": "Never triggered" }, "todo-list": { - "lists": "To-do Lists", "checked_items": "Checked items", "clear_items": "Clear checked items", "add_item": "Add item", @@ -5096,7 +5095,7 @@ "description": "The Sensor card gives you a quick overview of your sensors state with an optional graph to visualize change over time." }, "todo-list": { - "name": "Todo list", + "name": "To-do list", "description": "The to-do list card allows you to add, edit, check-off, and clear items from your to-do list.", "integration_not_loaded": "This card requires the `todo` integration to be set up." }, @@ -5517,7 +5516,7 @@ } }, "todo": { - "start_conversation": "Start conversation", + "assist": "[%key:ui::panel::lovelace::menu::assist%]", "create_list": "Create list", "delete_list": "Delete list", "information": "Information", From 9961a4ae3f1d98289b0ee8385256497cdd825747 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 27 Oct 2023 16:33:32 +0200 Subject: [PATCH 10/10] Bumped version to 20231027.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c695ec8291b..55d7a058ef82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20231026.0" +version = "20231027.0" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md"