Recently we made the switch from a variable energy contract to a dynamic energy contract (ANWB Energie) with a different energy price every hour. In this blog, we’re going to talk about a new integration I’ve been working on for the past month that will be available with the Home Assistant 2023.2 release.
That new integration is EnergyZero, a company where other parties can purchase their electricity/gas according to day-ahead market prices. Well-known partners who work with EnergyZero are, for example:
All the companies mentioned above are also available as a virtual integration in Home Assistant.
The idea of dynamic prices is that you can benefit more quickly from changes in the energy market. If you adjust your own energy consumption to consumption in the cheap hours, you could save quite a bit of money. However, there is always a risk because the price can also suddenly become more expensive on average, but in general you would be cheaper than a variable energy contract*.
*at least applicable to our situation
The integration
The integration consists of 2 services, one for gas and one for electricity.
Electricity market prices
The price can be different every hour and the new prices for the next day are published every afternoon around 14:00 UTC time. The following different types of entities are created:
- Th
e
current and next hour electricity market price - Average electricity price of the day
- Lowest energy price
- Highest energy price
- Time of day when the price is highest
- Time of day when the price is at its lowest
- Percentage of the current price compared to the maximum price of the day
Gas market prices
For gas service, only the current and next hour entity are created, because the prices only change once every 24 hours, so it would not really be necessary to show the min and max, for example. The new price will be published every morning around 05:00 UTC time.
More concrete information about this new integration can also be found in the documentation.
All-in price sensor template
The prices shown in the entities are raw prices that only include the 21% VAT. To determine the current all-in price you can use the template sensor below, which add the energy tax and storage costs. The templates below are based on added prices that ANWB Energie communicates, you may still have to adjust them for your own situation.
Templates were last updated on: 7-1-2024
- sensor:
- name: EnergyZero all-in current energy price
unique_id: allin_energy_current_price
icon: mdi:cash
unit_of_measurement: "€/kWh"
state_class: measurement
state: >
{% set energy_tax = 0.1312 %}
{% set purch_costs = 0.0484 %}
{% set current_price = states('sensor.energyzero_today_energy_current_hour_price') | float | default(None) %}
{{ (current_price + energy_tax + purch_costs) | round(2) }}
Personally, I use this entity in the Energy Dashboard to see if the calculated price in Home Assistant corresponds to what is stated in the ANWB Energie app.
You can make a similar template sensor for gas, but the added costs will be slightly different:
- sensor:
- name: EnergyZero all-in current gas price
unique_id: allin_gas_current_price
icon: mdi:cash
unit_of_measurement: "€/m³"
state_class: measurement
state: >
{% set energy_tax = 0.7065 %}
{% set purch_costs = 0.05911 %}
{% set current_price = states('sensor.energyzero_today_gas_current_hour_price') | float | default(None) %}
{{ (current_price + energy_tax + purch_costs) | round(4) }}
It may be possible that adjustments are still needed to these templates. So far a comparison between the ANWB Energie app and the Energy Dashboard in Home Assistant, shows a small difference.
Hourly price service calls
From Home Assistant version 2024.1, the EnergyZero integration has a number of service calls, with which you can request an array of hourly prices from EnergyZero and use them in an Apexchart.
The documentation of these service calls can be found here and to make it a bit easier for you, I’ve created a GitHub gist with code to create a trigger template sensor. This allows you to create template sensors for today and tomorrow. where the hourly price data is stored as an attribute in the template sensor. You will also find code to create a simple version of the above Apexcharts in your dashboard.
Package on PyPi
Do you want to collect the EnergyZero data in your own way and process it in another project? Then take a look at the repository of the python package, that is also on PyPi. The integration in Home Assistant also uses this package.
10 comments
Thanks for the work you put in the integration for HA.
Is it possible to add an extra feature for the addition costs (see Nordpool HACS integration)?
Kind regards,
Erik
The feature was considered, but ultimately decided not to add it because the additional costs are not given by the API.
See also this post on the community forum: https://community.home-assistant.io/t/hourly-electricity-prices-netherlands/485842/67
./Klaas
Hoi Erik, Klaas,
Allereerst wil ik me aansluiten bij de complimenten en dank voor de bestaande intergraties en het energy dashboard.
Voor Erik, mss kijken op YT ik zag daar oplossingen langskomen met een hulp getal en/of template sensoren om die ‘extra kosten’ toe te voegen boven op het basis tarief. Smart home junkie kanaal oid meen ik.
Aan Klaas, kwam via een opmerking in de Victron Community weer terug op jouw spoor. Gebruik(te) vorig jaar HA met Zuijdwijks slimme meter in parallel met P1meter van ztatz.nl om de ‘stroom die over is’ via transformator en Victron PV in een batterij te laden en later te ontladen met wat slimmer stekkers. Toch een MWh in huis gehouden. Dus kon je energie Dashboard goed gebruiken 👊🏼
Voor dit jaar het idee om dat te verbeteren met een multiplus II en minder omzet verliezen.
Ik ben (nog) geen programmeur en was aan het zoeken in bestaande oplossingen, want wijs worden van bestaand werk geeft hopelijk wat sneller overzicht en/of resultaat. Kwam bij Shelly-Victron/Venus code uit van Fabian Lauer, zag daar jou remark.
Nu groeit idee twee eigenlijk sneller dan de upgrade: het moet mogelijk zijn om vanuit P1monitor of Esphome-dsmr die data te trekken en op te laten halen/plaatsen in dbus-Venus OS.
Daarmee zou ik/men in de toekomst het aankopen en plaatsen van een speciale gridmeter besparen en koppelt de bestaande DSMR aan VenusOS, als invoer voor een ESS.
Hopelijk kom ik na genoeg zelfstudie tot inzicht om deze informatie stroom opgang te krijgen en iets bij te dragen aan onze community.
Hey Klaas,
Thanks for your work on this great integration. Installation and configuration was a breeze.
Have you considered adding additional sensors that calculate the next day cheapest hours? The lowest price time isn’t really useful for automation when its in the past. Also calculating an optimal time bracket for a device to run would be awesome to have.
The downside of showing the cheapest time tomorrow is that it is only available between 15:00 / 16:00 to 23:59. The question is whether you will still benefit from this, so with a nice use case I would like to take a look at it.
As for calculating the optimal time bracket, the easyEnergy integration already has something like that in place. I still need to add that to the EnergyZero package.
By the way, you can always email me directly with questions like this 😉
Hi Klaas, thank you so much for your integration.
I read your comment over at HA community that you added the total cost to your apex charts.
I created the helper template sensors(gas and electricity) with your code above.
Now I would like to add this to the Energy dashboard graphs/data. Can you please give a hint how to proceed?
The template sensors and the apex charts that I use are 2 separate things. The template sensor on my website is purely for showing the all-in price on your dashboard, or to use in the energy dashboard so that HA can calculate based on your consumption.
I know it is a popular feature request to put the hourly price data in apex charts, but the current core integration does not support that. But good news! That will change soon 😀
Hi Klaas,
Thank you. I used the UI of HA.
I copied the code above in a new Helper Template Sensor. But that did not work well, as I got a really strange graph with all colored blocks along the time scale for each price change. Also the Energy dashboard could not use it to calculate the cost.
So for example for Gas I had to use/copy only the part after; “state: >”.
Then in the fields below that you have to specify;
– Unit of Measurements. I put ; €/m³
– Device class. I selected ‘balance’ Is this right?
– State class. When I select measurement(as in the code), there is an error(unkown exclamation). So I put ; ‘Total’.
Maybe this can help others that use the UI.
As it currently stands on the website, it is really intended for use directly in YAML as a template sensor, no helpers via the UI. Soon there will be more things I can adjust on the website, so I will also include how to correctly create a template helper in the UI.
Hi Klaas,
Thank you.
I just update the template with the new code. Although the previous worked the last months very well as well.
I use the UI and the points above remain.
Also something valuable is to add comments like the source to your blog/website for reference (in the future) with something like:
{# source: https://student-techlife.com/2023/01/11/energyzero-market-prices-with-new-integration-in-home-assistant/amp/ #}