This is a roughly right (as good as the sensors) script to determine the daily average power peaks per month as used in Sweden (and other places maybe including Beligium?, Netherlands?). I used the method defined by Ellevio in Sweden here: https://www.ellevio.se/abonnemang/ny-prismodell-baserad-pa-effekt/
After a number of months of use, it works well and aligns well with our grid suppliers data.
I use this code today for some simpler load shedding / balancing / planning by being able to set a maximum allowed energy use each hour (based on the usage peaks and prices and monthly averages) to keep the peaks and prices lower.
output
The script provides a number of sensors to be able to support deeper understanding and debugging, they are numbered from 1 and up prefixed by EPPMA so they are easy to find and understand how they flow!
Within the script you will find more info regarding how it works, the process and the actual sensors.
Graphically in apex charts it is looking like this for checking/debug (previously):
import power (W) is used and as it comes in it is integrated to kWh… if you have a sensor already in kWh in a good enough time period you should be able to just put it into step 3! Mine did not run so often (like every 5-10min) so I went to import power which updates every few seconds which then required the integration.
configuration/install instructions
1. put the following line(s) in your configuration.yaml in the appropriate place (you can change the directory but you need to change it then appropriately):
a. after 5-10min check values in eppma_1 & 2 after a few moments (so long as you are importing data you will see something)
b. after 1st hour check values in eppma_3 & _4 for values from previous hour
c. after 1st day after 00:00 check eppma_5 & _6 and even 7 for previous days values
d. after 1st of month after 00:00ish check eppma _8 for results from previous month
help, advice, tips, improvements?
I can certainly learn more when it comes to jinja/yaml so I guess there are some improvements to be made here, some things I have identified which you can find in the open issues in the TODO section of the header within the code. If you find something or have ideas, let me know!
I have refactored the code into a package and renamed it
seems to be working well, give it a go!
oops… just made an edit to the code.(on the 1st post where I am leaving the latest version). it was on eppma_7 where I changed the name of the attribute at the last minute and missed to change it in the code.
Thanks fo rposting your code. I jus tinstalled it the other days and I am trying it out to see how it oerforms before my elctricity provider implements the new rules.
for me so far so good! (i made some corrections end of last month included above for the month) and it is matching very very closely my electric company!
This is what I am looking for, does it still work for you? I have hard to understand the graphs. Could you please post a picture of a graph showing a complete month?
it is working well for me - it is exactly correct over the last couple of months.
I have just corrected the code a bit as the monthly summary was not working correctly giving now closer to the correct time (still a conversion error between local and utc and back that I have not had time to fix).
I have tried to explain the graph a bit above, but I found myself that it is easier to load it and as data comes in hide everything and then step through them one by one in the beginning (1 - 7/8) to get a hang of how they are connected and the time shifts involved.
here is a picture of this month (note I have not included the statistical values so values for most sensors are not shown >10days … i could make a version with this but have not needed it so far myself)
what this tells me on the top is that just now we are using 0,37, so far the highest has been 0,24 (so it will go up shortly as right now it is at 0,37), the max of the day is 0,51 and the average of the 3 peaks this month is 1.01 … clicking that looking in attributes gives you the specific values)
Have you used these measurements & visualizations to inform automations for load shedding? We just got Effektavgift here in here Möndal, and I’m thinking I would do something like this. Eg turning off non critical devices to shed load. The EV charger and Heatpump are already controlled by Tibber, so I’ll leave those alone.
absolutely. we use it to inform and actively keep the peaks in check driving some primary load shedding (or rather the inverse, when to turn primary loads on) mainly using EPPMA 2 Energy per hour and to defer when applicable primary and other loads toward reduced price non peak hours and during the late evening/early morning 50% reductions.
Now that it has been running a while, given what we can automate and our own every changing needs, wants and priorities - I can say it has been pretty successful:
it matches well the data from our electric company,
it has informed and thereby impacted our behaviors and setups and
it has allowed us to automate the control of the primary loads (priorities)
This is great, looks fantastic,
need a little help though.
I assume that I need to update the: source: sensor.import_power
to get the power consumption into this. I use Tibber and have the realtime power sensor in W.
how do I convert it into kWh and how should the source sensor be configured to get everything working?
thanks
so,
in the process flow section in the code i have:
## process flow
# 1. import power -> integrate it to kWh.. i have power in watts coming in this should give kWh
# 2. u....
I believe that should be fine … so go to the EPPMA_1 (near the bottom)… and put in the entity id to your sensor that is in watts and that should be about it. you can see here is mine:
Thanks a lot!
I change the source to the realtime power sensor and now the EPPMA:1 is providing data and seems to work. I will assume the rest will follow when time passes by
I do not yet have it publicly available github. Do you mean just the code, or like a hacs integration?
If helpful to more I can look into it first putting up the code… give a heart/thumbs up here!