mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-18 07:56:44 +01:00
Fix ZHA device count not including devices without entities (#51322)
This commit is contained in:
committed by
Bram Kragten
parent
b558117d8c
commit
59361cbd38
@@ -75,18 +75,21 @@ class ZHAConfigDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const deviceIds = new Set<string>();
|
const devices = this._configEntry
|
||||||
|
? Object.values(this.hass.devices).filter((device) =>
|
||||||
|
device.config_entries.includes(this._configEntry!.entry_id)
|
||||||
|
)
|
||||||
|
: [];
|
||||||
|
const deviceCount = devices.length;
|
||||||
|
|
||||||
let entityCount = 0;
|
let entityCount = 0;
|
||||||
for (const entity of Object.values(this.hass.entities)) {
|
for (const entity of Object.values(this.hass.entities)) {
|
||||||
if (entity.platform === "zha") {
|
if (entity.platform === "zha") {
|
||||||
entityCount++;
|
entityCount++;
|
||||||
if (entity.device_id) {
|
|
||||||
deviceIds.add(entity.device_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const deviceOnline =
|
const deviceOnline =
|
||||||
this._offlineDevices < deviceIds.size || deviceIds.size === 0;
|
this._offlineDevices < deviceCount || deviceCount === 0;
|
||||||
return html`
|
return html`
|
||||||
<hass-subpage
|
<hass-subpage
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -96,8 +99,8 @@ class ZHAConfigDashboard extends LitElement {
|
|||||||
has-fab
|
has-fab
|
||||||
>
|
>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
${this._renderNetworkStatus(deviceOnline, deviceIds.size)}
|
${this._renderNetworkStatus(deviceOnline, deviceCount)}
|
||||||
${this._renderMyNetworkCard(deviceIds, entityCount)}
|
${this._renderMyNetworkCard(deviceCount, entityCount)}
|
||||||
${this._renderNavigationCard()} ${this._renderBackupCard()}
|
${this._renderNavigationCard()} ${this._renderBackupCard()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -165,7 +168,7 @@ class ZHAConfigDashboard extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderMyNetworkCard(deviceIds: Set<string>, entityCount: number) {
|
private _renderMyNetworkCard(deviceCount: number, entityCount: number) {
|
||||||
return html`
|
return html`
|
||||||
<ha-card class="nav-card">
|
<ha-card class="nav-card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@@ -189,7 +192,7 @@ class ZHAConfigDashboard extends LitElement {
|
|||||||
<div slot="headline">
|
<div slot="headline">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.zha.configuration_page.device_count",
|
"ui.panel.config.zha.configuration_page.device_count",
|
||||||
{ count: deviceIds.size }
|
{ count: deviceCount }
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ha-icon-next slot="end"></ha-icon-next>
|
<ha-icon-next slot="end"></ha-icon-next>
|
||||||
|
|||||||
Reference in New Issue
Block a user