Excellent Tutorial. I'm an experienced coder but a noob to Home Assistant so I needed some help to get over the first hurdles in a new interface and language. This was exactly what I needed. I'll be watching your whole series when I have time. Thanks.
Thank you for making this video. I'm a programmer by day, but a lot of the explanations around custom sensors seemed as clear as mud until I found your video. This breaks it down and explains it very clearly. You have saved me a lot of future headache, thank you so much for the simple and concise explanation!
Sir, you have opened my mind to new ideas! I've seen the dryer power monitor before and it's on my list of to-dos, but you have me thinking about it differently. Thank you! I feel better prepared to get started.
1000 times Thank you!! Being new to this is overwhelming but you helped greatly!! I made a simple little sensor to show whether I'm home or not... it's a start to bigger and better things :)
@@SmartHomeMakers Not sure how to or if I even can format code here but here it is.... VERY simple LOL I made that sensor that's called john_presence and put it in my sensor dir [which is included in my config.yaml] - platform: template sensors: john_presence: friendly_name: John presence value_template: >- {% if is_state('device_tracker.sm_f926u1', 'not_home') %} John's Out {% else %} John's In {% endif %}
@@SmartHomeMakers did not know that!!! Thank you!! I will try that too. What I was really trying to do was show a picture and have it change when I wasn't home.....but that's been a bit over my head :)
Thanks for the tutorial, really nicely explained. I wish there was entities ID autocomplete in this editor, just like in VS Code. Would make playing around it so much easier.
Thanks for the video. I got it to work with a Sonoff S31PM by using {% if state_attr('switch.sonoff_s31pm', 'power') == 0 %} in place of what you were using.
Very clear and much obliged. Only struggle here is to make the outcome of the if/else a trigger for an automation. I.e. if status dryer changes from standby to drying: send me a message or whatever action needed.
Excellent! I had no idea what templating was! I actually had made one months ago I think, made a switch and a contact sensor into a cover(garage door). But you explanation of those crazy brackets was super helpful, last time I did any programming was in the early 80’s and it was the Basic language, so I’m pretty much less than zero on programming knowledge. Thanks a bunch!
Enjoying your video's! Very helpful! HOWEVER, I missed the part where the "sensor.tumble_dryer_power" entity came from. Did you define it as part of the Shelly1PM? I'm currently only using esp's.
Thanks for all the work and time you have given us. I was not able to use the term state. When I went looking on other sites I found a different way of creating sensor as follows - platform: template sensors: quickpot: friendly_name: 'fastcook' value_template: > {% if states("sensor.dishwasher_energy_current") | float == 0 %} OFF {% elif states("sensor.dishwasher_energy_current") | float
You have just solved me another problem …. just one question left: how do you describe a value between two values let’s say „if sensor value is>= 40 but
Setting up an automation for our dryer is the one thing I've been unable to do so far. I live in the U.S. and we have the funky plugs for our dryers, so using a normal power monitor smart plug won't work. I've heard of Shelly before, do you have a link to the one you used? I know Shelly offers some products here in the US, so hopefully I can get one that will work.
Thanks Gio, a great video on templates! Much needed as I expand my use cases in HAS. By chance do you have a video that returns a specific entity that triggered an automation? For example I have 5 smoke sensors and I want my notification to return the specific sensor that triggered the automation. Thank you!
Hi Oystein! Yes you could, want would you use it for? Like an automation to turn off the device once it reached a certain power level? Not sure how practical on a family basis that could be :)
@@SmartHomeMakers Nice. I simply want to see daily consumption of my smart plugs etc. As they are out of the box, they only show current consumption and total consumption as far as I can tell. Even in the energy dashboard. Sure, the individually monitored nodes show the daily consumption, but not when I click on one of them; then they show just the total consumption. Which in reality tells nothing at all
Hello and congratulations for the home assistant videos, I need help on the dryer status template. How can I insert a delay that if it is under 6 w for 10 seconds is it stanbay?
@@SmartHomeMakers Hello,no in this sensor, put a 10 second delay before the dryer gives me standby - sensor: - name: stati asciugatrice state: > {% if states("sensor.tz3000_gjnozsaz_ts011f_active_power")|float == 0 %} off {% elif states("sensor.tz3000_gjnozsaz_ts011f_active_power")|float
Thank you for this, I have searched for any syntax documentation for creating templates and have had to rely on looking at other users code for clues, can you point at such documentation? For example I first thought to use a case statement rather than if but can’t find if one is available for use! I also found that I could just update templates rather than restarting HA, saved a ton of time with my many errors and restarts. Thanks for what you are doing to help us all!
I find the same, it's hard to figure out the prefix etc. It would be nice if there was a homeassistant examples cheat sheet trying to relate to the jinja documents is hard
@@SmartHomeMakers But I have one question left … what is the command if you want a range for the sensor …. ie between 40 and 50 … In you’re sample, you just covered 1 value i.e. one value …. how about between 2 values ?
thanks for the tutorial! i'm getting this error, any idea what is going wrong here? 'float' got invalid input 'unknown' when rendering template '{% if states("sensor.dryer_power")|float == 0 %} Off {% elif states("sensor.dryer_power")|float
I am trying to evaluate the last notification on my phone whether it contains a list of words and if NOT contain any of the specified words then it should update the sensor. What is the best way to write this code?
You create the code in templates but then you don't use that when you're typing the code into the config yaml so I am confused. I have got my code in the template but what do i do with that? I cannot see why you do that first as you just create some different code in the config yaml
I followed this video to a T. My template works within the generator but every line of code throws back an error. As soon as i write the word template: i cant seem to correct it at all.
@@SmartHomeMakers Thanks for the reply. I honestly cant remember the exact circumstances on what I was trying to do. This was when I was first learning Home Assistant. I was trying to do something but was getting an error since there was no unique ID. I obviously found a workaround and most likely a better way than I was thinking. I just cant remember what...
Thanks for the great video! I'm using Developer Tools, Template But, I'm stuck here is my code: ``` (% if states("number.humidifier_target_level") == 55 %) off (% else %) on (% endif %) ``` I am getting this error: This template does not listen for any events and will not update automatically. I have checked the States and it shows 55. Any help would be greatly appreciated! TIA
@@SmartHomeMakers Got this error; The following integrations and platforms could not be set up: template Please check your config and logs. Logger: homeassistant.config Source: config.py:464 First occurred: 1:27:53 PM (1 occurrences) Last logged: 1:27:53 PM Invalid config for [template]: expected dictionary for dictionary value @ data['sensors']. Got [OrderedDict([('name', 'Washing Machine'), ('state', '{% if states("sensor.washer_power")|float
@@SmartHomeMakers Yea, left aligned with no spaces. "Check Config" says valid and restart happens without issues. But just dont see the new sensor. Thanks.
HEy whenever i do the check i get a config invalid for Integration error: name - Integration 'name' not found. Integration error: platform - Integration 'platform' not found. Integration error: host - Integration 'host' not found. i have no errors on my code and it is exactly the same as yours other than the name ( i am running mine for the washer right now)
@@SmartHomeMakers Sadly had to rebuild my whole home assistant install (backups wouldn't restore for some reason_ so just had to do it all again....... but this time went way faster lol
Man, i use HA since 2018 and some of my automation using template by copy cat, i just understand the logic of the code with this tutorial. How poor my knowledge. Thanks so much
Thank you so much. Just two weeks into Home Assistant and struggling with 'custom sensors.' This was the perfect introduction!
Glad it helped Tym!
Thank you so much for making this tutorial. So far the most straight forward and clean way of doing it.
Amazing appreciate it!
Excellent Tutorial. I'm an experienced coder but a noob to Home Assistant so I needed some help to get over the first hurdles in a new interface and language. This was exactly what I needed. I'll be watching your whole series when I have time. Thanks.
Thanks Damien! In which languages do you code in?
Thank you for making this video. I'm a programmer by day, but a lot of the explanations around custom sensors seemed as clear as mud until I found your video. This breaks it down and explains it very clearly. You have saved me a lot of future headache, thank you so much for the simple and concise explanation!
Thanks Thad ! Appreciate you watching the video :)
@@SmartHomeMakers thanks for making them
Sir, you have opened my mind to new ideas! I've seen the dryer power monitor before and it's on my list of to-dos, but you have me thinking about it differently. Thank you! I feel better prepared to get started.
Robert, my pleasure! Have a happy new year !
+1 for the tutorial. I have no experience with ginja so this is great
Glad it was helpful!
1000 times Thank you!! Being new to this is overwhelming but you helped greatly!! I made a simple little sensor to show whether I'm home or not... it's a start to bigger and better things :)
Hi John! Please share your code with us :)
@@SmartHomeMakers Not sure how to or if I even can format code here but here it is.... VERY simple LOL I made that sensor that's called john_presence and put it in my sensor dir [which is included in my config.yaml]
- platform: template
sensors:
john_presence:
friendly_name: John presence
value_template: >-
{% if is_state('device_tracker.sm_f926u1', 'not_home') %}
John's Out {% else %}
John's In {% endif %}
@@TheCowboysdude you can also achieve this without templating by linking your device tracker to a person in HA! Regardless good work!
@@SmartHomeMakers did not know that!!! Thank you!! I will try that too. What I was really trying to do was show a picture and have it change when I wasn't home.....but that's been a bit over my head :)
Thank you so much! Great for presenting custom ESPHome devices better!
Thanks!!
This video will help me a lot with templating. Always had struggles with it, but now it is more clear for me. Many thanks 🙂
Thanks Robin! Glad you enjoyed it!
Thanks for the tutorial, really nicely explained.
I wish there was entities ID autocomplete in this editor, just like in VS Code.
Would make playing around it so much easier.
Kuba, you are right it would be a nice addition!
Well done. That's clarified a whole bunch of things. Thank you.
Thanks Ash! Which video would you like to see next?
@@SmartHomeMakers More on templating would be good
Brilliant, so simple to follow. Thank you!
Thanks Stuart!
Thanks for the video. I got it to work with a Sonoff S31PM by using {% if state_attr('switch.sonoff_s31pm', 'power') == 0 %} in place of what you were using.
Is that because the sonoff switch has power as an attribute of the device and not its own entity
@@SmartHomeMakers Yes, it is an attribute not its own entity. I'm using the HACS integration to get it to work in Home Assistant.
Excellent video. Clear and precise presentation!
Glad you enjoyed it!
Are you kidding? My wife would love a tumble dryer as a present. Definitely do that.
Why not:)
You must be the guy that bought yourself a new iPhone, gave your son an iPad, your daughter an iPod and your wife an iRon! lol
This is what I was looking for. Thank you so much.
Thanks David for watching!
Once again, thanks for a very helpful video. Your content selection and quality is constantly growing and I enjoy your channel 👍
Thanks Jaco!!
wooooww just what I was searching. thank you very much!!!
Thanks Jorge!!
Very clear and much obliged. Only struggle here is to make the outcome of the if/else a trigger for an automation. I.e. if status dryer changes from standby to drying: send me a message or whatever action needed.
Hi Celine, you can use the from to in a trigger to look at the status!
Excellent! I had no idea what templating was! I actually had made one months ago I think, made a switch and a contact sensor into a cover(garage door). But you explanation of those crazy brackets was super helpful, last time I did any programming was in the early 80’s and it was the Basic language, so I’m pretty much less than zero on programming knowledge. Thanks a bunch!
The basics of coding might not have changed much :) are you learning any new language now ?
@@SmartHomeMakers no I’m not, except the Home Assistant and Tasmota stuff.
Enjoying your video's! Very helpful! HOWEVER, I missed the part where the "sensor.tumble_dryer_power" entity came from. Did you define it as part of the Shelly1PM? I'm currently only using esp's.
plenty of examples presented in a simple way 😁👍
Glad to hear that!
Just made a free templating course here on YT!
Nice bite size & useful intro to templates.
Thanks Etienne!
Very well explained and very useful tip 👍🏼👍🏼thanks
Thanks GioBen! Much appreciated your comment !
Thanks for all the work and time you have given us. I was not able to use the term state. When I went looking on other sites I found a different way of creating sensor as follows
- platform: template
sensors:
quickpot:
friendly_name: 'fastcook'
value_template: >
{% if states("sensor.dishwasher_energy_current") | float == 0 %}
OFF
{% elif states("sensor.dishwasher_energy_current") | float
You have just solved me another problem …. just one question left: how do you describe a value between two values let’s say „if sensor value is>= 40 but
Hi NR I forgot if I answered this question already ?
Setting up an automation for our dryer is the one thing I've been unable to do so far. I live in the U.S. and we have the funky plugs for our dryers, so using a normal power monitor smart plug won't work. I've heard of Shelly before, do you have a link to the one you used? I know Shelly offers some products here in the US, so hopefully I can get one that will work.
Very nice explanation.
Thanks Jose!
Thanks Gio, a great video on templates! Much needed as I expand my use cases in HAS. By chance do you have a video that returns a specific entity that triggered an automation? For example I have 5 smoke sensors and I want my notification to return the specific sensor that triggered the automation. Thank you!
Thanks Louis, let me know what you think about my other templating videos
This is a very useful video... great job
Thanks Robert appreciate the constant support !
Great video. Thank you
Thanks Geoff!
Nice! Thanks.
Thanks Ron, I hope you have a great 2022
@@SmartHomeMakers Thank you and Happy New Year!
Love your coding videos. Keep up the good work. Could you maybe do a sensor for daily power consumption?
Hi Oystein! Yes you could, want would you use it for? Like an automation to turn off the device once it reached a certain power level? Not sure how practical on a family basis that could be :)
@@SmartHomeMakers Nice. I simply want to see daily consumption of my smart plugs etc. As they are out of the box, they only show current consumption and total consumption as far as I can tell. Even in the energy dashboard. Sure, the individually monitored nodes show the daily consumption, but not when I click on one of them; then they show just the total consumption. Which in reality tells nothing at all
Great video
Hi Parzival! Glad you enjoyed it
the sensor name will convert to xxxx_xxxx from name in template automatically right ?
Hello and congratulations for the home assistant videos, I need help on the dryer status template. How can I insert a delay that if it is under 6 w for 10 seconds is it stanbay?
Would that be a condition in an automation?
@@SmartHomeMakers Hello,no in this sensor, put a 10 second delay before the dryer gives me standby
- sensor:
- name: stati asciugatrice
state: >
{% if states("sensor.tz3000_gjnozsaz_ts011f_active_power")|float == 0 %}
off
{% elif states("sensor.tz3000_gjnozsaz_ts011f_active_power")|float
Thank you for this, I have searched for any syntax documentation for creating templates and have had to rely on looking at other users code for clues, can you point at such documentation? For example I first thought to use a case statement rather than if but can’t find if one is available for use!
I also found that I could just update templates rather than restarting HA, saved a ton of time with my many errors and restarts.
Thanks for what you are doing to help us all!
Hi Rick! There is a jinja2 templating documentation from the developer tool haven’t got a link on me :)
@@SmartHomeMakers Maybe my biggest issue is that I never know if I am coding Yaml, Python or Jinja. None of which I have used before. Thanks!
@@rickz6006 python is the programming language that HA is built upon, yaml mainly is seen as a configuration language as is jinja
I find the same, it's hard to figure out the prefix etc. It would be nice if there was a homeassistant examples cheat sheet trying to relate to the jinja documents is hard
Danke!
Welcome!
@@SmartHomeMakers
But I have one question left … what is the command if you want a range for the sensor …. ie between 40 and 50 …
In you’re sample, you just covered 1 value i.e. one value …. how about between 2 values ?
@@n.r.2258 have you tried >= 40 and
@@SmartHomeMakers
{% if states ('sensor.wasser_sensor') | float >= 40 and
you need to repeat the states portion again states ('sensor.wasser_sensor') | float
I get a strange error on startup saying -sensor is an invalid option for -template
Thanks for the information.. I like the sound of the keyboard.. Can you tell me what kind it is?
Hi Akram, just an apple keyboard!
thanks for the tutorial! i'm getting this error, any idea what is going wrong here?
'float' got invalid input 'unknown' when rendering template '{% if states("sensor.dryer_power")|float == 0 %} Off {% elif states("sensor.dryer_power")|float
I am trying to evaluate the last notification on my phone whether it contains a list of words and if NOT contain any of the specified words then it should update the sensor. What is the best way to write this code?
Hi Alex, nice use case, not sure home assistant is your answer for this!
11:41 Line 391 'Template' disappears ? I followed the instructions and no errors but my sensor does not appear afterward.
Hello! did you check the logs?
How do we know when drying finishes to get notifications?
When the power consumption drops to nearly 0 for a certain amount of time, depending on your model!
Can home assistant be used to send IR or RS232 command to control tv, audio receivers etc…?
With something like a broad link you can!
@@SmartHomeMakers can you make a video on it!
Studio Code editor throws immediate error
template:
- sensor: incorrect type expected array
state:
Any ideas? thx
You create the code in templates but then you don't use that when you're typing the code into the config yaml so I am confused. I have got my code in the template but what do i do with that? I cannot see why you do that first as you just create some different code in the config yaml
Do you mean in the developer tools?
I followed this video to a T. My template works within the generator but every line of code throws back an error. As soon as i write the word template: i cant seem to correct it at all.
Can you share your code Bobby?
Can you assign a unique id to the template sensor?
What are you trying to achieve Damuson?
@@SmartHomeMakers Thanks for the reply. I honestly cant remember the exact circumstances on what I was trying to do. This was when I was first learning Home Assistant. I was trying to do something but was getting an error since there was no unique ID. I obviously found a workaround and most likely a better way than I was thinking. I just cant remember what...
Thanks for the great video!
I'm using Developer Tools, Template
But, I'm stuck here is my code:
```
(% if states("number.humidifier_target_level") == 55 %)
off
(% else %)
on
(% endif %)
```
I am getting this error:
This template does not listen for any events and will not update automatically.
I have checked the States and it shows 55.
Any help would be greatly appreciated!
TIA
Can you try to use states("number.humidifier_target_level") ? What do you get?
@@SmartHomeMakers Thanks, that is the same as I'm using. Same error.
Thanks for the video. I followed everything you did but after restarting I do not get a new sensor.tumble_dryer. Any idea why?
Hi Chris, did you get any error messages? Do you want to share your YAML?
@@SmartHomeMakers Got this error;
The following integrations and platforms could not be set up:
template
Please check your config and logs.
Logger: homeassistant.config
Source: config.py:464
First occurred: 1:27:53 PM (1 occurrences)
Last logged: 1:27:53 PM
Invalid config for [template]: expected dictionary for dictionary value @ data['sensors']. Got [OrderedDict([('name', 'Washing Machine'), ('state', '{% if states("sensor.washer_power")|float
@@cchris3 can’t spot anything wrong! Is template aligned to the left no spaces ?
@@SmartHomeMakers Yea, left aligned with no spaces. "Check Config" says valid and restart happens without issues. But just dont see the new sensor. Thanks.
Can this be used to make a virtual motion or contact sensor in HA?
Hi Ryan, what is your use case for a virtual motion sensor?
Hi, Thanks for replying. I’m trying to find away to trigger an Alexa routine with ahome assistant automation.
@@ryantrainor2 I think you will find this article a great read: robpickering.com/integrate-iotty-wall-switches-with-home-assistant/
Thank you I’ll check it out much appreciated!
@@ryantrainor2 Have a great day/evening!
it will work with sonoff ewelink?
Have you got it integrated in HA?
HEy whenever i do the check i get a config invalid for
Integration error: name - Integration 'name' not found.
Integration error: platform - Integration 'platform' not found.
Integration error: host - Integration 'host' not found.
i have no errors on my code and it is exactly the same as yours other than the name ( i am running mine for the washer right now)
and if i remove what i just added it says the config is fine so its something in this it doesn't like. I'm out of ideas of what could be wrong lol
figured it out by adding it it made another part in my yaml freak out
Hi Patrick! I’m glad you figured it out how did you do it ?
@@SmartHomeMakers Sadly had to rebuild my whole home assistant install (backups wouldn't restore for some reason_ so just had to do it all again.......
but this time went way faster lol
@@SmartHomeMakers
#washer#
template:
- sensor:
- name: Washer Status
state: >
{% if states("sensor.washer_energy_power")| float == 0 %}
Idle
{% elif states("sensor.washer_energy_power")| float
{% if states("sensor.dryer_energy_power")| float == 0 %}
Idle
{% elif states("sensor.dryer_energy_power")| float
Man, i use HA since 2018 and some of my automation using template by copy cat, i just understand the logic of the code with this tutorial. How poor my knowledge. Thanks so much
Thanks for the video. BTW you have a spelling mistake in your splash screen. Cobing instead of Coding :D
Thanks Brent!
Imej itu terlalu menyinggung perasaan