From dd56671974989702f028618b264537ed4e274fec Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Tue, 18 Jun 2019 14:14:37 -0400 Subject: [PATCH] Add NWK to ZHA device card and fix search again (#3278) * add nwk to device info * fix search again --- src/data/zha.ts | 1 + src/panels/config/zha/zha-add-devices-page.ts | 14 +++++++------- src/panels/config/zha/zha-device-card.ts | 3 +++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/data/zha.ts b/src/data/zha.ts index dc759063fe..105bd93503 100644 --- a/src/data/zha.ts +++ b/src/data/zha.ts @@ -8,6 +8,7 @@ export interface ZHAEntityReference extends HassEntity { export interface ZHADevice { name: string; ieee: string; + nwk: string; manufacturer: string; model: string; quirk_applied: boolean; diff --git a/src/panels/config/zha/zha-add-devices-page.ts b/src/panels/config/zha/zha-add-devices-page.ts index 8080bc6c19..5adb181fd4 100644 --- a/src/panels/config/zha/zha-add-devices-page.ts +++ b/src/panels/config/zha/zha-add-devices-page.ts @@ -36,10 +36,10 @@ class ZHAAddDevicesPage extends LitElement { public connectedCallback(): void { super.connectedCallback(); - if (this.route && this.route.path && this.route.path !== "") { - this._ieeeAddress = this.route.path.substring(1); - } - this._subscribe(this._ieeeAddress); + this.route && this.route.path && this.route.path !== "" + ? (this._ieeeAddress = this.route.path.substring(1)) + : (this._ieeeAddress = undefined); + this._subscribe(); } public disconnectedCallback(): void { @@ -156,10 +156,10 @@ class ZHAAddDevicesPage extends LitElement { } } - private _subscribe(ieeeAddress: string | undefined): void { + private _subscribe(): void { const data: any = { type: "zha/devices/permit" }; - if (ieeeAddress) { - data.ieee = ieeeAddress; + if (this._ieeeAddress) { + data.ieee = this._ieeeAddress; } this._subscribed = this.hass!.connection.subscribeMessage( (message) => this._handleMessage(message), diff --git a/src/panels/config/zha/zha-device-card.ts b/src/panels/config/zha/zha-device-card.ts index 33b1f2cfbd..cf32d49a1d 100644 --- a/src/panels/config/zha/zha-device-card.ts +++ b/src/panels/config/zha/zha-device-card.ts @@ -36,6 +36,7 @@ import { HomeAssistant } from "../../../types"; import { ItemSelectedEvent, NodeServiceData } from "./types"; import { navigate } from "../../../common/navigate"; import { UnsubscribeFunc } from "home-assistant-js-websocket"; +import { formatAsPaddedHex } from "./functions"; declare global { // for fire event @@ -132,6 +133,8 @@ class ZHADeviceCard extends LitElement {
IEEE:
${this.device!.ieee}
+
Nwk:
+
${formatAsPaddedHex(this.device!.nwk)}
${ this.device!.quirk_applied ? html`