Тёмный

Create your OWN Template Sensor with Home Assistant Coding Tutorial 

Smart Home Makers
Подписаться 27 тыс.
Просмотров 57 тыс.
50% 1

Наука

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 140   
@tympeters7071
@tympeters7071 2 года назад
Thank you so much. Just two weeks into Home Assistant and struggling with 'custom sensors.' This was the perfect introduction!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Glad it helped Tym!
@procast
@procast 11 месяцев назад
Thank you so much for making this tutorial. So far the most straight forward and clean way of doing it.
@SmartHomeMakers
@SmartHomeMakers 9 месяцев назад
Amazing appreciate it!
@OPB682
@OPB682 2 года назад
+1 for the tutorial. I have no experience with ginja so this is great
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Glad it was helpful!
@ArranAsh
@ArranAsh Год назад
Thank you so much! Great for presenting custom ESPHome devices better!
@SmartHomeMakers
@SmartHomeMakers Год назад
Thanks!!
@MrRowbeartoes
@MrRowbeartoes 2 года назад
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.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Robert, my pleasure! Have a happy new year !
@RobinDeBecker
@RobinDeBecker 2 года назад
This video will help me a lot with templating. Always had struggles with it, but now it is more clear for me. Many thanks 🙂
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Robin! Glad you enjoyed it!
@Damien_D
@Damien_D Год назад
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.
@SmartHomeMakers
@SmartHomeMakers Год назад
Thanks Damien! In which languages do you code in?
@mindracing
@mindracing 2 года назад
Well done. That's clarified a whole bunch of things. Thank you.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Ash! Which video would you like to see next?
@mindracing
@mindracing 2 года назад
@@SmartHomeMakers More on templating would be good
@thad3229
@thad3229 2 года назад
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!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Thad ! Appreciate you watching the video :)
@thad3229
@thad3229 2 года назад
@@SmartHomeMakers thanks for making them
@stuartclark4045
@stuartclark4045 6 месяцев назад
Brilliant, so simple to follow. Thank you!
@SmartHomeMakers
@SmartHomeMakers 5 месяцев назад
Thanks Stuart!
@TheCowboysdude
@TheCowboysdude 2 года назад
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
@SmartHomeMakers 2 года назад
Hi John! Please share your code with us :)
@TheCowboysdude
@TheCowboysdude 2 года назад
@@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
@SmartHomeMakers 2 года назад
@@TheCowboysdude you can also achieve this without templating by linking your device tracker to a person in HA! Regardless good work!
@TheCowboysdude
@TheCowboysdude 2 года назад
@@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 :)
@coobek2k
@coobek2k 2 года назад
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.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Kuba, you are right it would be a nice addition!
@BerntHansson
@BerntHansson 10 месяцев назад
Excellent video. Clear and precise presentation!
@SmartHomeMakers
@SmartHomeMakers 10 месяцев назад
Glad you enjoyed it!
@Mrdsmith500
@Mrdsmith500 Год назад
This is what I was looking for. Thank you so much.
@SmartHomeMakers
@SmartHomeMakers Год назад
Thanks David for watching!
@vegaswayne247
@vegaswayne247 2 года назад
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.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Is that because the sonoff switch has power as an attribute of the device and not its own entity
@vegaswayne247
@vegaswayne247 2 года назад
@@SmartHomeMakers Yes, it is an attribute not its own entity. I'm using the HACS integration to get it to work in Home Assistant.
2 года назад
wooooww just what I was searching. thank you very much!!!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Jorge!!
@javandermerwe
@javandermerwe 2 года назад
Once again, thanks for a very helpful video. Your content selection and quality is constantly growing and I enjoy your channel 👍
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Jaco!!
@altussss
@altussss 2 года назад
plenty of examples presented in a simple way 😁👍
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Glad to hear that!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Just made a free templating course here on YT!
@mosth8ed
@mosth8ed 2 года назад
Are you kidding? My wife would love a tumble dryer as a present. Definitely do that.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Why not:)
@TheUnofficialMaker
@TheUnofficialMaker 2 года назад
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
@waynenocton
@waynenocton 2 года назад
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!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
The basics of coding might not have changed much :) are you learning any new language now ?
@waynenocton
@waynenocton 2 года назад
@@SmartHomeMakers no I’m not, except the Home Assistant and Tasmota stuff.
@etiennedeklerk
@etiennedeklerk 2 года назад
Nice bite size & useful intro to templates.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Etienne!
@GioBen68
@GioBen68 2 года назад
Very well explained and very useful tip 👍🏼👍🏼thanks
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks GioBen! Much appreciated your comment !
@celinevermolen1618
@celinevermolen1618 2 года назад
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.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Celine, you can use the from to in a trigger to look at the status!
@JoseBerruezo
@JoseBerruezo 2 года назад
Very nice explanation.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Jose!
@lcarter194
@lcarter194 Год назад
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
@bgable7707
@bgable7707 Год назад
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.
@n.r.2258
@n.r.2258 2 года назад
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
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi NR I forgot if I answered this question already ?
@robertaccess
@robertaccess 2 года назад
This is a very useful video... great job
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Robert appreciate the constant support !
@xXDeadJesterXx
@xXDeadJesterXx Год назад
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.
@WoottonRivers
@WoottonRivers 2 года назад
Great video. Thank you
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Geoff!
@louisviciedo
@louisviciedo Год назад
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!
@SmartHomeMakers
@SmartHomeMakers Год назад
Thanks Louis, let me know what you think about my other templating videos
@Gladers.
@Gladers. 2 года назад
Could you make a video where you make a value depending on the states of 2 diffrent sensors?
@Shaq2k
@Shaq2k 2 года назад
Love your coding videos. Keep up the good work. Could you maybe do a sensor for daily power consumption?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
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 :)
@Shaq2k
@Shaq2k 2 года назад
@@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
@user-mfsc-2024
@user-mfsc-2024 Год назад
the sensor name will convert to xxxx_xxxx from name in template automatically right ?
@akram1402
@akram1402 2 года назад
Thanks for the information.. I like the sound of the keyboard.. Can you tell me what kind it is?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Akram, just an apple keyboard!
@ARGONAUTA34
@ARGONAUTA34 Год назад
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
@SmartHomeMakers Год назад
Would that be a condition in an automation?
@ARGONAUTA34
@ARGONAUTA34 Год назад
@@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
@ronm6585
@ronm6585 2 года назад
Nice! Thanks.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Ron, I hope you have a great 2022
@ronm6585
@ronm6585 2 года назад
@@SmartHomeMakers Thank you and Happy New Year!
@kodeypatterson8973
@kodeypatterson8973 2 года назад
Great video
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Parzival! Glad you enjoyed it
@CalMUK91
@CalMUK91 8 месяцев назад
I get a strange error on startup saying -sensor is an invalid option for -template
@rickz6006
@rickz6006 2 года назад
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!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Rick! There is a jinja2 templating documentation from the developer tool haven’t got a link on me :)
@rickz6006
@rickz6006 2 года назад
@@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!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
@@rickz6006 python is the programming language that HA is built upon, yaml mainly is seen as a configuration language as is jinja
@simonburke6681
@simonburke6681 2 года назад
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
@singaporepastor
@singaporepastor 2 года назад
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
@Paata02
@Paata02 2 года назад
How do we know when drying finishes to get notifications?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
When the power consumption drops to nearly 0 for a certain amount of time, depending on your model!
@alexcapone3284
@alexcapone3284 2 года назад
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?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Alex, nice use case, not sure home assistant is your answer for this!
@highland-oldgit
@highland-oldgit Год назад
11:41 Line 391 'Template' disappears ? I followed the instructions and no errors but my sensor does not appear afterward.
@SmartHomeMakers
@SmartHomeMakers Год назад
Hello! did you check the logs?
@rudyhenderson5002
@rudyhenderson5002 2 года назад
Studio Code editor throws immediate error template: - sensor: incorrect type expected array state: Any ideas? thx
@shawnrichards7935
@shawnrichards7935 2 года назад
Can home assistant be used to send IR or RS232 command to control tv, audio receivers etc…?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
With something like a broad link you can!
@TheUnofficialMaker
@TheUnofficialMaker 2 года назад
@@SmartHomeMakers can you make a video on it!
@Boabee
@Boabee 2 года назад
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
@SmartHomeMakers 2 года назад
Can you share your code Bobby?
@Chesterflaps
@Chesterflaps Год назад
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
@SmartHomeMakers
@SmartHomeMakers Год назад
Do you mean in the developer tools?
@Rich33527
@Rich33527 2 года назад
Can you assign a unique id to the template sensor?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
What are you trying to achieve Damuson?
@Rich33527
@Rich33527 2 года назад
@@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...
@russgulley7193
@russgulley7193 Год назад
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
@SmartHomeMakers Год назад
Can you try to use states("number.humidifier_target_level") ? What do you get?
@russgulley7193
@russgulley7193 Год назад
@@SmartHomeMakers Thanks, that is the same as I'm using. Same error.
@n.r.2258
@n.r.2258 2 года назад
Danke!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Welcome!
@n.r.2258
@n.r.2258 2 года назад
@@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 ?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
@@n.r.2258 have you tried >= 40 and
@n.r.2258
@n.r.2258 2 года назад
@@SmartHomeMakers {% if states ('sensor.wasser_sensor') | float >= 40 and
@SmartHomeMakers
@SmartHomeMakers 2 года назад
you need to repeat the states portion again states ('sensor.wasser_sensor') | float
@kokzos
@kokzos 2 года назад
it will work with sonoff ewelink?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Have you got it integrated in HA?
@cchris3
@cchris3 2 года назад
Thanks for the video. I followed everything you did but after restarting I do not get a new sensor.tumble_dryer. Any idea why?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Chris, did you get any error messages? Do you want to share your YAML?
@cchris3
@cchris3 2 года назад
@@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
@SmartHomeMakers 2 года назад
@@cchris3 can’t spot anything wrong! Is template aligned to the left no spaces ?
@cchris3
@cchris3 2 года назад
@@SmartHomeMakers Yea, left aligned with no spaces. "Check Config" says valid and restart happens without issues. But just dont see the new sensor. Thanks.
@brentwesley6206
@brentwesley6206 2 года назад
Thanks for the video. BTW you have a spelling mistake in your splash screen. Cobing instead of Coding :D
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Thanks Brent!
@ryantrainor2
@ryantrainor2 2 года назад
Can this be used to make a virtual motion or contact sensor in HA?
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Ryan, what is your use case for a virtual motion sensor?
@ryantrainor2
@ryantrainor2 2 года назад
Hi, Thanks for replying. I’m trying to find away to trigger an Alexa routine with ahome assistant automation.
@SmartHomeMakers
@SmartHomeMakers 2 года назад
@@ryantrainor2 I think you will find this article a great read: robpickering.com/integrate-iotty-wall-switches-with-home-assistant/
@ryantrainor2
@ryantrainor2 2 года назад
Thank you I’ll check it out much appreciated!
@SmartHomeMakers
@SmartHomeMakers 2 года назад
@@ryantrainor2 Have a great day/evening!
@thepyropc_
@thepyropc_ 2 года назад
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)
@thepyropc_
@thepyropc_ 2 года назад
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
@thepyropc_
@thepyropc_ 2 года назад
figured it out by adding it it made another part in my yaml freak out
@SmartHomeMakers
@SmartHomeMakers 2 года назад
Hi Patrick! I’m glad you figured it out how did you do it ?
@thepyropc_
@thepyropc_ 2 года назад
@@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
@thepyropc_
@thepyropc_ 2 года назад
@@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
@WOTBLITZ_-xx1uf
@WOTBLITZ_-xx1uf 11 месяцев назад
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
@andrejo2459
@andrejo2459 2 года назад
Imej itu terlalu menyinggung perasaan
Далее
Home Assistant Templating Masterclass (Full Course)
46:18
Home Assistant Scripts Hidden Feature!
9:24
Просмотров 17 тыс.
Most POWERFUL Home Assistant SENSOR
11:14
Просмотров 41 тыс.