From 0cf8004b8dbf463463ba933ffc58bd73bafbf9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 27 Jan 2021 17:13:18 +0100 Subject: [PATCH 01/28] Add twine to release flow (#8254) --- .github/workflows/release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 425d0e3a2f..8653bc9644 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -33,6 +33,7 @@ jobs: - name: Build and release package run: | + python3 -m pip install twine export TWINE_USERNAME="__token__" export TWINE_PASSWORD="${{ secrets.TWINE_TOKEN }}" From 178605664e97f4b8ec0ecc7f656ee81f66d8ac99 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 27 Jan 2021 17:17:20 +0100 Subject: [PATCH 02/28] Bumped version to 20210127.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c0915cc7e9..5da1895d91 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.0", + version="20210127.1", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 3766f4478775e9ae6e26d9c49d576120abdd33f7 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 20:57:15 +0100 Subject: [PATCH 03/28] Bumped version to 20210127.2 --- setup.py | 2 +- src/components/ha-form/ha-form.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 5da1895d91..407d53fee3 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.1", + version="20210127.2", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", diff --git a/src/components/ha-form/ha-form.ts b/src/components/ha-form/ha-form.ts index 25cf8cd18d..adfe4fd71f 100644 --- a/src/components/ha-form/ha-form.ts +++ b/src/components/ha-form/ha-form.ts @@ -202,9 +202,8 @@ export class HaForm extends LitElement implements HaFormElement { ev.stopPropagation(); const schema = (ev.target as HaFormElement).schema as HaFormSchema; const data = this.data as HaFormDataContainer; - data[schema.name] = ev.detail.value; fireEvent(this, "value-changed", { - value: { ...data }, + value: { ...data, [schema.name]: ev.detail.value }, }); } From ef1dd8b7618f4e0d24ffdddd331744b67dde2132 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Wed, 27 Jan 2021 18:39:03 +0100 Subject: [PATCH 04/28] Add check to prevent undefined access during action validation (#8257) --- src/panels/lovelace/editor/types.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/editor/types.ts b/src/panels/lovelace/editor/types.ts index a42cc8dcb3..2cd040cf37 100644 --- a/src/panels/lovelace/editor/types.ts +++ b/src/panels/lovelace/editor/types.ts @@ -96,8 +96,14 @@ export interface EditSubElementEvent { } export const actionConfigStruct = dynamic((_value, ctx) => { - const test = actionConfigMap[ctx.branch[0][ctx.path[0]].action]; - return test || actionConfigStructType; + if (ctx.branch[0][ctx.path[0]]) { + return ( + actionConfigMap[ctx.branch[0][ctx.path[0]].action] || + actionConfigStructType + ); + } + + return actionConfigStructType; }); const actionConfigStructUser = object({ From 8ae1a1b558f9f2643a9749c70cbbdd5d18462b60 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 27 Jan 2021 23:42:06 +0100 Subject: [PATCH 05/28] Fix tts (#8261) --- src/data/tts.ts | 2 +- src/panels/config/cloud/account/dialog-cloud-tts-try.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data/tts.ts b/src/data/tts.ts index 23404087b9..e4469ffb24 100644 --- a/src/data/tts.ts +++ b/src/data/tts.ts @@ -9,4 +9,4 @@ export const convertTextToSpeech = ( language?: string; options?: Record; } -) => hass.callApi<{ url: string }>("POST", "tts_get_url", data); +) => hass.callApi<{ url: string; path: string }>("POST", "tts_get_url", data); diff --git a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts index 0fb9891aeb..076c9aef20 100644 --- a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts +++ b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts @@ -164,7 +164,7 @@ export class DialogTryTts extends LitElement { language, options: { gender }, }); - url = result.url; + url = result.path; } catch (err) { this._loadingExample = false; showAlertDialog(this, { From 4a64cd4464466ee9181ed89267c5765b37c376c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Hansl=C3=ADk?= Date: Thu, 28 Jan 2021 11:54:34 +0100 Subject: [PATCH 06/28] Typo in texts (#8264) --- src/translations/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translations/en.json b/src/translations/en.json index 50429653ce..4c2cca84e8 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2505,7 +2505,7 @@ "cards": { "confirm_delete": "Are you sure you want to delete this card?", "actions": { - "action_confirmation": "Are you sure you want to exectue action \"{action}\"?", + "action_confirmation": "Are you sure you want to execute action \"{action}\"?", "no_entity_more_info": "No entity provided for more info dialog", "no_entity_toggle": "No entity provided to toggle", "no_navigation_path": "No navigation path specified", From 48ed33af9551669ea95dcc5fbcba511a954e7879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Hansl=C3=ADk?= Date: Thu, 28 Jan 2021 11:55:00 +0100 Subject: [PATCH 07/28] Typo in texts (#8265) --- src/translations/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translations/en.json b/src/translations/en.json index 4c2cca84e8..efcab1801e 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -774,7 +774,7 @@ "edit_in_yaml_supported": "You can still edit your config in YAML.", "key_missing": "Required key \"{key}\" is missing.", "key_not_expected": "Key \"{key}\" is not expected or not supported by the visual editor.", - "key_wrong_type": "The provided value for \"{key}\" is not supported by the visual editor editor. We support ({type_correct}) but received ({type_wrong})." + "key_wrong_type": "The provided value for \"{key}\" is not supported by the visual editor. We support ({type_correct}) but received ({type_wrong})." } }, "login-form": { From 5afb8a77a9a9114f03566bda4e0c812fc6f064cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 28 Jan 2021 14:05:07 +0100 Subject: [PATCH 08/28] Make input_text entity row usable when value is "unknown" (#8258) --- src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts index 6722028303..38d6e8058e 100644 --- a/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts +++ b/src/panels/lovelace/entity-rows/hui-input-text-entity-row.ts @@ -10,7 +10,7 @@ import { PropertyValues, TemplateResult, } from "lit-element"; -import { UNAVAILABLE_STATES } from "../../../data/entity"; +import { UNAVAILABLE } from "../../../data/entity"; import { setValue } from "../../../data/input_text"; import { HomeAssistant } from "../../../types"; import { hasConfigOrEntityChanged } from "../common/has-changed"; @@ -54,7 +54,7 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow { Date: Thu, 28 Jan 2021 20:10:15 +0100 Subject: [PATCH 09/28] Move try tss button to bottom (#8266) --- src/panels/config/cloud/account/cloud-tts-pref.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/panels/config/cloud/account/cloud-tts-pref.ts b/src/panels/config/cloud/account/cloud-tts-pref.ts index 828590f47d..e069a71ad5 100644 --- a/src/panels/config/cloud/account/cloud-tts-pref.ts +++ b/src/panels/config/cloud/account/cloud-tts-pref.ts @@ -2,7 +2,6 @@ import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light"; import "@polymer/paper-item/paper-item"; import "@polymer/paper-listbox/paper-listbox"; import "@material/mwc-button"; -import { mdiPlayCircleOutline } from "@mdi/js"; import { css, CSSResult, @@ -59,12 +58,6 @@ export class CloudTTSPref extends LitElement { -
- - -  ${this.hass.localize("ui.panel.config.cloud.account.tts.try")} - -
${this.hass.localize( "ui.panel.config.cloud.account.tts.info", @@ -112,6 +105,11 @@ export class CloudTTSPref extends LitElement {
+
+ + ${this.hass.localize("ui.panel.config.cloud.account.tts.try")} + +
`; } From ff62fdb69dc25bba70d158354fb82bf8b6ffe3c5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 20:16:00 +0100 Subject: [PATCH 10/28] hide config links in demo (#8267) --- src/dialogs/more-info/ha-more-info-dialog.ts | 3 ++ src/panels/lovelace/hui-root.ts | 53 +++++++++++--------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/dialogs/more-info/ha-more-info-dialog.ts b/src/dialogs/more-info/ha-more-info-dialog.ts index 5e58c4e013..0e57bc9112 100644 --- a/src/dialogs/more-info/ha-more-info-dialog.ts +++ b/src/dialogs/more-info/ha-more-info-dialog.ts @@ -78,6 +78,9 @@ export class MoreInfoDialog extends LitElement { } protected shouldShowEditIcon(domain, stateObj): boolean { + if (__DEMO__) { + return false; + } if (EDITABLE_DOMAINS_WITH_ID.includes(domain) && stateObj.attributes.id) { return true; } diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index 5354007fe3..acff177aeb 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -189,30 +189,6 @@ class HUIRoot extends LitElement { )} `} - - - ${this.hass!.localize( - "ui.panel.lovelace.editor.menu.manage_dashboards" - )} - - - - ${this.hass!.localize( - "ui.panel.lovelace.editor.menu.manage_resources" - )} - + ${__DEMO__ /* No config available in the demo */ + ? "" + : html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.menu.manage_dashboards" + )} + + ${this.hass.userData?.showAdvanced + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.menu.manage_resources" + )} + ` + : ""} `} ` From 12bb3f5796bb459e0f806a7d40b4f2ca5170d693 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 20:18:13 +0100 Subject: [PATCH 11/28] Use close dialog function to close device registry detail dialog (#8269) --- .../device-registry-detail/dialog-device-registry-detail.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts index c30d63b50e..e60439f2de 100644 --- a/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts +++ b/src/panels/config/devices/device-registry-detail/dialog-device-registry-detail.ts @@ -149,7 +149,7 @@ class DialogDeviceRegistryDetail extends LitElement { area_id: this._areaId || null, disabled_by: this._disabledBy || null, }); - this._params = undefined; + this.closeDialog(); } catch (err) { this._error = err.message || From b4e5740050ff6bba5e2977a7d391edbef38b7cf9 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 20:20:07 +0100 Subject: [PATCH 12/28] Fix race condition in zwave migration (#8268) --- .../zwave/zwave-migration.ts | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts b/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts index 0dc8d750a4..d7e791bb49 100644 --- a/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts +++ b/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts @@ -37,8 +37,7 @@ import { showAlertDialog } from "../../../../../dialogs/generic/show-dialog-box" import { computeStateName } from "../../../../../common/entity/compute_state_name"; import { computeDeviceName, - DeviceRegistryEntry, - fetchDeviceRegistry, + subscribeDeviceRegistry, } from "../../../../../data/device_registry"; @customElement("zwave-migration") @@ -53,8 +52,6 @@ export class ZwaveMigration extends LitElement { @internalProperty() private _networkStatus?: ZWaveNetworkStatus; - @internalProperty() private _unsub?: Promise; - @internalProperty() private _step = 0; @internalProperty() private _stoppingNetwork = false; @@ -65,10 +62,18 @@ export class ZwaveMigration extends LitElement { @internalProperty() private _migratedZwaveEntities?: string[]; - @internalProperty() private _deviceRegistry?: DeviceRegistryEntry[]; + @internalProperty() private _deviceNameLookup: { [id: string]: string } = {}; + + private _unsub?: Promise; + + private _unsubDevices?: UnsubscribeFunc; public disconnectedCallback(): void { this._unsubscribe(); + if (this._unsubDevices) { + this._unsubDevices(); + this._unsubDevices = undefined; + } } protected render(): TemplateResult { @@ -89,7 +94,8 @@ export class ZwaveMigration extends LitElement { "ui.panel.config.zwave.migration.ozw.introduction" )} - ${!this.hass.config.components.includes("mqtt") + ${!this.hass.config.components.includes("hassio") && + !this.hass.config.components.includes("mqtt") ? html`
@@ -277,9 +283,9 @@ export class ZwaveMigration extends LitElement { ).map( (device_id) => html`
  • - ${this._computeDeviceName( + ${this._deviceNameLookup[ device_id - )} + ] || device_id}
  • ` )} ` @@ -372,10 +378,7 @@ export class ZwaveMigration extends LitElement { private async _setupOzw() { const ozwConfigFlow = await startOzwConfigFlow(this.hass); - if ( - !this.hass.config.components.includes("hassio") && - this.hass.config.components.includes("ozw") - ) { + if (this.hass.config.components.includes("ozw")) { this._getMigrationData(); this._step = 3; return; @@ -399,18 +402,29 @@ export class ZwaveMigration extends LitElement { this._migrationData.migration_entity_map ); if (Object.keys(this._migrationData.migration_device_map).length) { - this._deviceRegistry = await fetchDeviceRegistry(this.hass); + this._fetchDevices(); } } - private _computeDeviceName(deviceId) { - const device = this._deviceRegistry?.find( - (devReg) => devReg.id === deviceId + private _fetchDevices() { + this._unsubDevices = subscribeDeviceRegistry( + this.hass.connection, + (devices) => { + if (!this._migrationData) { + return; + } + const migrationDevices = Object.keys( + this._migrationData.migration_device_map + ); + const deviceNameLookup = {}; + devices.forEach((device) => { + if (migrationDevices.includes(device.id)) { + deviceNameLookup[device.id] = computeDeviceName(device, this.hass); + } + }); + this._deviceNameLookup = deviceNameLookup; + } ); - if (!device) { - return deviceId; - } - return computeDeviceName(device, this.hass); } private async _doMigrate() { From 1160d27004a603cd15f099c1e0ffc1b8153cdfef Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 22:34:31 +0100 Subject: [PATCH 13/28] Revert "Bumped version to 20210127.2" This reverts commit 3766f4478775e9ae6e26d9c49d576120abdd33f7. --- setup.py | 2 +- src/components/ha-form/ha-form.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 407d53fee3..5da1895d91 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.2", + version="20210127.1", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", diff --git a/src/components/ha-form/ha-form.ts b/src/components/ha-form/ha-form.ts index adfe4fd71f..25cf8cd18d 100644 --- a/src/components/ha-form/ha-form.ts +++ b/src/components/ha-form/ha-form.ts @@ -202,8 +202,9 @@ export class HaForm extends LitElement implements HaFormElement { ev.stopPropagation(); const schema = (ev.target as HaFormElement).schema as HaFormSchema; const data = this.data as HaFormDataContainer; + data[schema.name] = ev.detail.value; fireEvent(this, "value-changed", { - value: { ...data, [schema.name]: ev.detail.value }, + value: { ...data }, }); } From 9a088a21daffa5edfc093ce2de76f6b322d29049 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 28 Jan 2021 22:35:49 +0100 Subject: [PATCH 14/28] Bumped version to 20210127.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5da1895d91..eb4b681a4c 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.1", + version="20210127.3", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 1fc51f00878a4e0261f6229b615c1c55c506a18a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Jan 2021 18:10:58 +0100 Subject: [PATCH 15/28] Bumped version to 20210127.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index eb4b681a4c..9738b8e8ec 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.3", + version="20210127.4", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From bdff3fd45280b68bd58a99e94b04b38ba08a90d9 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Jan 2021 18:10:18 +0100 Subject: [PATCH 16/28] Z-wave migration tweaks (#8283) --- src/common/config/is_component_loaded.ts | 2 +- .../zwave/zwave-migration.ts | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/common/config/is_component_loaded.ts b/src/common/config/is_component_loaded.ts index 6275d705dc..1d212f3ff5 100644 --- a/src/common/config/is_component_loaded.ts +++ b/src/common/config/is_component_loaded.ts @@ -4,4 +4,4 @@ import { HomeAssistant } from "../../types"; export const isComponentLoaded = ( hass: HomeAssistant, component: string -): boolean => hass && hass.config.components.indexOf(component) !== -1; +): boolean => hass && hass.config.components.includes(component); diff --git a/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts b/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts index d7e791bb49..ce595713af 100644 --- a/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts +++ b/src/panels/config/integrations/integration-panels/zwave/zwave-migration.ts @@ -39,6 +39,7 @@ import { computeDeviceName, subscribeDeviceRegistry, } from "../../../../../data/device_registry"; +import { isComponentLoaded } from "../../../../../common/config/is_component_loaded"; @customElement("zwave-migration") export class ZwaveMigration extends LitElement { @@ -94,8 +95,8 @@ export class ZwaveMigration extends LitElement { "ui.panel.config.zwave.migration.ozw.introduction" )}
    - ${!this.hass.config.components.includes("hassio") && - !this.hass.config.components.includes("mqtt") + ${!isComponentLoaded(this.hass, "hassio") && + !isComponentLoaded(this.hass, "mqtt") ? html`
    @@ -182,7 +183,7 @@ export class ZwaveMigration extends LitElement {

    Now it's time to set up the OZW integration.

    - ${this.hass.config.components.includes("hassio") + ${isComponentLoaded(this.hass, "hassio") ? html`

    The OZWDaemon runs in a Home Assistant addon @@ -378,7 +379,7 @@ export class ZwaveMigration extends LitElement { private async _setupOzw() { const ozwConfigFlow = await startOzwConfigFlow(this.hass); - if (this.hass.config.components.includes("ozw")) { + if (isComponentLoaded(this.hass, "ozw")) { this._getMigrationData(); this._step = 3; return; @@ -386,7 +387,7 @@ export class ZwaveMigration extends LitElement { showConfigFlowDialog(this, { continueFlowId: ozwConfigFlow.flow_id, dialogClosedCallback: () => { - if (this.hass.config.components.includes("ozw")) { + if (isComponentLoaded(this.hass, "ozw")) { this._getMigrationData(); this._step = 3; } @@ -397,7 +398,18 @@ export class ZwaveMigration extends LitElement { } private async _getMigrationData() { - this._migrationData = await migrateZwave(this.hass, true); + try { + this._migrationData = await migrateZwave(this.hass, true); + } catch (err) { + showAlertDialog(this, { + title: "Failed to get migration data!", + text: + err.code === "unknown_command" + ? "Restart Home Assistant and try again." + : err.message, + }); + return; + } this._migratedZwaveEntities = Object.keys( this._migrationData.migration_entity_map ); From b8e9a4ce9fcfde96e5ee93babcc8347df537316e Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Jan 2021 17:19:01 +0100 Subject: [PATCH 17/28] Fix map editor (#8280) --- .../config-elements/hui-map-card-editor.ts | 22 +++++++++---------- src/panels/map/ha-entity-marker.js | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts index 714dc8deb1..39dde0b377 100644 --- a/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts @@ -96,37 +96,37 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor { return html`

    @@ -145,14 +145,14 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor { > @@ -169,7 +169,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
    Date: Fri, 29 Jan 2021 13:40:09 +0100 Subject: [PATCH 18/28] Fix external auth reconnection loop if connection lost after refresh token expiration (#8279) --- src/external_app/external_auth.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/external_app/external_auth.ts b/src/external_app/external_auth.ts index f1624e77d6..cf7cf41804 100644 --- a/src/external_app/external_auth.ts +++ b/src/external_app/external_auth.ts @@ -68,8 +68,14 @@ export class ExternalAuth extends Auth { public async refreshAccessToken(force?: boolean) { if (this._tokenCallbackPromise && !force) { - await this._tokenCallbackPromise; - return; + try { + await this._tokenCallbackPromise; + return; + } catch (e) { + // _tokenCallbackPromise is in a rejected state + // Clear the _tokenCallbackPromise and go on refreshing access token + this._tokenCallbackPromise = undefined; + } } const payload: GetExternalAuthPayload = { callback: CALLBACK_SET_TOKEN, From 362b419814560ceae1c15d214c787fabbe82e488 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Thu, 28 Jan 2021 22:39:45 +0100 Subject: [PATCH 19/28] Add missing extra field translation for cover position (#8273) * Ensure ha-form-integer passes "0" to form data * Only keep the translation change --- src/translations/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/translations/en.json b/src/translations/en.json index efcab1801e..ae70a1d5a8 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1426,7 +1426,8 @@ "extra_fields": { "code": "Code", "message": "Message", - "title": "Title" + "title": "Title", + "position": "[%key:ui::card::cover::position%]" } }, "scene": { From 1ed03842c05c8044361e07f496f78825105b1072 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Jan 2021 18:37:58 +0100 Subject: [PATCH 20/28] Fix grid + map editor (#8284) --- .../config-elements/hui-grid-card-editor.ts | 40 +++++++++++++------ .../config-elements/hui-map-card-editor.ts | 19 +++++---- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/panels/lovelace/editor/config-elements/hui-grid-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-grid-card-editor.ts index 0e4a62867b..681ebd0dc9 100644 --- a/src/panels/lovelace/editor/config-elements/hui-grid-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-grid-card-editor.ts @@ -29,6 +29,14 @@ export class HuiGridCardEditor extends HuiStackCardEditor { this._config = config; } + get _columns(): number { + return this._config!.columns || 3; + } + + get _square(): boolean { + return this._config!.square ?? true; + } + protected render(): TemplateResult { if (!this.hass || !this._config) { return html``; @@ -44,7 +52,7 @@ export class HuiGridCardEditor extends HuiStackCardEditor { "ui.panel.lovelace.editor.card.config.optional" )})" type="number" - .value=${(this._config as GridCardConfig).columns} + .value=${this._columns} .configValue=${"columns"} @value-changed=${this._handleColumnsChanged} > @@ -55,7 +63,7 @@ export class HuiGridCardEditor extends HuiStackCardEditor { .dir=${computeRTLDirection(this.hass)} > @@ -70,24 +78,30 @@ export class HuiGridCardEditor extends HuiStackCardEditor { if (!this._config) { return; } - - this._config = { - ...this._config, - columns: Number(ev.target.value), - }; + const value = Number(ev.target.value); + if (this._columns === value) { + return; + } + if (!ev.target.value) { + this._config = { ...this._config }; + delete this._config.columns; + } else { + this._config = { + ...this._config, + columns: value, + }; + } fireEvent(this, "config-changed", { config: this._config }); } private _handleSquareChanged(ev): void { - if (!this._config) { + if (!this._config || this._square === ev.target.checked) { return; } - this._config = { - ...this._config, - square: ev.target.checked, - }; - fireEvent(this, "config-changed", { config: this._config }); + fireEvent(this, "config-changed", { + config: { ...this._config, square: ev.target.checked }, + }); } } diff --git a/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts index 39dde0b377..e32c9f56bc 100644 --- a/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-map-card-editor.ts @@ -73,7 +73,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor { } get _default_zoom(): number { - return this._config!.default_zoom || NaN; + return this._config!.default_zoom || 0; } get _geo_location_sources(): string[] { @@ -199,22 +199,25 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor { return; } const target = ev.target! as EditorTarget; - let value = ev.detail.value; - - if (target.configValue && this[`_${target.configValue}`] === value) { + if (!target.configValue) { return; } - if (target.type === "number") { + + let value = target.checked ?? ev.detail.value; + + if (value && target.type === "number") { value = Number(value); } - if (value === "" || (target.type === "number" && isNaN(value))) { + if (this[`_${target.configValue}`] === value) { + return; + } + if (value === "") { this._config = { ...this._config }; delete this._config[target.configValue!]; } else if (target.configValue) { this._config = { ...this._config, - [target.configValue]: - target.checked !== undefined ? target.checked : value, + [target.configValue]: value, }; } fireEvent(this, "config-changed", { config: this._config }); From 8ea6baaf5dfc1813bbb4dc29e3622ce6b12c8eba Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 29 Jan 2021 18:38:36 +0100 Subject: [PATCH 21/28] Bumped version to 20210127.5 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9738b8e8ec..41203e011f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.4", + version="20210127.5", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From db9597d2e7026cbd863c72a185d4e783a5552a27 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 30 Jan 2021 21:30:47 +0100 Subject: [PATCH 22/28] Don't use badges in generated Lovelace + group entities by area (#8291) --- .../common/generate-lovelace-config.ts | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/panels/lovelace/common/generate-lovelace-config.ts b/src/panels/lovelace/common/generate-lovelace-config.ts index bd11c3946e..cf2c1797cb 100644 --- a/src/panels/lovelace/common/generate-lovelace-config.ts +++ b/src/panels/lovelace/common/generate-lovelace-config.ts @@ -43,18 +43,9 @@ import { PictureEntityCardConfig, ThermostatCardConfig, } from "../cards/types"; -import { processEditorEntities } from "../editor/process-editor-entities"; import { LovelaceRowConfig } from "../entity-rows/types"; const DEFAULT_VIEW_ENTITY_ID = "group.default_view"; -const DOMAINS_BADGES = [ - "binary_sensor", - "mailbox", - "person", - "sensor", - "sun", - "timer", -]; const HIDE_DOMAIN = new Set([ "automation", "configurator", @@ -91,10 +82,12 @@ const splitByAreas = ( ); for (const entity of entityEntries) { if ( - areaDevices.has( + ((areaDevices.has( // @ts-ignore entity.device_id ) && + !entity.area_id) || + entity.area_id === area.area_id) && entity.entity_id in allEntities ) { areaEntities.push(allEntities[entity.entity_id]); @@ -246,30 +239,18 @@ const generateViewConfig = ( (gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id] ); - const badgeEntities: { [domain: string]: string[] } = {}; const ungroupedEntitites: { [domain: string]: string[] } = {}; - // Organize ungrouped entities in badges/ungrouped things + // Organize ungrouped entities in ungrouped things Object.keys(splitted.ungrouped).forEach((entityId) => { const state = splitted.ungrouped[entityId]; const domain = computeStateDomain(state); - const coll = DOMAINS_BADGES.includes(domain) - ? badgeEntities - : ungroupedEntitites; - - if (!(domain in coll)) { - coll[domain] = []; + if (!(domain in ungroupedEntitites)) { + ungroupedEntitites[domain] = []; } - coll[domain].push(state.entity_id); - }); - - let badges: string[] = []; - DOMAINS_BADGES.forEach((domain) => { - if (domain in badgeEntities) { - badges = badges.concat(badgeEntities[domain]); - } + ungroupedEntitites[domain].push(state.entity_id); }); let cards: LovelaceCardConfig[] = []; @@ -315,7 +296,6 @@ const generateViewConfig = ( const view: LovelaceViewConfig = { path, title, - badges: processEditorEntities(badges), cards, }; From 9d82ce8ab49a43e943cb579502a53945ee37eb44 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Sat, 30 Jan 2021 21:32:25 +0100 Subject: [PATCH 23/28] Add missing device_classes to sensor (#8288) --- src/util/hass-attributes-util.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/hass-attributes-util.ts b/src/util/hass-attributes-util.ts index f26384786a..1b9c521e34 100644 --- a/src/util/hass-attributes-util.ts +++ b/src/util/hass-attributes-util.ts @@ -40,13 +40,17 @@ const hassAttributeUtil = { humidifier: ["dehumidifier", "humidifier"], sensor: [ "battery", + "current", + "energy", "humidity", "illuminance", - "temperature", - "pressure", "power", + "power_factor", + "pressure", "signal_strength", + "temperature", "timestamp", + "voltage", ], switch: ["switch", "outlet"], }, From da3f911deb67626f18a39db9a3ce36eb1513ba18 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 30 Jan 2021 22:42:01 +0100 Subject: [PATCH 24/28] Fix tts try on ios (#8292) --- .../config/cloud/account/dialog-cloud-tts-try.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts index 076c9aef20..e4d340d46d 100644 --- a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts +++ b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts @@ -141,7 +141,10 @@ export class DialogTryTts extends LitElement { this._target = target; if (target === "browser") { - this._playBrowser(message); + // We create the audio element here + do a play, because iOS requires it to be done by user action + const audio = new Audio(); + audio.play(); + this._playBrowser(message, audio); } else { this.hass.callService("tts", "cloud_say", { entity_id: target, @@ -150,7 +153,7 @@ export class DialogTryTts extends LitElement { } } - private async _playBrowser(message: string) { + private async _playBrowser(message: string, audio: HTMLAudioElement) { this._loadingExample = true; const language = this._params!.defaultVoice[0]; @@ -173,13 +176,17 @@ export class DialogTryTts extends LitElement { }); return; } - const audio = new Audio(url); + audio.src = url; audio.addEventListener("canplaythrough", () => { audio.play(); }); audio.addEventListener("playing", () => { this._loadingExample = false; }); + audio.addEventListener("error", () => { + showAlertDialog(this, { title: "Error playing audio." }); + this._loadingExample = false; + }); } static get styles(): CSSResult[] { From 92b116c0da141e9f31c5f6c970d34816c8d2cc78 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Sat, 30 Jan 2021 22:49:48 +0100 Subject: [PATCH 25/28] More precise name handling for auto-generated dashboards (#8289) Co-authored-by: Bram Kragten --- .../lovelace/common/generate-lovelace-config.ts | 14 +++++++++++++- .../lovelace/components/hui-generic-entity-row.ts | 3 --- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/common/generate-lovelace-config.ts b/src/panels/lovelace/common/generate-lovelace-config.ts index cf2c1797cb..26e6337213 100644 --- a/src/panels/lovelace/common/generate-lovelace-config.ts +++ b/src/panels/lovelace/common/generate-lovelace-config.ts @@ -184,7 +184,7 @@ export const computeCards = ( (name = computeStateName(stateObj)).startsWith(titlePrefix) ? { entity: entityId, - name: name.substr(titlePrefix.length), + name: adjustName(name.substr(titlePrefix.length)), } : entityId; @@ -203,6 +203,18 @@ export const computeCards = ( return cards; }; +const hasUpperCase = (str: string): boolean => { + return str.toLowerCase() !== str; +}; + +const adjustName = (name: string): string => { + // If first word already has an upper case letter (e.g. from brand name) + // leave as-is, otherwise capitalize the first word. + return hasUpperCase(name.substr(0, name.indexOf(" "))) + ? name + : name[0].toUpperCase() + name.slice(1); +}; + const computeDefaultViewStates = ( entities: HassEntities, entityEntries: EntityRegistryEntry[] diff --git a/src/panels/lovelace/components/hui-generic-entity-row.ts b/src/panels/lovelace/components/hui-generic-entity-row.ts index ddc4b8040d..8bf4b1abbd 100644 --- a/src/panels/lovelace/components/hui-generic-entity-row.ts +++ b/src/panels/lovelace/components/hui-generic-entity-row.ts @@ -173,9 +173,6 @@ class HuiGenericEntityRow extends LitElement { overflow: hidden; text-overflow: ellipsis; } - .info::first-letter { - text-transform: uppercase; - } .flex ::slotted(*) { margin-left: 8px; min-width: 0; From d79e5dd8fbdbc31564a94bde012b13d150e7daef Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 30 Jan 2021 22:51:57 +0100 Subject: [PATCH 26/28] Bumped version to 20210127.6 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 41203e011f..2254d364e8 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.5", + version="20210127.6", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 9d89aa329cd8b2c3d152daa8705d8ff1786f826e Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 2 Feb 2021 21:17:38 +0100 Subject: [PATCH 27/28] Revert "Add icon support to gauge" (#8303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- src/panels/lovelace/cards/hui-gauge-card.ts | 26 +++--------- src/panels/lovelace/cards/types.ts | 1 - .../config-elements/hui-gauge-card-editor.ts | 41 +++++-------------- 3 files changed, 15 insertions(+), 53 deletions(-) diff --git a/src/panels/lovelace/cards/hui-gauge-card.ts b/src/panels/lovelace/cards/hui-gauge-card.ts index f760bb2720..48e49d6432 100644 --- a/src/panels/lovelace/cards/hui-gauge-card.ts +++ b/src/panels/lovelace/cards/hui-gauge-card.ts @@ -14,7 +14,6 @@ import { styleMap } from "lit-html/directives/style-map"; import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element"; import { fireEvent } from "../../../common/dom/fire_event"; import { computeStateName } from "../../../common/entity/compute_state_name"; -import { stateIcon } from "../../../common/entity/state_icon"; import { isValidEntityId } from "../../../common/entity/valid_entity_id"; import "../../../components/ha-card"; import "../../../components/ha-gauge"; @@ -140,11 +139,8 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { "--gauge-color": this._computeSeverity(state), })} > -
    - -
    - ${this._config.name || computeStateName(stateObj)} -
    +
    + ${this._config.name || computeStateName(stateObj)}
    `; @@ -236,25 +232,13 @@ class HuiGaugeCard extends LitElement implements LovelaceCard { max-width: 250px; } - .row { - display: flex; - justify-content: space-around; - margin-top: 4px; - align-items: center; - } - .name { text-align: center; line-height: initial; - color: var(--secondary-text-color); + color: var(--primary-text-color); width: 100%; - font-size: 16px; - font-weight: 500; - } - - ha-icon { - color: var(--state-icon-color, #44739e); - margin-right: 4px; + font-size: 15px; + margin-top: 8px; } `; } diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 3c0d104639..05330f9dbf 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -115,7 +115,6 @@ export interface GaugeCardConfig extends LovelaceCardConfig { max?: number; severity?: SeverityConfig; theme?: string; - icon?: string; } export interface ConfigEntity extends EntityConfig { diff --git a/src/panels/lovelace/editor/config-elements/hui-gauge-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-gauge-card-editor.ts index da0147c5e2..7c12ea1fce 100644 --- a/src/panels/lovelace/editor/config-elements/hui-gauge-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-gauge-card-editor.ts @@ -12,10 +12,8 @@ import { import { assert, number, object, optional, string } from "superstruct"; import { fireEvent } from "../../../../common/dom/fire_event"; import { computeRTLDirection } from "../../../../common/util/compute_rtl"; -import { stateIcon } from "../../../../common/entity/state_icon"; import "../../../../components/ha-formfield"; import "../../../../components/ha-switch"; -import "../../../../components/ha-icon-input"; import { HomeAssistant } from "../../../../types"; import { GaugeCardConfig, SeverityConfig } from "../../cards/types"; import "../../components/hui-entity-editor"; @@ -33,7 +31,6 @@ const cardConfigStruct = object({ max: optional(number()), severity: optional(object()), theme: optional(string()), - icon: optional(string()), }); const includeDomains = ["sensor"]; @@ -78,10 +75,6 @@ export class HuiGaugeCardEditor extends LitElement return this._config!.severity || undefined; } - get _icon(): string { - return this._config!.icon || ""; - } - protected render(): TemplateResult { if (!this.hass || !this._config) { return html``; @@ -112,30 +105,16 @@ export class HuiGaugeCardEditor extends LitElement .configValue=${"name"} @value-changed="${this._valueChanged}" > -
    - - -
    + Date: Tue, 2 Feb 2021 21:24:52 +0100 Subject: [PATCH 28/28] Bumped version to 20210127.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2254d364e8..18ae112874 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210127.6", + version="20210127.7", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors",