Home » Blog » How to Track Dynamic Energy Prices in Home Assistant NOW!

How to Track Dynamic Energy Prices in Home Assistant NOW!

Energy prices are going through the roof these days. Some energy companies deliver dynamic energy prices so that the price of energy changes every hour. This way, you can turn on your appliances when the prices are low. I am going to show you in this tutorial how you can create a bar chart of the dynamic energy prices in Home Assistant so that you can monitor these prices and see when it’s the best time to turn on appliances like your washing machine. And on top of that, you learn more about how to work with templates in Home Assistant.

⭐⭐⭐ NOTE: ⭐⭐⭐

This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. To keep doing this, I would like to ask you to check out the video, leave a comment under the video, give the video a thumbs up, and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.

Thank you for your support!


Click here to watch the video


There are a couple of ways to retrieve dynamic energy prices. I will use the Nordpool service in this tutorial to explain how you can work with these prices. Next to that, I will show how to use the ENTSO-e service and how you can use Zonneplan which is a Dutch provider. So you can choose the right provider for you depending on where you live. Not all areas in the world are covered by these services, but you can apply the way of working in this tutorial to your own service if it’s available in Home Assistant.

Install the Nordpool integration in Home Assistant

Okay, let’s start by installing the Nordpool integration in Home Assistant. We need HACS for that. If you haven’t got HACS installed yet, then please check out this easy-to-follow video where I explain how you can install HACS in Home Assistant.

  • Go to HACS.
  • Go to Integrations.
  • Click Explore & Download repositories.
  • Search for Nordpool.
  • Click Nordpool.
  • Click Download.
  • Click Download again.
  • Now restart Home Assistant.
  • Go to Settings.
  • Go to System and click Restart.
  • After the restart has finished, go to Settings > Devices and Services.
  • Click Add Integration.
  • Search for Nord Pool.
  • Click Nord Pool.
  • The configuration wizard for Nord Pool will now start.
  • Select your Region here. If your region is not available, you might want to try the ENTSO-e integration which I will cover in a minute. But, the template that I am about to create works the same for that integration, so please stay tuned before you install the ENTSO-e integration.
  • Now select your currency.
  • You can add a template for additional costs here, but you cannot change that afterward. You can also add additional costs to the template that I will create later. This way you will be a lot more flexible and I recommend leaving this field empty and following the procedure that I use for this.
  • Click Submit.
  • Click Finish.

View the data of the Nord Pool integration

Now the Nordpool integration is installed. Let’s see what data it sends to Home Assistant.

  • Go to Developer Tools.
  • Click the States tab.
  • Search for Nordpool.
  • Click on your Nordpool entity. You see that the entity contains the region and currency in the name. That is NL and EUR for me. This can be different for you if you are living in a different area. So, make sure that you take note of what the exact entity name is in your case.
  • The state contains the current energy price.
  • If you look into the state attributes, you see that the prices of today and tomorrow are shown in a list. First, there is a list with the prices of today and after that a list with the prices of tomorrow. These lists are followed by two other lists. One is called raw_today and contains the start and end times of prices including the prices of today. After that, the list raw_tomorrow is shown that contains the times and prices of tomorrow.
  • Now I do not want one bar chart for today and one separate bar chart for tomorrow, but I want one bar chart that shows the prices of today and tomorrow combined. This is why I am going to create a template sensor that stores all the hours and prices in just one list. You see a start time, an end time, and a value in each list item. We are going to make use of the start time and value in our template. And another thing is that Nordpool only shows the purchase prices. On top of that, there are other costs and VAT that are being charged by my own energy provider, so I want to add additional costs to the prices as well in the template. This way, the prices will match the prices of my own energy provider.

But before we go on, please give this video a thumbs up, subscribe to my channel and hit the notification bell. This helps me to create new tutorials for you.

Create a helper for the additional costs

I will now create a number helper that stores the extra costs so that we can use that helper in the template that we are going to create.

  • Go to Settings > Devices and Services.
  • Click on the Helpers Tab.
  • Click Create Helper.
  • Select the Number helper.
  • Give it a name.
  • I’m going to select the euro icon for the icon here.
  • The display mode is Input field.
  • and the step size is 0.001.
  • I enter the euro sign as unit of measurement.
  • Click create.

Create the template to show the energy prices for each hour.

Let’s create the template! You can copy all the code that I use in this tutorial from the screen, but you can also download the code via the download link in the description. Next to that, the download link contains extra code for the ENTSO-e and Zonneplan services, so that you can choose what integration you’d like to implement in your setup. It will save you time and frustration and you sponsor me a bit so that I can keep creating these tutorials for you. I cannot keep doing this without your help. Thanks!

Install Studio Code Server

To create a template in Home Assistant you need Studio Code Server. To install Studio Code Server, go to settings > Add-Ons and click on Add-On Store.

  • Search for Studio Code Server.
  • Click Install.
  • Turn on all the options if you want and click start.
  • Now click on Studio Code Server in the left menu bar.
  • You now see all the files on your Home Assistant server.

Create templates.yaml

  • If you do not have a templates.yaml file yet, then create one by clicking on the new file icon and add a file called templates.yaml.
  • Now click on the configurations.yaml file.
  • and add the following line: template: !include templates.yaml.
  • Now, save this file and restart Home Assistant first.
  • After Home Assistant is restarted, go back to Studio Code Server and open the templates.yaml file.

Create the template for the dynamic energy prices

  • Now add the following code to the templates.yaml file.
  • I will try to explain what I am doing in this code.
  • First I define a name and I give this sensor a unique id. You can do that by clicking on your right mouse button and selecting Generate UUID at cursor.
  • The icon is a euro sign in my case.
  • The state is the current price. I can retrieve that by using the states command followed by the entity-id of the Nordpool integration entity that we looked at in the developer tools before.

Add the times to the template sensor

  • Now we arrived at the most important part of this template. We are going to create two attributes in our Nordpool Energyprices sensor. One is times and the other one is prices.
  • What I am doing at times is retrieving the times of today and tomorrow and concatenating them in one list.
  • I start with creating a namespace which is a container that can hold values that are created in a for loop.
  • Then I am defining the starting point within the attribute of the nordpool entity. This attribute is called raw_today.
  • Within raw_today there’s a list of start times, end times, and values.
  • In the for loop, I am retrieving the times of that list and add those times to a times list in my namespace. I make sure that the time is in my local format, so that it will work later on when I create the bar chart.
  • After I processed all the times for today, I process the times for raw_tomorrow as well and add them to the same namespace.
  • So, in the end, the namespace is filled with all the available times for today and tomorrow, and the attribute which is called “times” is filled with this list.

Add the prices to the template sensor

  • We are going to do the same for the prices.
  • A lot of code is the same as the code that we used to create the times list. The only difference is that we are now filling the namespace with the price that we retrieve from the Nordpool entity and that we are adding the additional costs to the price too. The additional costs are stored in the helper that we’ve just created. You can retrieve that value by using this code.
  • Save the file.
  • Reload the templates.yaml by presssing ctrl-shift-P and search for template and clicking on Home Assistant: Reload Template Entities.
  • You can also do this by going to the Developer Tools, clicking on the YAML tab, and clicking on Template Entities.

Test the template sensor

Now let’s test the template code.

  • Go to Developer Tools.
  • Click the States Tab.
  • Search for Nordpool energy prices.
  • Click Nordpool energy prices.
  • You see that the state is the current price.
  • And we have one list for times and one list for prices as attributes.
  • You see that the times in the list are the times for today and tomorrow and that is exactly what I wanted to achieve here!
I need your help!

You will be doing me a huge favor if you subscribe to my channel if you haven’t already. And, you help me a lot if you also give this video a thumbs up and leave a comment. This way, YouTube will present this video to new people and that will make the channel grow! In the description of the video, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.

Thank you!

Creating the bar chart with dynamic energy prices

Now let’s create the bar chart on our dashboard. We are going to make use of the apexcharts integration from HACS for this.

