Templates and Custom Sensors are a more advanced feature in Home Assistant. With Templates and Custom Sensors you can format and convert data so that it looks exactly the way how you want it to look. These are really powerful in Home Assistant and will help you in tailoring Home Assistant to your specific needs. In this video, I will explain how to create Templates and Custom Sensors in Home Assistant so that you can set this up yourself!
โญโญโญ 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
You can watch the video tutorial here
Setting up Templates and Custom Sensors
The video tutorial explains in detail how Templates and Custom Sensors work in Home Assistant.
In the video we are going to build these use cases:
- Create a customized motion sensor message
- Show a different icon based on the motion sensor state
- Show a different icon color based on the motion sensor state
- Create a custom light counter sensor
- Create customized light counter message
- Show a different icon based on the light counter state
- Show a different icon color based on the light counter state
- Create a customized battery status indicator
- Show a different icon based on the battery state
- Show a different icon color based on the battery state
The final result will be something like this:
You can find all the code used in the video here.
Disclaimer:
This video uses the “old” method of setting up template sensors. This is still supported by Home Assistant and works perfectly fine. The video gives you a good insight into how template sensors work. The modern way of setting up template sensors follows the same approach, but in that case, the sensors are stored in templates.yaml. You can watch this video to see how you can apply this.
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!