Hey Guys, I am struggling with the Automation for the reset.
It looks like it works … each hour / day / week / month / year the dynamic_energy_cost.reset_cost is triggered and the Value goes to 0€/h day week month year…
but seconds later all the “old” values come back and the prices go up again to roughly the same value than before the reset.
I reset the “Action” manually but that DEC Sensor of the Projector did not reset to 0 and stayed at 0,51€
target:
entity_id:
- sensor.beamer_kwh_hourly_energy_cost
action: dynamic_energy_cost.reset_cost
data: {}
Hourly Reset
alias: Dynamic Energy Cost - Reset costs of all hourly Sensors
description: >
Trigger: Jede volle Stunde, Aktion: Reset aller *_kwh_hourly_energy_cost Sensoren
trigger:
- platform: time_pattern
hours: "*"
minutes: 0
seconds: 0
condition:
- condition: template
value_template: >
{{ states.sensor | selectattr('entity_id', 'match',
'_kwh_hourly_energy_cost$') | list | length > 0 }}
action:
- service: dynamic_energy_cost.reset_cost
target:
entity_id: >
{% set sensors = states.sensor
| selectattr('entity_id', 'match', '_kwh_hourly_energy_cost$')
| map(attribute='entity_id')
| list %}
{{ sensors if sensors | length > 0 else ['sensor.dummy_does_not_exist'] }}
data:
label_id: kosten_stundlich
mode: single
Daily reset
alias: Dynamic Energy Cost - Reset costs of all daily Sensors
description: >
Trigger: Jeden Tag um Mitternacht, Aktion: Reset aller *_kwh_daily_energy_cost
Sensoren
triggers:
- at: "00:00:00"
trigger: time
conditions:
- condition: template
value_template: >
{{ states.sensor | selectattr('entity_id', 'match',
'_kwh_daily_energy_cost$') | list | length > 0 }}
action:
- service: dynamic_energy_cost.reset_cost
target:
entity_id: >
{% set sensors = states.sensor
| selectattr('entity_id', 'match', '_kwh_daily_energy_cost$')
| map(attribute='entity_id')
| list %}
{{ sensors if sensors | length > 0 else ['sensor.dummy_does_not_exist'] }}
data:
label_id: kosten_taglich
mode: single
Weekly Reset
alias: Dynamic Energy Cost - Reset costs of all weekly Sensors
description: >
Trigger: Jeden Sonntag um Mitternacht, Aktion: Reset aller
*_kwh_weekly_energy_cost Sensoren
triggers:
- at: "00:00:00"
trigger: time
conditions:
- condition: and
conditions:
- condition: template
value_template: |
{{ now().weekday() == 6 }}
- condition: template
value_template: >
{{ states.sensor | selectattr('entity_id', 'match',
'_kwh_weekly_energy_cost$') | list | length > 0 }}
action:
- service: dynamic_energy_cost.reset_cost
target:
entity_id: >
{% set sensors = states.sensor
| selectattr('entity_id', 'match', '_kwh_weekly_energy_cost$')
| map(attribute='entity_id')
| list %}
{{ sensors if sensors | length > 0 else ['sensor.dummy_does_not_exist'] }}
data:
label_id: kosten_wochentlich
mode: single
Monthly Reset
alias: Dynamic Energy Cost - Reset costs of all monthly Sensors
description: >
Trigger: Am 1. jeden Monats um Mitternacht, Aktion: Reset aller
*_kwh_monthly_energy_cost Sensoren
triggers:
- at: "00:00:00"
trigger: time
conditions:
- condition: and
conditions:
- condition: template
value_template: |
{{ now().day == 1 }}
- condition: template
value_template: >
{{ states.sensor | selectattr('entity_id', 'match',
'_kwh_monthly_energy_cost$') | list | length > 0 }}
action:
- service: dynamic_energy_cost.reset_cost
target:
entity_id: >
{% set sensors = states.sensor
| selectattr('entity_id', 'match', '_kwh_monthly_energy_cost$')
| map(attribute='entity_id')
| list %}
{{ sensors if sensors | length > 0 else ['sensor.dummy_does_not_exist'] }}
data:
label_id: kosten_monatlich
mode: single
Yearly Reset
alias: Dynamic Energy Cost - Reset costs of all yearly Sensors
description: >
Trigger: Am 1. Januar um Mitternacht, Aktion: Reset aller
*_kwh_yearly_energy_cost Sensoren
triggers:
- at: "00:00:00"
trigger: time
conditions:
- condition: and
conditions:
- condition: template
value_template: |
{{ now().month == 1 and now().day == 1 }}
- condition: template
value_template: >
{{ states.sensor | selectattr('entity_id', 'match',
'_kwh_yearly_energy_cost$') | list | length > 0 }}
action:
- service: dynamic_energy_cost.reset_cost
target:
entity_id: >
{% set sensors = states.sensor
| selectattr('entity_id', 'match', '_kwh_yearly_energy_cost$')
| map(attribute='entity_id')
| list %}
{{ sensors if sensors | length > 0 else ['sensor.dummy_does_not_exist'] }}
data:
label_id: kosten_jahrlich
mode: single