From e8aa08b717238c13e34ba3365633016f39ca7d38 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Wed, 2 Aug 2023 10:39:51 +0200 Subject: [PATCH 1/6] Replace paper-input elements in supervisor network dialog (#17387) --- .../config/network/supervisor-network.ts | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/src/panels/config/network/supervisor-network.ts b/src/panels/config/network/supervisor-network.ts index 114649620d..faaa0a2100 100644 --- a/src/panels/config/network/supervisor-network.ts +++ b/src/panels/config/network/supervisor-network.ts @@ -4,7 +4,6 @@ import "@material/mwc-list/mwc-list-item"; import "@material/mwc-tab"; import "@material/mwc-tab-bar"; import { mdiDotsVertical } from "@mdi/js"; -import { PaperInputElement } from "@polymer/paper-input/paper-input"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { cache } from "lit/directives/cache"; @@ -15,7 +14,6 @@ import "../../../components/ha-circular-progress"; import "../../../components/ha-expansion-panel"; import "../../../components/ha-formfield"; import "../../../components/ha-icon-button"; -import "../../../components/ha-radio"; import { extractApiErrorMessage } from "../../../data/hassio/common"; import { AccessPoints, @@ -31,6 +29,10 @@ import { } from "../../../dialogs/generic/show-dialog-box"; import type { HomeAssistant } from "../../../types"; import { showIPDetailDialog } from "./show-ip-detail-dialog"; +import "../../../components/ha-textfield"; +import type { HaTextField } from "../../../components/ha-textfield"; +import "../../../components/ha-radio"; +import type { HaRadio } from "../../../components/ha-radio"; const IP_VERSIONS = ["ipv4", "ipv6"]; @@ -213,18 +215,16 @@ export class HassioNetwork extends LitElement { ${this._wifiConfiguration.auth === "wpa-psk" || this._wifiConfiguration.auth === "wep" ? html` - - + ` : ""} ` @@ -348,39 +348,36 @@ export class HassioNetwork extends LitElement { ${this._interface![version].method === "static" ? html` - - - + - - + - + ` : ""} @@ -487,8 +484,9 @@ export class HassioNetwork extends LitElement { this._interface = { ...this._interfaces[ev.detail.index] }; } - private _handleRadioValueChanged(ev: CustomEvent): void { - const value = (ev.target as any).value as "disabled" | "auto" | "static"; + private _handleRadioValueChanged(ev: Event): void { + const source = ev.target as HaRadio; + const value = source.value as "disabled" | "auto" | "static"; const version = (ev.target as any).version as "ipv4" | "ipv6"; if ( @@ -504,21 +502,19 @@ export class HassioNetwork extends LitElement { this.requestUpdate("_interface"); } - private _handleRadioValueChangedAp(ev: CustomEvent): void { - const value = (ev.target as any).value as string as - | "open" - | "wep" - | "wpa-psk"; + private _handleRadioValueChangedAp(ev: Event): void { + const source = ev.target as HaRadio; + const value = source.value as string as "open" | "wep" | "wpa-psk"; this._wifiConfiguration!.auth = value; this._dirty = true; this.requestUpdate("_wifiConfiguration"); } - private _handleInputValueChanged(ev: CustomEvent): void { - const value: string | null | undefined = (ev.target as PaperInputElement) - .value; + private _handleInputValueChanged(ev: Event): void { + const source = ev.target as HaTextField; + const value = source.value; const version = (ev.target as any).version as "ipv4" | "ipv6"; - const id = (ev.target as PaperInputElement).id; + const id = source.id; if ( !value || @@ -532,10 +528,10 @@ export class HassioNetwork extends LitElement { this._interface[version]![id] = value; } - private _handleInputValueChangedWifi(ev: CustomEvent): void { - const value: string | null | undefined = (ev.target as PaperInputElement) - .value; - const id = (ev.target as PaperInputElement).id; + private _handleInputValueChangedWifi(ev: Event): void { + const source = ev.target as HaTextField; + const value = source.value; + const id = source.id; if ( !value || @@ -573,8 +569,9 @@ export class HassioNetwork extends LitElement { --expansion-panel-summary-padding: 0 16px; margin: 4px 0; } - paper-input { - padding: 0 14px; + ha-textfield { + display: block; + margin-top: 16px; } mwc-list-item { --mdc-list-side-padding: 10px; From 5f95968c8fdc9985b7d00f07bdfbdd9e52d4e03e Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 2 Aug 2023 13:48:48 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Make=20event=20entity=20row=20show=20time?= =?UTF-8?q?=20as=20relative=20by=20default,=20hide=20in=20gener=E2=80=A6?= =?UTF-8?q?=20(#17456)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/generate-lovelace-config.ts | 1 + .../entity-rows/hui-event-entity-row.ts | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/panels/lovelace/common/generate-lovelace-config.ts b/src/panels/lovelace/common/generate-lovelace-config.ts index 65b66c3ce1..673e8286a5 100644 --- a/src/panels/lovelace/common/generate-lovelace-config.ts +++ b/src/panels/lovelace/common/generate-lovelace-config.ts @@ -36,6 +36,7 @@ const HIDE_DOMAIN = new Set([ "script", "sun", "zone", + "event", ]); const HIDE_PLATFORM = new Set(["mobile_app"]); diff --git a/src/panels/lovelace/entity-rows/hui-event-entity-row.ts b/src/panels/lovelace/entity-rows/hui-event-entity-row.ts index cb6e097a50..f7abad2349 100644 --- a/src/panels/lovelace/entity-rows/hui-event-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-event-entity-row.ts @@ -68,16 +68,23 @@ class HuiEventEntityRow extends LitElement implements LovelaceRow { hasDoubleClick: hasAction(this._config.double_tap_action), })} > -
- ${computeStateDisplay( - this.hass!.localize, - stateObj, - this.hass.locale, - this.hass.config, - this.hass.entities - )} -
+ ${isUnavailableState(stateObj.state) + ? computeStateDisplay( + this.hass!.localize, + stateObj, + this.hass.locale, + this.hass.config, + this.hass.entities + ) + : html``} +
+
${isUnavailableState(stateObj.state) ? `` : computeAttributeValueDisplay( @@ -104,10 +111,10 @@ class HuiEventEntityRow extends LitElement implements LovelaceRow { text-align: right; } .when { - color: var(--secondary-text-color); + color: var(--primary-text-color); } .what { - color: var(--primary-text-color); + color: var(--secondary-text-color); } `; } From 0f56e8f985dd896a7d1d90ec8e026316807ded72 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 2 Aug 2023 13:52:03 +0200 Subject: [PATCH 3/6] Update ha-panel-shopping-list.ts --- src/panels/shopping-list/ha-panel-shopping-list.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/panels/shopping-list/ha-panel-shopping-list.ts b/src/panels/shopping-list/ha-panel-shopping-list.ts index a9cfb23eaf..fa5921455b 100644 --- a/src/panels/shopping-list/ha-panel-shopping-list.ts +++ b/src/panels/shopping-list/ha-panel-shopping-list.ts @@ -87,8 +87,7 @@ class PanelShoppingList extends LitElement { display: flex; flex-direction: row; justify-content: center; - margin-left: 4px; - margin-right: 4px; + margin: 8px; } .column { flex: 1 0 0; From 788e48a5a6367be154d1a8d2acee94208457338e Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 2 Aug 2023 13:52:27 +0200 Subject: [PATCH 4/6] Bumped version to 20230802.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3461519203..50d335eed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20230801.0" +version = "20230802.0" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md" From bde93c44bd88102d2f2eddb105a4c664d4a53e99 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 2 Aug 2023 04:53:05 -0700 Subject: [PATCH 5/6] Fix statistic-picker filter behavior (#17453) --- src/components/entity/ha-statistic-picker.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/entity/ha-statistic-picker.ts b/src/components/entity/ha-statistic-picker.ts index e9a9388243..3a46527766 100644 --- a/src/components/entity/ha-statistic-picker.ts +++ b/src/components/entity/ha-statistic-picker.ts @@ -1,5 +1,5 @@ import { HassEntity } from "home-assistant-js-websocket"; -import { html, LitElement, PropertyValues, TemplateResult } from "lit"; +import { html, LitElement, nothing, PropertyValues, TemplateResult } from "lit"; import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit"; import { customElement, property, query, state } from "lit/decorators"; import memoizeOne from "memoize-one"; @@ -87,6 +87,8 @@ export class HaStatisticPicker extends LitElement { private _statistics: StatisticItem[] = []; + @state() private _filteredItems?: StatisticItem[] = undefined; + private _rowRenderer: ComboBoxLitRenderer = (item) => html` ${item.state @@ -254,7 +256,11 @@ export class HaStatisticPicker extends LitElement { } } - protected render(): TemplateResult { + protected render(): TemplateResult | typeof nothing { + if (this._statistics.length === 0) { + return nothing; + } + return html` (filterString, this._statistics) - : this._statistics; + : undefined; } private _setValue(value: string) { From 6653a8f63426755d6a58bce0ef3d55d83d8ec99c Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 2 Aug 2023 04:55:51 -0700 Subject: [PATCH 6/6] Fix some minor issues with cost display in energy sources table (#17452) --- .../energy/hui-energy-sources-table-card.ts | 100 +++++++++++------- 1 file changed, 59 insertions(+), 41 deletions(-) diff --git a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts index 734a4067ae..4b061f42a0 100644 --- a/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts +++ b/src/panels/lovelace/cards/energy/hui-energy-sources-table-card.ts @@ -80,6 +80,10 @@ export class HuiEnergySourcesTableCard let totalWater = 0; let totalWaterCost = 0; + let hasGridCost = false; + let hasGasCost = false; + let hasWaterCost = false; + let totalGridCompare = 0; let totalGridCostCompare = 0; let totalSolarCompare = 0; @@ -477,6 +481,7 @@ export class HuiEnergySourcesTableCard ) || 0 : null; if (cost !== null) { + hasGridCost = true; totalGridCost += cost; } @@ -575,6 +580,7 @@ export class HuiEnergySourcesTableCard ) || 0) * -1 : null; if (cost !== null) { + hasGridCost = true; totalGridCost += cost; } @@ -686,14 +692,16 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber( - totalGridCostCompare, - this.hass.locale, - { - style: "currency", - currency: this.hass.config.currency!, - } - )} + ${hasGridCost + ? formatNumber( + totalGridCostCompare, + this.hass.locale, + { + style: "currency", + currency: this.hass.config.currency!, + } + ) + : ""} ` : ""}` : ""} @@ -706,10 +714,12 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber(totalGridCost, this.hass.locale, { - style: "currency", - currency: this.hass.config.currency!, - })} + ${hasGridCost + ? formatNumber(totalGridCost, this.hass.locale, { + style: "currency", + currency: this.hass.config.currency!, + }) + : ""} ` : ""} ` @@ -737,6 +747,7 @@ export class HuiEnergySourcesTableCard 0 : null; if (cost !== null) { + hasGasCost = true; totalGasCost += cost; } @@ -835,14 +846,16 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber( - totalGasCostCompare, - this.hass.locale, - { - style: "currency", - currency: this.hass.config.currency!, - } - )} + ${hasGasCost + ? formatNumber( + totalGasCostCompare, + this.hass.locale, + { + style: "currency", + currency: this.hass.config.currency!, + } + ) + : ""} ` : ""}` : ""} @@ -855,10 +868,12 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber(totalGasCost, this.hass.locale, { - style: "currency", - currency: this.hass.config.currency!, - })} + ${hasGasCost + ? formatNumber(totalGasCost, this.hass.locale, { + style: "currency", + currency: this.hass.config.currency!, + }) + : ""} ` : ""} ` @@ -886,6 +901,7 @@ export class HuiEnergySourcesTableCard 0 : null; if (cost !== null) { + hasWaterCost = true; totalWaterCost += cost; } @@ -984,14 +1000,16 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber( - totalWaterCostCompare, - this.hass.locale, - { - style: "currency", - currency: this.hass.config.currency!, - } - )} + ${hasWaterCost + ? formatNumber( + totalWaterCostCompare, + this.hass.locale, + { + style: "currency", + currency: this.hass.config.currency!, + } + ) + : ""} ` : ""}` : ""} @@ -1004,16 +1022,18 @@ export class HuiEnergySourcesTableCard ? html` - ${formatNumber(totalWaterCost, this.hass.locale, { - style: "currency", - currency: this.hass.config.currency!, - })} + ${hasWaterCost + ? formatNumber(totalWaterCost, this.hass.locale, { + style: "currency", + currency: this.hass.config.currency!, + }) + : ""} ` : ""} ` : ""} - ${[totalGasCost, totalWaterCost, totalGridCost].filter(Boolean) - .length > 1 + ${[hasGasCost, hasWaterCost, hasGridCost].filter(Boolean).length > + 1 ? html` @@ -1022,9 +1042,7 @@ export class HuiEnergySourcesTableCard )} ${compare - ? html`${showCosts - ? html`` - : ""} + ? html`