Fix counting entity states

Entity states where counted multiple times if those entities also belong
to a group. `Group` entities are excluded from the count now.
This commit is contained in:
DigiLive
2025-06-03 20:57:18 +02:00
parent 0bcc1a417a
commit e806ffd3d5

View File

@@ -12,7 +12,7 @@ import {
StrategyConfig, StrategyConfig,
StrategyViewConfig, StrategyViewConfig,
SupportedDomains, SupportedDomains,
SupportedViews SupportedViews,
} from './types/strategy/strategy-generics'; } from './types/strategy/strategy-generics';
import { logMessage, lvlFatal, lvlOff, lvlWarn, setDebugLevel } from './utilities/debug'; import { logMessage, lvlFatal, lvlOff, lvlWarn, setDebugLevel } from './utilities/debug';
import setupCustomLocalize from './utilities/localize'; import setupCustomLocalize from './utilities/localize';
@@ -37,10 +37,6 @@ class Registry {
/** Entries of Home Assistant's device registry. */ /** Entries of Home Assistant's device registry. */
private static _devices: DeviceRegistryEntry[]; private static _devices: DeviceRegistryEntry[];
/** Entries of Home Assistant's state registry */
private static _hassStates: HassEntities;
/** Indicates whether this module is initialized. */
private static _initialized: boolean = false;
/** /**
* Home Assistant's Device registry. * Home Assistant's Device registry.
@@ -52,6 +48,22 @@ class Registry {
return Registry._devices; return Registry._devices;
} }
/** Entries of Home Assistant's state registry */
private static _hassStates: HassEntities;
/** Home Assistant's State registry. */
static get hassStates(): HassEntities {
return Registry._hassStates;
}
/** Indicates whether this module is initialized. */
private static _initialized: boolean = false;
/** Get the initialization status of the Registry class. */
static get initialized(): boolean {
return Registry._initialized;
}
/** Entries of Home Assistant's entity registry. */ /** Entries of Home Assistant's entity registry. */
private static _entities: EntityRegistryEntry[]; private static _entities: EntityRegistryEntry[];
@@ -68,11 +80,6 @@ class Registry {
/** Entries of Home Assistant's area registry. */ /** Entries of Home Assistant's area registry. */
private static _areas: StrategyArea[] = []; private static _areas: StrategyArea[] = [];
/** Home Assistant's State registry. */
static get hassStates(): HassEntities {
return Registry._hassStates;
}
/** /**
* Home Assistant's Area registry. * Home Assistant's Area registry.
* *
@@ -83,11 +90,6 @@ class Registry {
return Registry._areas; return Registry._areas;
} }
/** Get the initialization status of the Registry class. */
static get initialized(): boolean {
return Registry._initialized;
}
/** The Custom strategy configuration. */ /** The Custom strategy configuration. */
private static _strategyOptions: StrategyConfig; private static _strategyOptions: StrategyConfig;
@@ -252,7 +254,7 @@ class Registry {
states.push( states.push(
...new RegistryFilter(Registry.entities) ...new RegistryFilter(Registry.entities)
.whereDomain(domain) .whereDomain(domain)
.where((entity) => !entity.entity_id.endsWith('_stateful_scene')) .where((entity) => !entity.entity_id.endsWith('_stateful_scene') && entity.platform !== 'group')
.toList() .toList()
.map((entity) => `states['${entity.entity_id}']`), .map((entity) => `states['${entity.entity_id}']`),
); );