Install Apexchart

  • Go to HACS.
  • Go to frontend.
  • Click Explore and download repositories.
  • Search for apexcharts.
  • Click apexchart-card.
  • Click Download.
  • Click Download again.
  • Click Reload.
  • Restart Home Assistant and clear your browser cache to make sure that you will see the new apexchart card in Home Assistant.

Add the bar chart with dynamic energy prices to a dashboard

Now create a new dashboard or open an existing dashboard. I will just open my tutorial dashboard here.

  • Click the three dots in the right upper corner.
  • Click Edit dashboard.
  • Click Add Card.
  • Search for apexchart. If the apexchart does not show up, please redownload the apexchart from HACS.
  • Click the Apexchart.
  • Replace the example code with this code.
  • The code points to our nordpool_energyprices entity.
  • The data-generator retrieves the data from the attribute times and the attribute prices and shows the bar chart for all the data that is available for the upcoming 36 hours. If you’d like to know what all the options are for the apexchart integration then read the apexchart manual for this.
  • Click Save

Add the additional costs helper field to the dashboard

Now let’s add the additional costs helper field to the dashboard.

  • Click Add Card.
  • Select the entities card.
  • Remove all the entities in the card.
  • Select the Nordpool addition costs entity.
  • Click Save.

If you enter an amount in the Additional costs field, you will see that this amount is being added to all the bars in the bar chart. This way you can tweak the chart so that it corresponds with the prices of your own energy provider.

Use the ENTSO-e integration to track dynamic energy prices

You created your own dynamic energy price barchart on your dashboard now. If your area is not available in the Nordpool integration, you can try to use the ENTSO-e integration instead. This integration supports more areas but is a little bit more tedious to set up. The ENTSO-e integration can be installed using HACS too. For that, go to HACS.

  • Go to integrations.
  • Click explore & Download Repositories.
  • Search for entso.
  • Click ENTSO-e Transparency platform.
  • Click Download.
  • Click Download Again.
  • Restart Home Assistant.
  • You need an API key for the ENSTO-e integration. To retrieve that key, go to the ENTSO-e transparency site at https://transparency.entsoe.eu/ and create an account over there.
  • Then, send an e-mail to transparency@entsoe.eu with “Restful API access” in the subject line and ask for an API key. Don’t forget to mention your e-mail address. If everything went well, you will get a reply after some time that will tell you that you are able to create a token that you can use in Home Assistant. Create the token on the ENTSO-e platform in your account settings and store that token on your clipboard.
  • Now go to Settings > Devices and Services.
  • Click Add integration.
  • Search for entso.
  • Enter a name and paste the token that you copied to your clipboard in the API KEY field.
  • Choose the area that you live in.
  • You can also set the VAT, template, and calculation method in the next step, but we are going to do that in our template just like how I did that in the Nordpool example.
Set up the template

From here, the procedure is the same as how I explained before for the Nordpool integration. I think you can do this yourself now based on the information in this tutorial. You can download the code for the ENTSO-e integration via the download link in the description below if you are having issues setting this up for the ENTSO-e integration. The code for the Zonneplan integration is also in that download file, so if you use Zonneplan, you can integrate Zonneplan using that code as well.

If you install Zonneplan, you have to enable the following entity to make this work: sensor.zonneplan_current_electricity_tariff

  • Go to Settings
  • Go to Devices and Services
  • Go to the entities tab
  • Search for Zonneplan
  • Click on Zonneplan current electricity tariff
  • Select Enable Entity


I hope I made it clear how you can create a dynamic energy prices bar chart in Home Assistant. I will create another tutorial in the near future that automatically determines what the cheapest hour is so that you can create automations that start appliances automatically at the cheapest hour.

These people made it possible for me to create this tutorial for you. I can’t do this without you supporting me. I depend entirely on people who sponsor me because they find these tutorials valuable. If you want to support me too, you can do so through Patreon, Ko-Fi, or by joining my channel. This helps me to pay for my groceries. The links are in the description below the video. And please do not forget to give this video a thumbs up, subscribe to my channel, and hit the notification bell.

I will see you soon.

Bye Bye.


Back to all articles