From 1d15f81b6c5721f54fae598bc61bd4d65c42c3c9 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 10 Jan 2023 18:28:07 +0100 Subject: [PATCH] Fixes moon badge icon (#15015) --- src/components/entity/ha-state-label-badge.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/entity/ha-state-label-badge.ts b/src/components/entity/ha-state-label-badge.ts index c51309ccfb..155294ef75 100644 --- a/src/components/entity/ha-state-label-badge.ts +++ b/src/components/entity/ha-state-label-badge.ts @@ -22,6 +22,7 @@ import { isNumericState, } from "../../common/number/format_number"; import { isUnavailableState, UNAVAILABLE, UNKNOWN } from "../../data/entity"; +import { EntityRegistryEntry } from "../../data/entity_registry"; import { timerTimeRemaining } from "../../data/timer"; import { HomeAssistant } from "../../types"; import "../ha-label-badge"; @@ -103,8 +104,10 @@ export class HaStateLabelBadge extends LitElement { // 4. Icon determined via entity state // 5. Value string as fallback const domain = computeStateDomain(entityState); + const entry = this.hass?.entities[entityState.entity_id]; - const showIcon = this.icon || this._computeShowIcon(domain, entityState); + const showIcon = + this.icon || this._computeShowIcon(domain, entityState, entry); const image = this.icon ? "" : this.image @@ -112,7 +115,9 @@ export class HaStateLabelBadge extends LitElement { : entityState.attributes.entity_picture_local || entityState.attributes.entity_picture; const value = - !image && !showIcon ? this._computeValue(domain, entityState) : undefined; + !image && !showIcon + ? this._computeValue(domain, entityState, entry) + : undefined; return html`