From 8ef690d91df2dadef7a80f60b4a896f7916919aa Mon Sep 17 00:00:00 2001 From: rgc99 Date: Wed, 17 Jan 2024 20:00:15 +0000 Subject: [PATCH] Fix zone_id reference --- src/irrigation-unlimited-card.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/irrigation-unlimited-card.ts b/src/irrigation-unlimited-card.ts index 1c00b3a..8392f60 100644 --- a/src/irrigation-unlimited-card.ts +++ b/src/irrigation-unlimited-card.ts @@ -28,7 +28,7 @@ console.info( description: 'A companion card for the Irrigation Unlimited integration', }); -type IUEntity = { entity_id: string; last_updated: Date; name: string | undefined }; +type IUEntity = { entity_id: string; last_updated: Date; name: string | undefined; zone_id: string }; @customElement('irrigation-unlimited-card') export class IrrigationUnlimitedCard extends LitElement { @@ -73,7 +73,7 @@ export class IrrigationUnlimitedCard extends LitElement { if (entity_id.startsWith("binary_sensor.irrigation_unlimited_")) { const entity = this.hass.states[entity_id] const date: Date = new Date(entity.last_updated); - this._iu_entities.push({ entity_id: entity_id, last_updated: date, name: entity.attributes.friendly_name }); + this._iu_entities.push({ entity_id: entity_id, last_updated: date, name: entity.attributes.friendly_name, zone_id: entity.attributes?.zone_id }); } } return true; @@ -421,7 +421,7 @@ export class IrrigationUnlimitedCard extends LitElement {
- ${sequenceZone.zone_ids.map((zoneRef: number, index: number, array) => this._renderSequenceZoneRef(controller, zoneRef, index === array.length - 1))} + ${sequenceZone.zone_ids.map((zoneRef: string, index: number, array) => this._renderSequenceZoneRef(controller, zoneRef, index === array.length - 1))}
@@ -440,12 +440,12 @@ export class IrrigationUnlimitedCard extends LitElement { `; } - private _renderSequenceZoneRef(controller: number, zoneRef: number, last: boolean): TemplateResult { - const entity_id = `binary_sensor.irrigation_unlimited_c${controller + 1}_z${zoneRef}`; + private _renderSequenceZoneRef(controller: number, zoneRef: string, last: boolean): TemplateResult { + const entity_id = `binary_sensor.irrigation_unlimited_c${controller + 1}_`; let name: string | undefined = undefined; if (this._iu_entities !== undefined) { for (const iu_entity of this._iu_entities) { - if (iu_entity.entity_id === entity_id) { + if (iu_entity.entity_id.startsWith(entity_id) && iu_entity.zone_id === zoneRef) { if (iu_entity.name) { name = iu_entity.name; } @@ -456,7 +456,7 @@ export class IrrigationUnlimitedCard extends LitElement { if (name) return html`${name}${last === false ? ", " : ""}`; return html` - ${zoneRef} + ${zoneRef} `; }