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,6 +224,9 @@ class ZHADeviceCard extends LitElement {
`
)}
</div>
${
this.device!.entities && this.device!.entities.length > 0
? html`
<div class="card-actions">
<mwc-button @click=${this._addToLovelaceView}>
${this.hass.localize(
@ -231,6 +234,9 @@ class ZHADeviceCard extends LitElement {
)}
</mwc-button>
</div>
`
: ""
}
${
this.showEditableInfo
? html`

View File

@ -79,6 +79,9 @@ export class ZHADevicePage extends LitElement {
.hass="${this.hass}"
.device=${this.device}
></zha-node>
${this.device && this.device.device_type !== "Coordinator"
? html`
<zha-clusters
.hass="${this.hass}"
.isWide="${this.isWide}"
@ -123,6 +126,8 @@ export class ZHADevicePage extends LitElement {
></zha-group-binding-control>
`
: ""}
`
: ""}
<div class="spacer" />
</hass-subpage>
`;
@ -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>
`