Yaml and Jinja Course Episode 7: Creating your own sensors

preview_player
Показать описание
Here's episode seven of this YAML and Jinja programming course! In this episode of our Jinja and YAML course, I explain how you can create your own template sensors in Home Assistant!

Links referred to in this video:

⭐⭐⭐
⭐⭐⭐

00:00:00 Introduction
00:01:18 How do you create your own sensor in Home Assistant?
00:01:23 Deploying a Template Helper
00:03:27 Creating advanced templates
00:03:44 Install Studio Code Server or File Editor
00:06:04 Adding your first sensor
00:07:56 What lights are exactly on?
00:09:07 What lights are on in a specific room?
00:10:02 Show the values of a custom template sensor on a dashboard
00:11:53 Outtakes

homeassistant #jinja #yaml #templates #templating #programming #sensors
Рекомендации по теме
Комментарии
Автор

Let me know what custom templates you created in the comments!

SmartHomeJunkie
Автор

Another great tutorial. Thanks for producing this whole series! I use to fear yaml and templates, but no longer. Can't do without them now.

major_west
Автор

Nice room filter; I'll begin incorporating them into my code. :)
Thanks, Ed.

sevagjb
Автор

Again I am enjoying this series - thanks so much for sharing. While fiddling around I actually found I was defining my Templates in the Binary-sensor file .. DOH. Hopefully to help others I also added " | rejectattr('entity_id', 'search', 'bulb|robby|led') " This helps me to remove any sensor LED's etc from my list easily. I also have a naming convention that any light inside a group is called a 'Bulb', this quickly removes them without having to go arround and set specific labels.

clairerovic
Автор

Thanks again! With this and episode 6, I replaced my Total Power summation sensor which was about 30 lines of code with a very clean single line of code. Now I have a single sensor that adds all my power loads together, and all I need to do to add a new one is to add the label to it. I modified the code with the map('float') and sum functions. I use this sensor to display the total instantaneous power draw in my house on my dashboard.

{{ states.sensor | selectattr('entity_id', 'in', label_entities('Power Load'))
| map(attribute='state')
| map('float')
| list | sum }}

desertaip
Автор

When you make a sensor, HA will store that value inn its database. It will take more space and if you are running Raspberry PI with SD card, it will wear out faster. If you only need to display a number, but not store it, you can make lots of calculation directly in the display card it self. (Do you really need to go back one month and see how many lights that are on? I know this is just an example, but this is how you should think)

lakromani
Автор

Thank you. Your tutorials are outstanding!

johnwietz
Автор

Thanks Ed. Another awesome video in the series. Cant wait to see what you will share next

emms-place
Автор

Really useful tutorial. Thank you very much 👍

richardfuller
Автор

Hi,

Initially I followed your videos to recreate the sprinkler watering system in order to learn as much as I can. I ran into issues with a couple of things.
I have since resolved the issues but the major issue has been the sensors not updating . As I had created the sensors myself after purchasing the latest code from you the sensors ended up with a modified name suffixed with a l_2”. In order to resolve is there a way to remove the original sensors that I had created from cache

maricelchristarr
Автор

Your content is great! Would like to know how to create a time sensor and should be able to use it for automatons

Thank you

powertbs