From 128433c5e8e73da03816a544c21001ff4966a769 Mon Sep 17 00:00:00 2001 From: Johan Frick Date: Sat, 23 Mar 2024 10:47:18 +0100 Subject: [PATCH] fix: log warning if player is not available --- src/model/store.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/model/store.ts b/src/model/store.ts index 6cc1163..af82073 100644 --- a/src/model/store.ts +++ b/src/model/store.ts @@ -108,6 +108,8 @@ export default class Store { if (player) { result = { player, volume }; } + } else { + console.warn(`Player ${pgEntityId} is unavailable`); } return result; } @@ -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;