Hi,
Here I am again with a great tutorial that will allow you to display this overview of free Epic games in Home Assistant on your dashboard. Let’s do this!
โญโญโญ 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 want 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!
Ed
In version 2024.5, the Epic Games Store integration has been introduced. Using this integration, you can see which games you can download for free. Epic gives away free games every week and you can now keep an eye on that using Home Assistant. By default, the integration shows one game, but actually, there are always two games free to download. I’ll show you, how you can use a custom Jinja template to show both games on your dashboard. If you want to know more about how to program in YAML and Jinja, follow this YAML and JINJA course that I created specifically for that purpose. The link is in the description of this video.
Installing the Epic Games Store integration
First, we are going to install the Epic Games Store integration.
- Go to Settings > Devices and Services
- Click Add Integration
- Search for Epic
- Click Epic Games Store
- Select your Language and Country and click Submit.
The Epic Games Store Integration is now installed.
What does the Epic Game Store Integration do?
If you click on the integration, you will see that two calendar entities have been added to Home Assistant. The Epic Games Store Free games entity is turned on by default and can be viewed via the calendar link on the left. There you will now see a list of all current and future free games and when they are available. Thus, you can see that in my case, the game INDUSTRIA and LISA: The Definitive Edition are now available. But, if you look at the status of the Epic Games Store Free games entity, you will see that only one game is shown, namely INDUSTRIA. However, if I go to the services tab and then call the service calendar.get_events and in doing so, want to show the events that are available today, I see that two games are available for free download.
As you can see, two events are shown, each with its own start and end time. And, a summary and description which even contains a link to the respective game.
Now to make both of these visible, we are going to build our custom template that we can then use on our dashboard.
How to create your own template.
To create your own templates, you can use the add-on Studio Code Server or File Editor.
- To install Studio Code Server, go to Settings -> Add-ons.
- Click Add-on store and search for Studio Code Server.
- Click Studio Code Server and Click Install.
- Click Show in Sidebar and Click Start.
- Now go to Studio Code Server.
You now see an overview of all the files on your Home Assistant Server.
- Open the config folder and then open the configuration.yaml file.
- Check that this line is in it:
template: !include templates.yaml
If this line is not in there, add it.
- Then create the templates.yaml file if it does not already exist.
- Restart Home Assistant if you had to perform these last actions. If the templates.yaml file and its reference was already in your configuration.yaml, you do not need to restart Home Assistant.
- Now go back to Studio Code Server and open the templates.yaml file.
- We are now going to add this code and I am now going to explain to you exactly what this code does.
If you don’t want to type this code from the screen, you can also download this code from the link in the description of this video for a small fee. This will save you a lot of work and frustration and in the process you will be sponsoring me and ensuring that I can continue to make these tutorials for you.
What exactly does the template do?
- First, we start by creating a trigger. This is called once every hour.
- The action of this trigger calls the calendar.get_events service and retrieves the events of the epic_games_store_free-games calendar for the next 24 hours.
- The values retrieved are stored in the variable my_games.
- Then we are going to create the sensor next.
- The sensor is given a name with which we can later find it in Home Assistant.
- In addition, we give the sensor a unique_id, so that later we can adjust some properties of this sensor via the UI of Home Assistant. This unique_id can be any value you like, but in Studio Code Server you can also generate it by right-clicking with your mouse.
- As an icon, I have chosen a controller icon.
- Then we define the state. I make it the same as the state of the entity calendar.epic_games_store_free_games.
- And then I create four attributes for this sensor.
- We start with the game name for game 1. If you look back at the service call I did in the developer tools, you can see that there are two events available. these values are now stored in the variable my_games that I defined in the trigger above.
- So to retrieve the title of the first game, I need to look at the first event within calendar.epic_games_store_free_games. And within that event, I want to retrieve the value belonging to “summary”. You note that as follows:
{{ my_games['calendar.epic_games_store_free_games'].events[0].summary }}
- As you can see, I retrieved events zero here. Zero means the first event in this case.
- For the description of the first game, you basically do the same thing, but retrieve the value of the description.
{{ my_games['calendar.epic_games_store_free_games'].events[0].description }}
- Then repeat this process for the second game.
- In this case, I point to events one, which is the second event.
- Then save the file.
- Now we are going to reload the template into Home Assistant.
- Go to the Developer Tools and click on the YAML tab.
- Scroll down and click on the template entities link.
- If everything went well, now we can start testing the templates.
- Go to the States tab and search for Epic.
- If you copied the code correctly, you will see your new sensor sensor.epic_store_free_games now listed. Click on this sensor and you’ll see that the sensor has four attributes, namely gamename_one, gamedescription_one, gamename_two, and gamedescription_two. And these attributes are now all filled with the game information.
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 will 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, making the channel grow! In the video description, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.
Thank you!
Adding the list of games to your dashboard.
The final step is that we will now add the list of free games to a dashboard.
- Go to any dashboard and click on Add card.
- Search for the Markdown card and click on it to add it.
- Now remove all the text that is already in it by default.
- Now create the title first. In my case, it is EPIC STORE FREE GAMES.
- Now in the content field, we are going to add the attribute values of our sensor.
- First, I want to create a subtitle for the first free game. I want to display that in bold, so I put two asterisk characters around it.
- Then I want to display the name of the game in italics, so I start with an asterisk and then I add this code:
{{ state_attr('sensor.epic_store_free_games','gamename_one')}}
- Here I retrieve the attribute value of gamename_one from our self-made sensor.
- Again I end with an asterisk and you can see that the game name is now displayed in italics.
- Now I’m going to display the description. I do that with almost the same code, only now I use the attribute value gamedescription_one.
- You can see that the description is now also displayed.
- And then I copy this whole piece of code and paste it below. Then I replace one with two and you can see that the second game is now also displayed.
- Click Save.
- Click Done.
Fantastic! The free Epic games are now displayed on your dashboard so you are always aware of free downloadable games!
Thanks for watching and if my videos save you time and frustration, please consider sponsoring me monthly with a small amount so I can continue to do this work. Making these tutorials is my daily work and unfortunately, the income from YouTube is too little to live on. That’s why I need your help, just as I get help from these amazing people who sponsor me monthly. Thank you so much! You’ll find links to Patreon, Ko-Fi, and how to join my channel in the description of this video.
And, don’t forget to give this video a thumbs up and subscribe to my channel if you haven’t already. I also really like it if you leave a comment below this video. Thanks again and I’ll see you soon in my next video!
Bye Bye.