I use Tibber prices to “smart” charge my solar battery in winter when I don’t get enough solar power.
So far I used a static value for my home cunsumption (10kWh) which worked reasonably well.
However, we added a Heat Pump to our home and it will soon start using quite a bit of electricity every day once the heating period starts.
Now my idea is this: Instead of using a static value to know how much I need to charge my battery when electricity is cheap, I want to creat a “3 Day Average” from my daily energy consumption and use that value as the new basis for my charging calculation.
I thought this would be easy, but unfortunately it has turned out to be impossible for me…
I have a Sensor (a Utility Meter with dayly reset) that gives me my energy consumption in kWh for each day. Yesterday’s value is stored in the “last_period” attribute. That is as far as I have managed to get so far.
I would like my new Sensor to collect data for a few days (let’s say 3 Days) and always give me the average of those three days. If I try to do that right now, I get a far too low value, because it takes the “last period” and combines it with the incomplete data for today, resulting in a far too low value.
I hope I managed to explain what I am trying to achieve.
I added it to my Configuration.yaml and the new Sensors show up, currently with status “Unkown” and “unavailable”.
I will keep them running and see if they populate over the next couple of days or if something is not working.
So…after leaving it running for several days I unfortunately have to report that the Sensor never populated any Data for me. The values always return as “unknown” and “unavailable”.
Unfortunately I don’t really know how to attempt fixing this since I don’t understand what the Sensors above are supposed to ve doing.
Thanks anyway for your help…I will keep looking for a solution.
Edit: I found a partial solution for now using the Average Sensor. The value is not quite as expected for some reason, but pretty close. I will keep monitroing it and see how it behaves.
That means the trigger never fired. Make sure you have entered the correct value for entity_id in the trigger.
The trigger-based sensor listens when your daily consumption sensor resets to zero, then it adds the value it changed from to a list stored in the history attribute. The last value in the list is dropped and the list is saved.
The state-based sensor just watches that list of three values and provides an average.
Hello, here’s another 2 sensor approach by using statistics:
- platform: statistics
name: Energy Consumed Last 3 Days
entity_id: sensor.<consumed_energy>
state_characteristic: change
max_age:
days: 3
precision: 1
unique_id: e_consumed_3_days
This sensor provides the delta of the consumed energy from now until 3 days in the past. Not exactly what you were looking for though so we need another sensor:
Thanks. I have managed to get a (more or less) working solution with the “Average Sensor” integration. It isn’t perfect, but appears to give me workable data. I will try your suggestion when I have a little time on my hands and see if it is better or worse than my current approach