Filter hidden media players out of the media player menu.

This commit is contained in:
Dermot Duffy
2023-02-12 17:30:30 -08:00
parent 1d826cf415
commit 8c1fa511b0
4 changed files with 143 additions and 55 deletions
+19 -1
View File
@@ -42,7 +42,10 @@ export class EntityRegistryManager {
return await this.getExtendedEntity(hass, entityID);
}
public async getMatchingEntities(hass: HomeAssistant, func: (arg: Entity) => boolean): Promise<Entity[]> {
public async getMatchingEntities(
hass: HomeAssistant,
func: (arg: Entity) => boolean,
): Promise<Entity[]> {
await this.fetchEntityList(hass);
return this._cache.getMatches(func);
}
@@ -67,6 +70,21 @@ export class EntityRegistryManager {
return extendedEntity;
}
public async getEntities(
hass: HomeAssistant,
entityIDs: string[],
): Promise<Map<string, Entity>> {
const output: Map<string, Entity> = new Map();
const _storeEntity = async (entityID: string): Promise<void> => {
const entity = await this.getEntity(hass, entityID);
if (entity) {
output.set(entityID, entity);
}
};
await Promise.all(entityIDs.map(_storeEntity));
return output;
}
public async getExtendedEntities(
hass: HomeAssistant,
entityIDs: string[],