From 0eb8b775cc11285cd2d0e851785bb4eebdbfe825 Mon Sep 17 00:00:00 2001 From: Quentame Date: Mon, 22 Jul 2024 15:19:20 +0000 Subject: [PATCH] gracefully use the default config.image if the person don't have an image (that works) --- src/panels/lovelace/cards/hui-picture-card.ts | 6 ++++-- src/panels/lovelace/cards/hui-picture-elements-card.ts | 6 ++++-- src/panels/lovelace/cards/hui-picture-entity-card.ts | 6 ++++-- src/panels/lovelace/cards/hui-picture-glance-card.ts | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/panels/lovelace/cards/hui-picture-card.ts b/src/panels/lovelace/cards/hui-picture-card.ts index faead7f3e7c3..f5abf64b5897 100644 --- a/src/panels/lovelace/cards/hui-picture-card.ts +++ b/src/panels/lovelace/cards/hui-picture-card.ts @@ -115,8 +115,10 @@ export class HuiPictureCard extends LitElement implements LovelaceCard { case "image": image = computeImageUrl(stateObj as ImageEntity); break; - case "person" && (stateObj as PersonEntity).attributes.entity_picture: - image = (stateObj as PersonEntity).attributes.entity_picture; + case "person": + if ((stateObj as PersonEntity).attributes.entity_picture) { + image = (stateObj as PersonEntity).attributes.entity_picture; + } break; } } diff --git a/src/panels/lovelace/cards/hui-picture-elements-card.ts b/src/panels/lovelace/cards/hui-picture-elements-card.ts index 115017c5ba62..143a2fde5858 100644 --- a/src/panels/lovelace/cards/hui-picture-elements-card.ts +++ b/src/panels/lovelace/cards/hui-picture-elements-card.ts @@ -127,8 +127,10 @@ class HuiPictureElementsCard extends LitElement implements LovelaceCard { case "image": image = computeImageUrl(stateObj as ImageEntity); break; - case "person" && (stateObj as PersonEntity).attributes.entity_picture: - image = (stateObj as PersonEntity).attributes.entity_picture; + case "person": + if ((stateObj as PersonEntity).attributes.entity_picture) { + image = (stateObj as PersonEntity).attributes.entity_picture; + } break; } } diff --git a/src/panels/lovelace/cards/hui-picture-entity-card.ts b/src/panels/lovelace/cards/hui-picture-entity-card.ts index de976ddb8719..ccc430b24371 100644 --- a/src/panels/lovelace/cards/hui-picture-entity-card.ts +++ b/src/panels/lovelace/cards/hui-picture-entity-card.ts @@ -144,8 +144,10 @@ class HuiPictureEntityCard extends LitElement implements LovelaceCard { case "image": image = computeImageUrl(stateObj as ImageEntity); break; - case "person" && (stateObj as PersonEntity).attributes.entity_picture: - image = (stateObj as PersonEntity).attributes.entity_picture; + case "person": + if ((stateObj as PersonEntity).attributes.entity_picture) { + image = (stateObj as PersonEntity).attributes.entity_picture; + } break; } diff --git a/src/panels/lovelace/cards/hui-picture-glance-card.ts b/src/panels/lovelace/cards/hui-picture-glance-card.ts index f91a5a513bee..d178dd68d3d4 100644 --- a/src/panels/lovelace/cards/hui-picture-glance-card.ts +++ b/src/panels/lovelace/cards/hui-picture-glance-card.ts @@ -193,8 +193,10 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard { case "image": image = computeImageUrl(stateObj as ImageEntity); break; - case "person" && (stateObj as PersonEntity).attributes.entity_picture: - image = (stateObj as PersonEntity).attributes.entity_picture; + case "person": + if ((stateObj as PersonEntity).attributes.entity_picture) { + image = (stateObj as PersonEntity).attributes.entity_picture; + } break; } }