Skip to content

Commit

Permalink
fix: log warning if player is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Mar 23, 2024
1 parent ea57ab3 commit 128433c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/model/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export default class Store {
if (player) {
result = { player, volume };
}
} else {
console.warn(`Player ${pgEntityId} is unavailable`);
}
return result;
}
Expand Down Expand Up @@ -145,7 +147,11 @@ export default class Store {
);
const isGrouped = groupIds?.length > 1;
const isMainInGroup = isGrouped && groupIds && groupIds[0] === hassEntity.entity_id;
return (!isGrouped || isMainInGroup) && this.hass.states[hassEntity.entity_id]?.state !== 'unavailable';
const available = this.hass.states[hassEntity.entity_id]?.state !== 'unavailable';
if (!available) {
console.warn(`Player ${hassEntity.entity_id} is unavailable`);
}
return (!isGrouped || isMainInGroup) && available;
} catch (e) {
console.error('Failed to determine main player', JSON.stringify(hassEntity), e);
return false;
Expand Down

0 comments on commit 128433c

Please sign in to comment.