-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for negative prices and energy delivery #31
base: main
Are you sure you want to change the base?
Conversation
…) energy usage Added a calibration method which recalculates the cost at price change events (each hour) The most precise method of cost calculation is use the delta energy for the past hour and multiple this with the electricity price of that hour. Therefore at each price change event we calulate the cost for the past hour. However, as this will only update the cost each per hour I kept the original code for updates in the running hour, and overwrite this value with a more precise value
That is awesome - I'm on Octopus Agile in the UK and it has negative rates from time to time. I hadn't considered whether this was supported or not. Definitely of interest when charging my EV. |
I think we have to solve it with a bit more complex way. Issue is that at least in our region when you buy electricity total price will be nordpool + tariff + VAT (export), but when you sell electricity its nordpoool wo. VAT (import). Now at the moment only one price is given to the integration which in my case is total electricity price. Cost can be negative in two cases:
So to do this right and support all scenarios this should be done:
It looks a bit overwhelming for me, so any contributions are welcome. |
This makes sense if the integration is being used to measure the total energy spend for a household, but not my use case where I am only using it to measure the cost of running specific devices such as my EV. In those cases is the export price relevant? I'm quite happy using HA's built in Energy functions for calculating my overall spend, and just use this integration to see how much certain appliances are costing to run on a highly variable tariff that can go negative. I don't export energy so I can't say whether HA is good at handling that. |
I understand the complexity and as such I would suggest to keep the component as simple as possible, leaving out too many scenarios. For example on your second example: That is indeed true for a grid sensor but not when measuring an home-battery sensor. When the consumption of a device is negative I may not be "earning", but "saving" costs in which the correct costs savings are calculated using the import price (northpool with taxes). On the same token the energy cost of a device might be the "missed earnings" when the source of the electricity are solarpanels. We could indeed support two price sensors, one for positve energy usage and one for negative. However following the above rationale I recommend to have the price sensor itself to contain this logic, and determine the current electricity price based on if there is a net delivery, or net energy consumption to the grid. {% if states('sensor.net_energy_usage') | float >= 0 %} Using the above as price sensor would give a more exact costs indication. Afterall when your are net-delivering to the grid the energy price is what you "miss out" when not exporting to the grid |
ps. When the market price is negative, and you are net delivering, its costing you money. As such a device consuming energy is saving you money. With the above proposed price sensor this is correctly taken into account. When delivering energy, the price sensor is set to nordpool without taxes, which is then negative. The energy used with the negative nordpool price is then correctly reducing your total cost |
…ading to track the costs. The energy sensor events are kept for regular HA updates but using the energy and cumulative cost calculated at the last price sensor event
@Pluimvee, thank you very much for contributing. I’ve been so busy that I didn’t have time to maintain the integration. I think your approach looks good, so let’s proceed with it. Maybe in the future, we can think about adding import and export prices. Since I’m still quite busy, I’ve added access to the repository for you, so you can make the commit. It looks like there’s a conflict because of another pull request. Also, I would be happy if you could co-manage this integration. There are some other issues that need attention as well. EDIT: Did some more fixes, so @Pluimvee please check your pull request. |
I've added support for negative dynamic prices and decreasing energy usage. The latter is usefull for not only net P1 readings, but also for energy readings from home-batteries.
Additionally added a recalculation on each price change event (each hour), overwriting (and correcting) small roundings issues which occur in the normal loop triggered on each energy reading