From b81d8236027125d6c9d2c55c2d18efee48c27e19 Mon Sep 17 00:00:00 2001
From: Charles Garwood
Date: Mon, 3 Aug 2020 12:53:41 -0400
Subject: [PATCH 1/8] Add Z-Wave device info to OZW device pages (#6508)
* Add basic device info to devices page for OZW devices
* Remove unused HassEntity
* connection -> identifier
* async fetch
* Cleanup fetch call
---
src/data/ozw.ts | 21 +++++
.../ozw/ha-device-info-ozw.ts | 89 +++++++++++++++++++
.../config/devices/ha-config-device-page.ts | 9 ++
src/translations/en.json | 23 ++++-
4 files changed, 140 insertions(+), 2 deletions(-)
create mode 100644 src/data/ozw.ts
create mode 100644 src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts
diff --git a/src/data/ozw.ts b/src/data/ozw.ts
new file mode 100644
index 0000000000..491b0168a2
--- /dev/null
+++ b/src/data/ozw.ts
@@ -0,0 +1,21 @@
+import { HomeAssistant } from "../types";
+
+export interface OZWDevice {
+ node_id: number;
+ node_query_stage: string;
+ is_awake: boolean;
+ is_failed: boolean;
+ is_zwave_plus: boolean;
+ ozw_instance: number;
+}
+
+export const fetchOZWNodeStatus = (
+ hass: HomeAssistant,
+ ozw_instance: string,
+ node_id: string
+): Promise =>
+ hass.callWS({
+ type: "ozw/node_status",
+ ozw_instance: ozw_instance,
+ node_id: node_id,
+ });
diff --git a/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts
new file mode 100644
index 0000000000..b82ba363f0
--- /dev/null
+++ b/src/panels/config/devices/device-detail/integration-elements/ozw/ha-device-info-ozw.ts
@@ -0,0 +1,89 @@
+import {
+ CSSResult,
+ customElement,
+ html,
+ LitElement,
+ property,
+ internalProperty,
+ TemplateResult,
+ css,
+ PropertyValues,
+} from "lit-element";
+import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
+import { haStyle } from "../../../../../../resources/styles";
+import { HomeAssistant } from "../../../../../../types";
+import { OZWDevice, fetchOZWNodeStatus } from "../../../../../../data/ozw";
+
+@customElement("ha-device-info-ozw")
+export class HaDeviceInfoOzw extends LitElement {
+ @property({ attribute: false }) public hass!: HomeAssistant;
+
+ @property() public device!: DeviceRegistryEntry;
+
+ @internalProperty() private _ozwDevice?: OZWDevice;
+
+ protected updated(changedProperties: PropertyValues) {
+ if (changedProperties.has("device")) {
+ this._fetchNodeDetails(this.device);
+ }
+ }
+
+ protected async _fetchNodeDetails(device) {
+ const ozwIdentifier = device.identifiers.find(
+ (identifier) => identifier[0] === "ozw"
+ );
+ if (!ozwIdentifier) {
+ return;
+ }
+ const identifiers = ozwIdentifier[1].split(".");
+ this._ozwDevice = await fetchOZWNodeStatus(
+ this.hass,
+ identifiers[0],
+ identifiers[1]
+ );
+ }
+
+ protected render(): TemplateResult {
+ if (!this._ozwDevice) {
+ return html``;
+ }
+ return html`
+
+ ${this.hass.localize("ui.panel.config.ozw.device_info.zwave_info")}
+
+
+ ${this.hass.localize("ui.panel.config.ozw.common.node_id")}:
+ ${this._ozwDevice.node_id}
+
+
+ ${this.hass.localize("ui.panel.config.ozw.device_info.stage")}:
+ ${this._ozwDevice.node_query_stage}
+
+
+ ${this.hass.localize("ui.panel.config.ozw.common.ozw_instance")}:
+ ${this._ozwDevice.ozw_instance}
+
+
+ ${this.hass.localize("ui.panel.config.ozw.device_info.node_failed")}:
+ ${this._ozwDevice.is_failed
+ ? this.hass.localize("ui.common.yes")
+ : this.hass.localize("ui.common.no")}
+
+ `;
+ }
+
+ static get styles(): CSSResult[] {
+ return [
+ haStyle,
+ css`
+ h4 {
+ margin-bottom: 4px;
+ }
+ div {
+ word-break: break-all;
+ margin-top: 2px;
+ }
+ `,
+ ];
+ }
+}
diff --git a/src/panels/config/devices/ha-config-device-page.ts b/src/panels/config/devices/ha-config-device-page.ts
index bc96ae7215..ec2e67ea68 100644
--- a/src/panels/config/devices/ha-config-device-page.ts
+++ b/src/panels/config/devices/ha-config-device-page.ts
@@ -501,6 +501,15 @@ export class HaConfigDevicePage extends LitElement {
`);
}
+ if (integrations.includes("ozw")) {
+ import("./device-detail/integration-elements/ozw/ha-device-info-ozw");
+ templates.push(html`
+
+ `);
+ }
if (integrations.includes("zha")) {
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
import("./device-detail/integration-elements/zha/ha-device-info-zha");
diff --git a/src/translations/en.json b/src/translations/en.json
index d27eef38b7..bb692bf03b 100755
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -539,7 +539,10 @@
"sidebar_toggle": "Sidebar Toggle"
},
"panel": {
- "calendar": { "my_calendars": "My Calendars", "today": "Today" },
+ "calendar": {
+ "my_calendars": "My Calendars",
+ "today": "Today"
+ },
"config": {
"header": "Configure Home Assistant",
"introduction": "In this view it is possible to configure your components and Home Assistant. Not everything is possible to configure from the UI yet, but we're working on it.",
@@ -1568,7 +1571,11 @@
"description": "Manage users",
"users_privileges_note": "The users group is a work in progress. The user will be unable to administer the instance via the UI. We're still auditing all management API endpoints to ensure that they correctly limit access to administrators.",
"picker": {
- "headers": { "name": "Name", "group": "Group", "system": "System" }
+ "headers": {
+ "name": "Name",
+ "group": "Group",
+ "system": "System"
+ }
},
"editor": {
"caption": "View user",
@@ -1611,6 +1618,18 @@
"stop_listening": "Stop listening",
"message_received": "Message {id} received on {topic} at {time}:"
},
+ "ozw": {
+ "common": {
+ "zwave": "Z-Wave",
+ "node_id": "Node ID",
+ "ozw_instance": "OpenZWave Instance"
+ },
+ "device_info": {
+ "zwave_info": "Z-Wave Info",
+ "stage": "Stage",
+ "node_failed": "Node Failed"
+ }
+ },
"zha": {
"button": "Configure",
"header": "Configure Zigbee Home Automation",
From 410bd22f8aa97b7cb46e17c4631d8c5bb2c3748f Mon Sep 17 00:00:00 2001
From: Bram Kragten
Date: Mon, 3 Aug 2020 22:44:20 +0200
Subject: [PATCH 2/8] Punycode client id on auth page (#6513)
---
package.json | 1 +
src/auth/ha-authorize.ts | 3 ++-
yarn.lock | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index c067e53d7c..d49ffdb706 100644
--- a/package.json
+++ b/package.json
@@ -106,6 +106,7 @@
"memoize-one": "^5.0.2",
"node-vibrant": "^3.1.5",
"proxy-polyfill": "^0.3.1",
+ "punycode": "^2.1.1",
"regenerator-runtime": "^0.13.2",
"resize-observer-polyfill": "^1.5.1",
"roboto-fontface": "^0.10.0",
diff --git a/src/auth/ha-authorize.ts b/src/auth/ha-authorize.ts
index 989525cb23..72404d153e 100644
--- a/src/auth/ha-authorize.ts
+++ b/src/auth/ha-authorize.ts
@@ -16,6 +16,7 @@ import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
import { registerServiceWorker } from "../util/register-service-worker";
import "./ha-auth-flow";
import { extractSearchParamsObject } from "../common/url/search-params";
+import punycode from "punycode";
import(/* webpackChunkName: "pick-auth-provider" */ "./ha-pick-auth-provider");
@@ -75,7 +76,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
${this.localize(
"ui.panel.page-authorize.authorizing_client",
"clientId",
- this.clientId
+ this.clientId ? punycode.toASCII(this.clientId) : this.clientId
)}
${loggingInWith}
diff --git a/yarn.lock b/yarn.lock
index c813bc0508..8a9ddcb099 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9887,7 +9887,7 @@ punycode@^1.2.4, punycode@^1.3.2:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
integrity sha1-wNWmOycYgArY4esPpSachN1BhF4=
-punycode@^2.1.0:
+punycode@^2.1.0, punycode@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
From 699140320393b63a18b9c030691344e3e0f923d1 Mon Sep 17 00:00:00 2001
From: Bram Kragten
Date: Mon, 3 Aug 2020 23:26:41 +0200
Subject: [PATCH 3/8] Fix location editor in onboarding (#6512)
---
src/components/map/ha-location-editor.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/map/ha-location-editor.ts b/src/components/map/ha-location-editor.ts
index be72287b3e..a1775f1a58 100644
--- a/src/components/map/ha-location-editor.ts
+++ b/src/components/map/ha-location-editor.ts
@@ -107,7 +107,7 @@ class LocationEditor extends LitElement {
if (changedProps.has("hass")) {
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
- if (!oldHass || oldHass.themes.darkMode === this.hass.themes.darkMode) {
+ if (!oldHass || oldHass.themes?.darkMode === this.hass.themes?.darkMode) {
return;
}
if (!this._leafletMap || !this._tileLayer) {
@@ -117,7 +117,7 @@ class LocationEditor extends LitElement {
this.Leaflet,
this._leafletMap,
this._tileLayer,
- this.hass.themes.darkMode
+ this.hass.themes?.darkMode
);
}
}
@@ -129,7 +129,7 @@ class LocationEditor extends LitElement {
private async _initMap(): Promise {
[this._leafletMap, this.Leaflet, this._tileLayer] = await setupLeafletMap(
this._mapEl,
- this.hass.themes.darkMode,
+ this.hass.themes?.darkMode,
Boolean(this.radius)
);
this._leafletMap.addEventListener(
From bb5f6e88d0cc231778b9ce748a7efd7595086970 Mon Sep 17 00:00:00 2001
From: Bram Kragten
Date: Tue, 4 Aug 2020 11:13:55 +0200
Subject: [PATCH 4/8] Close entity registry dialog when navigation away (#6511)
---
src/components/ha-related-items.ts | 17 +++++++++++++++--
.../config/entities/entity-registry-settings.ts | 8 +++++---
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/components/ha-related-items.ts b/src/components/ha-related-items.ts
index 35a24a8479..4596b453b5 100644
--- a/src/components/ha-related-items.ts
+++ b/src/components/ha-related-items.ts
@@ -97,6 +97,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
${this.hass.localize(`component.${entry.domain}.title`)}:
${entry.title}
@@ -116,7 +117,10 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
${this.hass.localize("ui.components.related-items.device")}:
-
+
${device.name_by_user || device.name}
`;
@@ -134,7 +138,10 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
${this.hass.localize("ui.components.related-items.area")}:
-
+
${area.name}
`;
@@ -278,6 +285,12 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
`;
}
+ private async _navigateAwayClose() {
+ // allow new page to open before closing dialog
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ fireEvent(this, "close-dialog");
+ }
+
private async _findRelated() {
this._related = await findRelated(this.hass, this.itemType, this.itemId);
await this.updateComplete;
diff --git a/src/panels/config/entities/entity-registry-settings.ts b/src/panels/config/entities/entity-registry-settings.ts
index 58c9ac7a5c..5ac897dc78 100644
--- a/src/panels/config/entities/entity-registry-settings.ts
+++ b/src/panels/config/entities/entity-registry-settings.ts
@@ -73,7 +73,7 @@ export class EntityRegistrySettings extends LitElement {
return html`
${!stateObj
? html`
-
+
${this.hass!.localize(
"ui.dialogs.entity_registry.editor.unavailable"
)}
@@ -81,7 +81,7 @@ export class EntityRegistrySettings extends LitElement {
`
: ""}
${this._error ? html`
${this._error}
` : ""}
-