From 2c29890b74dd7fc5a83e376c432e295f07fe669d Mon Sep 17 00:00:00 2001 From: Arjan <44190435+vingerha@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:29:03 +0200 Subject: [PATCH 1/4] Add Tempo remaining days --- dist/content-card-linky-editor.js | 5 +++++ dist/content-card-linky.js | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dist/content-card-linky-editor.js b/dist/content-card-linky-editor.js index 97da5f8..a9c495e 100644 --- a/dist/content-card-linky-editor.js +++ b/dist/content-card-linky-editor.js @@ -53,6 +53,10 @@ export class contentCardLinkyEditor extends LitElement { return this._config.ewEntityJ2 || ""; } + get _tempoEntity() { + return this._config.tempoEntity || ""; + } + get _tempoEntityJ0() { return this._config.tempoEntityJ0 || ""; } @@ -195,6 +199,7 @@ export class contentCardLinkyEditor extends LitElement { ${this.renderSensorPicker("EcoWatt", this._ewEntity, "ewEntity")} ${this.renderSensorPicker("EcoWattJ1", this._ewEntityJ1, "ewEntityJ1")} ${this.renderSensorPicker("EcoWattJ2", this._ewEntityJ2, "ewEntityJ2")} + ${this.renderSensorPicker("Tempo", this._tempoEntity, "tempoEntity")} ${this.renderSensorPicker("TempoJ0", this._tempoEntityJ0, "tempoEntityJ0")} ${this.renderSensorPicker("TempoJ1", this._tempoEntityJ1, "tempoEntityJ1")} diff --git a/dist/content-card-linky.js b/dist/content-card-linky.js index fd07a23..eda64c9 100644 --- a/dist/content-card-linky.js +++ b/dist/content-card-linky.js @@ -693,6 +693,13 @@ class ContentCardLinky extends LitElement { return [tempoDate, tempoValues.get(tempoValue), tempoValue]; } + getTempoRemainingDays(tempoEntity) { + let tempoRemainingRed = new Date(tempoEntity.attributes["days_red"]); + let tempoRemainingWhite = new Date(tempoEntity.attributes["days_white"]); + let tempoRemainingBlue = new Date(tempoEntity.attributes["days_blue"]); + return [tempoRemainingRed, tempoRemainingWhite, tempoRemainingBlue]; + } + renderTempo(attributes, config) { if (attributes.serviceEnedis === undefined ){ return html ``; @@ -703,17 +710,23 @@ class ContentCardLinky extends LitElement { if (this.config.showTempo === false ){ return html ``; } + let sensorName = this.config.tempoEntity; + const tempo = this.hass.states[sensorName]; let sensorNameJ0 = this.config.tempoEntityJ0; const tempoJ0 = this.hass.states[sensorNameJ0]; let sensorNameJ1 = this.config.tempoEntityJ1; const tempoJ1 = this.hass.states[sensorNameJ1]; if (!tempoJ0 || tempoJ0.length === 0 || !tempoJ1 || tempoJ1.length === 0) { - return html `Tempo: sensor(s) indisponible ou incorrecte`; + return html `Tempo: sensor(s) J0 et/ou J1 indisponible ou incorrecte`; + } + if (!tempo || tempo.length === 0) { + return html `Tempo: sensor tempo indisponible ou incorrecte`; } let [dateJ0, valueJ0, stateJ0] = this.getTempoDateValue(tempoJ0); let [dateJ1, valueJ1, stateJ1] = this.getTempoDateValue(tempoJ1); + let [remainingRed, remainingWhite, remainingBlue] = this.getTempoRemainingDays(tempo); return html` @@ -721,6 +734,11 @@ class ContentCardLinky extends LitElement { + + + + +
${ (new Date(dateJ0)).toLocaleDateString('fr-FR', {weekday: 'long', day: 'numeric'})} ${ (new Date(dateJ1)).toLocaleDateString('fr-FR', {weekday: 'long', day: 'numeric'})}
${remainingRed}${remainingWhite}${remainingBlue}
` From 26c2fa4aa9ae4593669c660db40505c627b3905e Mon Sep 17 00:00:00 2001 From: Arjan <44190435+vingerha@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:38:41 +0200 Subject: [PATCH 2/4] Update content-card-linky.js --- dist/content-card-linky.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/content-card-linky.js b/dist/content-card-linky.js index eda64c9..ab675f4 100644 --- a/dist/content-card-linky.js +++ b/dist/content-card-linky.js @@ -734,6 +734,8 @@ class ContentCardLinky extends LitElement { ${ (new Date(dateJ0)).toLocaleDateString('fr-FR', {weekday: 'long', day: 'numeric'})} ${ (new Date(dateJ1)).toLocaleDateString('fr-FR', {weekday: 'long', day: 'numeric'})} + + From 1a27f4888e26f4ffed773a66674402f0b84609db Mon Sep 17 00:00:00 2001 From: Arjan <44190435+vingerha@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:44:19 +0200 Subject: [PATCH 3/4] Update content-card-linky.js --- dist/content-card-linky.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/content-card-linky.js b/dist/content-card-linky.js index ab675f4..4587834 100644 --- a/dist/content-card-linky.js +++ b/dist/content-card-linky.js @@ -694,9 +694,9 @@ class ContentCardLinky extends LitElement { } getTempoRemainingDays(tempoEntity) { - let tempoRemainingRed = new Date(tempoEntity.attributes["days_red"]); - let tempoRemainingWhite = new Date(tempoEntity.attributes["days_white"]); - let tempoRemainingBlue = new Date(tempoEntity.attributes["days_blue"]); + let tempoRemainingRed = tempoEntity.attributes["days_red"]; + let tempoRemainingWhite = tempoEntity.attributes["days_white"]; + let tempoRemainingBlue = tempoEntity.attributes["days_blue"]; return [tempoRemainingRed, tempoRemainingWhite, tempoRemainingBlue]; } From 998652c9c3c1491d7132acc85f0117bebe6284e3 Mon Sep 17 00:00:00 2001 From: Arjan <44190435+vingerha@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:28:44 +0200 Subject: [PATCH 4/4] Finetuning --- dist/content-card-linky-editor.js | 4 ++-- dist/content-card-linky.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/content-card-linky-editor.js b/dist/content-card-linky-editor.js index a9c495e..418b73b 100644 --- a/dist/content-card-linky-editor.js +++ b/dist/content-card-linky-editor.js @@ -54,7 +54,7 @@ export class contentCardLinkyEditor extends LitElement { } get _tempoEntity() { - return this._config.tempoEntity || ""; + return this._config.tempoEntityInfo || ""; } get _tempoEntityJ0() { @@ -199,7 +199,7 @@ export class contentCardLinkyEditor extends LitElement { ${this.renderSensorPicker("EcoWatt", this._ewEntity, "ewEntity")} ${this.renderSensorPicker("EcoWattJ1", this._ewEntityJ1, "ewEntityJ1")} ${this.renderSensorPicker("EcoWattJ2", this._ewEntityJ2, "ewEntityJ2")} - ${this.renderSensorPicker("Tempo", this._tempoEntity, "tempoEntity")} + ${this.renderSensorPicker("TempoInfo", this._tempoEntityInfo, "tempoEntityInfo")} ${this.renderSensorPicker("TempoJ0", this._tempoEntityJ0, "tempoEntityJ0")} ${this.renderSensorPicker("TempoJ1", this._tempoEntityJ1, "tempoEntityJ1")} diff --git a/dist/content-card-linky.js b/dist/content-card-linky.js index 4587834..9a30753 100644 --- a/dist/content-card-linky.js +++ b/dist/content-card-linky.js @@ -710,8 +710,8 @@ class ContentCardLinky extends LitElement { if (this.config.showTempo === false ){ return html ``; } - let sensorName = this.config.tempoEntity; - const tempo = this.hass.states[sensorName]; + let sensorName = this.config.tempoEntityInfo; + const tempoInfo = this.hass.states[sensorName]; let sensorNameJ0 = this.config.tempoEntityJ0; const tempoJ0 = this.hass.states[sensorNameJ0]; let sensorNameJ1 = this.config.tempoEntityJ1; @@ -720,13 +720,13 @@ class ContentCardLinky extends LitElement { if (!tempoJ0 || tempoJ0.length === 0 || !tempoJ1 || tempoJ1.length === 0) { return html `Tempo: sensor(s) J0 et/ou J1 indisponible ou incorrecte`; } - if (!tempo || tempo.length === 0) { - return html `Tempo: sensor tempo indisponible ou incorrecte`; + if (!tempoInfo || tempoInfo.length === 0) { + return html `Tempo: sensor 'info' indisponible ou incorrecte`; } let [dateJ0, valueJ0, stateJ0] = this.getTempoDateValue(tempoJ0); let [dateJ1, valueJ1, stateJ1] = this.getTempoDateValue(tempoJ1); - let [remainingRed, remainingWhite, remainingBlue] = this.getTempoRemainingDays(tempo); + let [remainingRed, remainingWhite, remainingBlue] = this.getTempoRemainingDays(tempoInfo); return html`
${remainingRed} ${remainingWhite}