@fribse wrote:
Hi All
I’ve gotten all my sensors to show some sort of daily usage.
I’ve created a sensor to hold yesterdays usage:input_number: yesterday_powerusage: name: Samlet forbrug for i går min: 0 max: 20 mode: box unit_of_measurement: kWh icon: mdi:flash-outline
I created an automation to notify about the usage, which runs just before midnight:
- id: '1577539305551' alias: Rapportér dagligt forbrug description: '' trigger: - at: '23:59:50' platform: time action: - service: persistent_notification.create data_template: title: Strømforbrug message: 'Samlet forbrug for dagen: {{ states(''sensor.total_daily_power'') }} {{ state_attr(''sensor.total_daily_power'',''unit_of_measurement'') }}' - service: input_number.set_value data_template: entity_id: input_number.yesterday_powerusage value: '{{ states(''sensor.total_daily_power'')|float }}'
Then the sensors to hold the sums.
One is supposed to hold todays sum, as far as it has gotten for today.
The other is supposed to hold the usage from yesterday.total_daily_power: friendly_name: Samlet forbrug for i dag unit_of_measurement: kWh value_template: "{{ states.sensor|selectattr( 'entity_id','in',state_attr('group.daily_power_usage','entity_id')) | rejectattr('entity_id', 'equalto', 'sensor.power') | map(attribute='state')|map('float')|sum|round(3) }}" device_class: power total_daily_power_yesterday: friendly_name: Gårsdagens strømforbrug unit_of_measurement: kWh value_template: "{{ states('input_number.yesterday_powerusage') | float }}" device_class: power
Most of this works very well, I get a notification every night about the usage of the day.
The problem is that when I look at the usage the day after, it looks like this:
As you can see the ‘today’ usage, shows the ‘yesterdays usage’, and is not a sum of todays usage.
Posts: 1
Participants: 1