Reaching out to the community since I cannot figure this one out.
I have a trigger that is to update two sensors at the end of the hour, to get a hourly state to be able to visualize graphs in Grafana.
The trigger works the first time and sub-sequent hours for ‘electrical_yield_rate_summary_hour’.
However, the trigger only works the first time for ‘electrical_distribution_consumption_rate_summary_sek_hour’, but not for sub-sequent hours.
Both of the sensors has values.
The only difference is that ‘sensor.electrical_yield_rate_summary’ is update hourly, where-as ‘sensor.electrical_distribution_consumption_rate_summary_sek’ is only updated at reboot or when manually set.
Have I missed something here, or is this a bug/feature?
- trigger:
# Trigger at the near end of every hour, since we want to keep hourly states for energy costs.
- platform: time_pattern
hours: "/1"
minutes: "59"
seconds: "0"
sensor:
# We set the hourly state for: electrical_yield_rate_summary
- name: electrical_yield_rate_summary_hour
unit_of_measurement: 'SEK/kWh'
state_class: measurement
state: >
{% set snapshot = states('sensor.electrical_yield_rate_summary') %}
{% if (snapshot == 'unknown' or snapshot == 'unavailable') %}
{% set result = 0 %}
{% else %}
{% set result = float(snapshot)/100 %}
{% endif %}
{{ result | round(2) }}
# We set the hourly state for: electrical_distribution_consumption_rate_summary_sek
- name: electrical_distribution_consumption_rate_summary_sek_hour
unit_of_measurement: 'SEK/kWh'
state_class: measurement
state: >
{% set snapshot = states('sensor.electrical_distribution_consumption_rate_summary_sek') %}
{% if (snapshot == 'unknown' or snapshot == 'unavailable') %}
{% set result = 0 %}
{% else %}
{% set result = float(snapshot) %}
{% endif %}
{{ result }}