Merge pull request #1019 from dermotduffy/media-player-non-entity

Tolerate media players not in the entity registry
This commit is contained in:
Dermot Duffy
2023-03-19 15:06:03 -07:00
committed by GitHub
2 changed files with 14 additions and 4 deletions
+6 -3
View File
@@ -1154,9 +1154,12 @@ class FrigateCard extends LitElement {
// Filter out entities that are marked as hidden (this information is not
// available in the HA state, only in the registry).
this._mediaPlayers = [...mediaPlayerEntities.values()]
.filter((entity) => !entity.hidden_by)
.map((entity) => entity.entity_id);
this._mediaPlayers = mediaPlayers.filter((entityID) => {
// Specifically allow for media players that are not found in the entity registry:
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1016
const entity = mediaPlayerEntities.get(entityID);
return !entity || !entity.hidden_by;
});
}
/**
+8 -1
View File
@@ -43,7 +43,14 @@ export class EntityRegistryManager {
): 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);
let entity: Entity | null = null;
try {
entity = await this.getEntity(hass, entityID);
} catch {
// When asked to fetch multiple entities, ignore missing entities (they
// will just not feature in the output).
return;
}
if (entity) {
output.set(entityID, entity);
}