Update ZHA config panel to handle the addition of ZHA devices for the Zigbee coordinator (#4541)

* only show when there are entities

* handle coordinator correctly
This commit is contained in:
David F. Mulcahey 2020-01-21 04:35:31 -05:00 committed by Bram Kragten
parent 83756a338a
commit 38be488f86
4 changed files with 67 additions and 48 deletions

View File

@ -56,6 +56,7 @@ class DialogZHADeviceInfo extends LitElement {
.device=${this._device}
@zha-device-removed=${this._onDeviceRemoved}
.showEntityDetail=${false}
.showActions="${this._device.device_type !== "Coordinator"}"
></zha-device-card>
`}
</ha-paper-dialog>

View File

@ -224,13 +224,19 @@ class ZHADeviceCard extends LitElement {
`
)}
</div>
<div class="card-actions">
<mwc-button @click=${this._addToLovelaceView}>
${this.hass.localize(
"ui.panel.config.devices.entities.add_entities_lovelace"
)}
</mwc-button>
</div>
${
this.device!.entities && this.device!.entities.length > 0
? html`
<div class="card-actions">
<mwc-button @click=${this._addToLovelaceView}>
${this.hass.localize(
"ui.panel.config.devices.entities.add_entities_lovelace"
)}
</mwc-button>
</div>
`
: ""
}
${
this.showEditableInfo
? html`

View File

@ -79,48 +79,53 @@ export class ZHADevicePage extends LitElement {
.hass="${this.hass}"
.device=${this.device}
></zha-node>
<zha-clusters
.hass="${this.hass}"
.isWide="${this.isWide}"
.selectedDevice="${this.device}"
@zha-cluster-selected="${this._onClusterSelected}"
></zha-clusters>
${this._selectedCluster
? html`
<zha-cluster-attributes
.isWide="${this.isWide}"
.hass="${this.hass}"
.selectedNode="${this.device}"
.selectedCluster="${this._selectedCluster}"
></zha-cluster-attributes>
<zha-cluster-commands
.isWide="${this.isWide}"
.hass="${this.hass}"
.selectedNode="${this.device}"
.selectedCluster="${this._selectedCluster}"
></zha-cluster-commands>
`
: ""}
${this._bindableDevices.length > 0
${this.device && this.device.device_type !== "Coordinator"
? html`
<zha-device-binding-control
.isWide="${this.isWide}"
<zha-clusters
.hass="${this.hass}"
.selectedDevice="${this.device}"
.bindableDevices="${this._bindableDevices}"
></zha-device-binding-control>
`
: ""}
${this.device && this._groups.length > 0
? html`
<zha-group-binding-control
.isWide="${this.isWide}"
.narrow="${this.narrow}"
.hass="${this.hass}"
.selectedDevice="${this.device}"
.groups="${this._groups}"
></zha-group-binding-control>
@zha-cluster-selected="${this._onClusterSelected}"
></zha-clusters>
${this._selectedCluster
? html`
<zha-cluster-attributes
.isWide="${this.isWide}"
.hass="${this.hass}"
.selectedNode="${this.device}"
.selectedCluster="${this._selectedCluster}"
></zha-cluster-attributes>
<zha-cluster-commands
.isWide="${this.isWide}"
.hass="${this.hass}"
.selectedNode="${this.device}"
.selectedCluster="${this._selectedCluster}"
></zha-cluster-commands>
`
: ""}
${this._bindableDevices.length > 0
? html`
<zha-device-binding-control
.isWide="${this.isWide}"
.hass="${this.hass}"
.selectedDevice="${this.device}"
.bindableDevices="${this._bindableDevices}"
></zha-device-binding-control>
`
: ""}
${this.device && this._groups.length > 0
? html`
<zha-group-binding-control
.isWide="${this.isWide}"
.narrow="${this.narrow}"
.hass="${this.hass}"
.selectedDevice="${this.device}"
.groups="${this._groups}"
></zha-group-binding-control>
`
: ""}
`
: ""}
<div class="spacer" />
@ -137,14 +142,20 @@ export class ZHADevicePage extends LitElement {
private async _fetchData(): Promise<void> {
if (this.ieee && this.hass) {
this.device = await fetchZHADevice(this.hass, this.ieee);
this._bindableDevices = (
await fetchBindableDevices(this.hass, this.ieee)
).sort(sortZHADevices);
this._bindableDevices =
this.device && this.device.device_type !== "Coordinator"
? (await fetchBindableDevices(this.hass, this.ieee)).sort(
sortZHADevices
)
: [];
}
}
private async _fetchGroups() {
this._groups = (await fetchGroups(this.hass!)).sort(sortZHAGroups);
this._groups =
this.device && this.device.device_type !== "Coordinator"
? (await fetchGroups(this.hass!)).sort(sortZHAGroups)
: [];
}
static get styles(): CSSResult[] {

View File

@ -67,6 +67,7 @@ export class ZHANode extends LitElement {
showName
showModelInfo
.showEntityDetail=${false}
.showActions="${this.device.device_type !== "Coordinator"}"
@zha-device-removed=${this._onDeviceRemoved}
></zha-device-card>
`