Add NWK to ZHA device card and fix search again (#3278)

* add nwk to device info

* fix search again
This commit is contained in:
David F. Mulcahey 2019-06-18 14:14:37 -04:00 committed by Paulus Schoutsen
parent d8e0fd0ba5
commit dd56671974
3 changed files with 11 additions and 7 deletions

View File

@ -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;

View File

@ -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),

View File

@ -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 {
<dl>
<dt>IEEE:</dt>
<dd class="zha-info">${this.device!.ieee}</dd>
<dt>Nwk:</dt>
<dd class="zha-info">${formatAsPaddedHex(this.device!.nwk)}</dd>
${
this.device!.quirk_applied
? html`