Hide hidden updates from sidebar/settings (#21058)

This commit is contained in:
Paulus Schoutsen 2024-06-10 15:52:24 -04:00 committed by GitHub
parent 0d489213a4
commit d36bbfe07d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -327,6 +327,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
for (const entityId of Object.keys(this.hass.states)) { for (const entityId of Object.keys(this.hass.states)) {
if ( if (
entityId.startsWith("update.") && entityId.startsWith("update.") &&
!this.hass.entities[entityId]?.hidden &&
updateCanInstall(this.hass.states[entityId] as UpdateEntity) updateCanInstall(this.hass.states[entityId] as UpdateEntity)
) { ) {
updateCount++; updateCount++;

View File

@ -6,7 +6,7 @@ import {
mdiPower, mdiPower,
mdiRefresh, mdiRefresh,
} from "@mdi/js"; } from "@mdi/js";
import { HassEntities, UnsubscribeFunc } from "home-assistant-js-websocket"; import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import { import {
CSSResultGroup, CSSResultGroup,
LitElement, LitElement,
@ -177,7 +177,10 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
protected render(): TemplateResult { protected render(): TemplateResult {
const { updates: canInstallUpdates, total: totalUpdates } = const { updates: canInstallUpdates, total: totalUpdates } =
this._filterUpdateEntitiesWithInstall(this.hass.states); this._filterUpdateEntitiesWithInstall(
this.hass.states,
this.hass.entities
);
const { issues: repairsIssues, total: totalRepairIssues } = const { issues: repairsIssues, total: totalRepairIssues } =
this._repairsIssues; this._repairsIssues;
@ -306,8 +309,13 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
} }
private _filterUpdateEntitiesWithInstall = memoizeOne( private _filterUpdateEntitiesWithInstall = memoizeOne(
(entities: HassEntities): { updates: UpdateEntity[]; total: number } => { (
const updates = filterUpdateEntitiesWithInstall(entities); entities: HomeAssistant["states"],
entityRegistry: HomeAssistant["entities"]
): { updates: UpdateEntity[]; total: number } => {
const updates = filterUpdateEntitiesWithInstall(entities).filter(
(entity) => !entityRegistry[entity.entity_id]?.hidden
);
return { return {
updates: updates.slice(0, updates.length === 3 ? updates.length : 2), updates: updates.slice(0, updates.length === 3 ? updates.length : 2),