I have a sensor which updates just before midnight to get the final reading cost of that days electricity. This sensor is then is fed into a Statistics (mean) sensor to give me an average cost based on the last weeks readings. My issue is that on a restart the first sensors value is restored which then upsets the Statistic calculation. Is there a way around this? Or is there a better way to do it?
- trigger:
- platform: time_pattern
hours: 23
minutes: 59
sensor:
- name: "Daily Energy Cost"
unique_id: 'daily_energy_cost'
icon: mdi:cash
state: "{{ states('sensor.smart_meter_energy_cost_today')|float }}"
unit_of_measurement: "GBP"
- platform: statistics
name: "Average Energy Cost"
unique_id: average_energy_cost
entity_id: sensor.daily_energy_cost
state_characteristic: mean
sampling_size: 7