mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Fix ZHA neighbor table in the manage device dialog (#14236)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
2e988bf5c3
commit
42386c7dee
@ -36,6 +36,8 @@ export interface Neighbor {
|
|||||||
ieee: string;
|
ieee: string;
|
||||||
nwk: string;
|
nwk: string;
|
||||||
lqi: string;
|
lqi: string;
|
||||||
|
depth: string;
|
||||||
|
relationship: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ZHADeviceEndpoint {
|
export interface ZHADeviceEndpoint {
|
||||||
|
@ -27,7 +27,7 @@ import "./zha-cluster-commands";
|
|||||||
import "./zha-manage-clusters";
|
import "./zha-manage-clusters";
|
||||||
import "./zha-device-binding";
|
import "./zha-device-binding";
|
||||||
import "./zha-group-binding";
|
import "./zha-group-binding";
|
||||||
import "./zha-device-children";
|
import "./zha-device-neighbors";
|
||||||
import "./zha-device-signature";
|
import "./zha-device-signature";
|
||||||
import {
|
import {
|
||||||
Tab,
|
Tab,
|
||||||
@ -179,10 +179,11 @@ class DialogZHAManageZigbeeDevice extends LitElement {
|
|||||||
></zha-device-zigbee-info>
|
></zha-device-zigbee-info>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
<zha-device-children
|
<zha-device-neighbors
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.device=${this._device}
|
.device=${this._device}
|
||||||
></zha-device-children>
|
.narrow=${!this.large}
|
||||||
|
></zha-device-neighbors>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -221,7 +222,7 @@ class DialogZHAManageZigbeeDevice extends LitElement {
|
|||||||
device &&
|
device &&
|
||||||
(device.device_type === "Router" || device.device_type === "Coordinator")
|
(device.device_type === "Router" || device.device_type === "Coordinator")
|
||||||
) {
|
) {
|
||||||
tabs.push("children");
|
tabs.push("neighbors");
|
||||||
}
|
}
|
||||||
|
|
||||||
return tabs;
|
return tabs;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||||
import { ZHADevice } from "../../../../../data/zha";
|
import { ZHADevice } from "../../../../../data/zha";
|
||||||
|
|
||||||
export type Tab = "clusters" | "bindings" | "signature" | "children";
|
export type Tab = "clusters" | "bindings" | "signature" | "neighbors";
|
||||||
|
|
||||||
export interface ZHAManageZigbeeDeviceDialogParams {
|
export interface ZHAManageZigbeeDeviceDialogParams {
|
||||||
device: ZHADevice;
|
device: ZHADevice;
|
||||||
|
@ -16,12 +16,16 @@ export interface DeviceRowData extends DataTableRowData {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
lqi: number;
|
lqi: number;
|
||||||
|
depth: number;
|
||||||
|
relationship: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("zha-device-children")
|
@customElement("zha-device-neighbors")
|
||||||
class ZHADeviceChildren extends LitElement {
|
class ZHADeviceNeighbors extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
@property() public device: ZHADevice | undefined;
|
@property() public device: ZHADevice | undefined;
|
||||||
|
|
||||||
@state() private _devices: Map<string, ZHADevice> | undefined;
|
@state() private _devices: Map<string, ZHADevice> | undefined;
|
||||||
@ -33,20 +37,22 @@ class ZHADeviceChildren extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _deviceChildren = memoizeOne(
|
private _deviceNeighbors = memoizeOne(
|
||||||
(
|
(
|
||||||
device: ZHADevice | undefined,
|
device: ZHADevice | undefined,
|
||||||
devices: Map<string, ZHADevice> | undefined
|
devices: Map<string, ZHADevice> | undefined
|
||||||
) => {
|
) => {
|
||||||
const outputDevices: DeviceRowData[] = [];
|
const outputDevices: DeviceRowData[] = [];
|
||||||
if (device && devices) {
|
if (device && devices) {
|
||||||
device.neighbors.forEach((child) => {
|
device.neighbors.forEach((neighbor) => {
|
||||||
const zhaDevice: ZHADevice | undefined = devices.get(child.ieee);
|
const zhaDevice: ZHADevice | undefined = devices.get(neighbor.ieee);
|
||||||
if (zhaDevice) {
|
if (zhaDevice) {
|
||||||
outputDevices.push({
|
outputDevices.push({
|
||||||
name: zhaDevice.user_given_name || zhaDevice.name,
|
name: zhaDevice.user_given_name || zhaDevice.name,
|
||||||
id: zhaDevice.device_reg_id,
|
id: zhaDevice.device_reg_id,
|
||||||
lqi: parseInt(child.lqi),
|
lqi: parseInt(neighbor.lqi),
|
||||||
|
depth: parseInt(neighbor.depth),
|
||||||
|
relationship: neighbor.relationship,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -55,22 +61,57 @@ class ZHADeviceChildren extends LitElement {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private _columns: DataTableColumnContainer = {
|
private _columns = memoizeOne(
|
||||||
name: {
|
(narrow: boolean): DataTableColumnContainer =>
|
||||||
title: "Name",
|
narrow
|
||||||
sortable: true,
|
? {
|
||||||
filterable: true,
|
name: {
|
||||||
direction: "asc",
|
title: this.hass.localize("ui.panel.config.zha.neighbors.name"),
|
||||||
grows: true,
|
sortable: true,
|
||||||
},
|
filterable: true,
|
||||||
lqi: {
|
direction: "asc",
|
||||||
title: "LQI",
|
grows: true,
|
||||||
sortable: true,
|
},
|
||||||
filterable: true,
|
lqi: {
|
||||||
type: "numeric",
|
title: this.hass.localize("ui.panel.config.zha.neighbors.lqi"),
|
||||||
width: "75px",
|
sortable: true,
|
||||||
},
|
filterable: true,
|
||||||
};
|
type: "numeric",
|
||||||
|
width: "75px",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
name: {
|
||||||
|
title: this.hass.localize("ui.panel.config.zha.neighbors.name"),
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
direction: "asc",
|
||||||
|
grows: true,
|
||||||
|
},
|
||||||
|
lqi: {
|
||||||
|
title: this.hass.localize("ui.panel.config.zha.neighbors.lqi"),
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
type: "numeric",
|
||||||
|
width: "75px",
|
||||||
|
},
|
||||||
|
relationship: {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.zha.neighbors.relationship"
|
||||||
|
),
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
width: "150px",
|
||||||
|
},
|
||||||
|
depth: {
|
||||||
|
title: this.hass.localize("ui.panel.config.zha.neighbors.depth"),
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
type: "numeric",
|
||||||
|
width: "75px",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.device) {
|
if (!this.device) {
|
||||||
@ -85,8 +126,8 @@ class ZHADeviceChildren extends LitElement {
|
|||||||
></ha-circular-progress>`
|
></ha-circular-progress>`
|
||||||
: html`<ha-data-table
|
: html`<ha-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.columns=${this._columns}
|
.columns=${this._columns(this.narrow)}
|
||||||
.data=${this._deviceChildren(this.device, this._devices)}
|
.data=${this._deviceNeighbors(this.device, this._devices)}
|
||||||
auto-height
|
auto-height
|
||||||
.dir=${computeRTLDirection(this.hass)}
|
.dir=${computeRTLDirection(this.hass)}
|
||||||
.searchLabel=${this.hass.localize(
|
.searchLabel=${this.hass.localize(
|
||||||
@ -111,6 +152,6 @@ class ZHADeviceChildren extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"zha-device-children": ZHADeviceChildren;
|
"zha-device-neighbors": ZHADeviceNeighbors;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1024,7 +1024,7 @@
|
|||||||
"clusters": "Clusters",
|
"clusters": "Clusters",
|
||||||
"bindings": "Bindings",
|
"bindings": "Bindings",
|
||||||
"signature": "Signature",
|
"signature": "Signature",
|
||||||
"children": "Children"
|
"neighbors": "Neighbors"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"zha_device_info": {
|
"zha_device_info": {
|
||||||
@ -3247,6 +3247,12 @@
|
|||||||
"unbind_button_label": "Unbind Group",
|
"unbind_button_label": "Unbind Group",
|
||||||
"bind_button_help": "Bind the selected group to the selected device clusters.",
|
"bind_button_help": "Bind the selected group to the selected device clusters.",
|
||||||
"unbind_button_help": "Unbind the selected group from the selected device clusters."
|
"unbind_button_help": "Unbind the selected group from the selected device clusters."
|
||||||
|
},
|
||||||
|
"neighbors": {
|
||||||
|
"name": "Name",
|
||||||
|
"lqi": "LQI",
|
||||||
|
"relationship": "Relationship",
|
||||||
|
"depth": "Depth"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"zwave_js": {
|
"zwave_js": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user