From e070c8626c570ff6e0a9273414d274b67389ab36 Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Thu, 8 Jun 2023 01:16:40 +0200 Subject: [PATCH 1/2] Increase compatibility with older HA versions --- src/components/tile.ts | 1 + src/localize/hass/compute_attribute_display.ts | 2 +- src/localize/hass/compute_state_display.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/tile.ts b/src/components/tile.ts index 02649333..22091655 100644 --- a/src/components/tile.ts +++ b/src/components/tile.ts @@ -44,6 +44,7 @@ export class Tile extends RootlessLitElement { } this.className = `tile-wrapper clickable ripple ${this.config.tile_id ? `tile-${this.config.tile_id}-wrapper` : ""}`; const stateObj = this.config.entity ? this.hass.states[this.config.entity] : undefined; + if (!stateObj) return; const title = this.getTileLabel(stateObj); const value = this.getTileValue(stateObj); const icon = this.getIcon(stateObj); diff --git a/src/localize/hass/compute_attribute_display.ts b/src/localize/hass/compute_attribute_display.ts index 5d6173fb..0a4f532e 100644 --- a/src/localize/hass/compute_attribute_display.ts +++ b/src/localize/hass/compute_attribute_display.ts @@ -87,7 +87,7 @@ export const computeAttributeValueDisplay = ( const entityId = stateObj.entity_id; const domain = computeDomain(entityId); const deviceClass = stateObj.attributes.device_class; - const registryEntry = entities[entityId] as + const registryEntry = entities?.[entityId] as | EntityRegistryDisplayEntry | undefined; const translationKey = registryEntry?.translation_key; diff --git a/src/localize/hass/compute_state_display.ts b/src/localize/hass/compute_state_display.ts index f2ff98f5..7ed98b0b 100644 --- a/src/localize/hass/compute_state_display.ts +++ b/src/localize/hass/compute_state_display.ts @@ -41,7 +41,7 @@ export const computeStateDisplay = ( entities: HomeAssistantFixed["entities"], state?: string ): string => { - const entity = entities[stateObj.entity_id] as + const entity = entities?.[stateObj.entity_id] as | EntityRegistryDisplayEntry | undefined; From 63f1b2f7de207e2083878c49c94f3ad76c091c26 Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Thu, 8 Jun 2023 01:18:20 +0200 Subject: [PATCH 2/2] Set version to v2.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ff54edd..be7c09b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaomi-vacuum-map-card", - "version": "v2.2.1", + "version": "v2.2.2", "description": "Xiaomi Vacuum Map Card", "keywords": [ "home-assistant",