Love this video - I have routinely come back every 4 or 5 months since you've released it as a refresher. Would love to see another masterclass with the new templating options HA has. Thanks for everything you do!!!
@SmartHomeMakersАй бұрын
Great suggestion!
@brunofreitag94742 жыл бұрын
Thank you for your effort. It addressed exactly the questions I was struggling with. It gave me the "concept" around templates. Without that I was lost, thanks to your video I was able to succeed.
@SmartHomeMakers2 жыл бұрын
Thanks Bruno for the kind words! Feel free to share this video so it can help more people :)
@cupertinogeek2070 Жыл бұрын
Awesome job. This is one of your best videos and it is packed with great content. Great way of teaching templates and coding breakdown for understanding contextually
@SmartHomeMakers Жыл бұрын
Thanks Cupertino! Appreciate your kind words! I hope I can pull off another gem in the near future
@robertaccess Жыл бұрын
We appreciate the time you spend to make this video. Very informative. Thank you!
@SmartHomeMakers10 ай бұрын
Thanks a lot for your appreciation !
@horaciomonaco68432 жыл бұрын
Thank you for sharing your knowledge. Even for people non English mother tongues, your explanations are crystal clear. Grazie!!
@SmartHomeMakers2 жыл бұрын
Thanks Horacio, where do you come from? :)
@horaciomonaco68432 жыл бұрын
@@SmartHomeMakers Citizen of the world ... I was born in Argentina but but I have lived in Italy for 20 years
@SmartHomeMakers Жыл бұрын
@@horaciomonaco6843are you happy Argentina are in the final of the World Cup?
@horaciomonaco6843 Жыл бұрын
@@SmartHomeMakers Yes, of course I am ... but I always keep in mind that it's just a game 🙂
@izemanevobike2 жыл бұрын
Your channel deserves WAY more subscribers!!!
@SmartHomeMakers2 жыл бұрын
Appreciate your support!
@martinwesterberg16652 жыл бұрын
Really good course on templating! Thank you!
@TheNico98702 жыл бұрын
Thanks, I'm a frequent flyer here. Learning a lot every time.
@SmartHomeMakers2 жыл бұрын
Are you watching the videos offline with premium?
@TheNico98702 жыл бұрын
@@SmartHomeMakers Don't think so. Why do you ask? ;)
@SmartHomeMakers2 жыл бұрын
@@TheNico9870 I thought you were watching the videos offline :)
@mindracing Жыл бұрын
Well done, Gio. Templates are now sinking in, at last!
@SmartHomeMakers Жыл бұрын
Thanks Ash! Appreciate it!
@martinwatson80819 ай бұрын
Excellent tutorial I have learnt a lot - thank you 👍🏻
@SmartHomeMakers8 ай бұрын
Glad it was helpful!
@tomaszgasecki2 жыл бұрын
Thank you, this makes templates more approachable.
@SmartHomeMakers2 жыл бұрын
Thanks Tomasz, glat I was able to help
@ziezoenie-2023 Жыл бұрын
This is one of the best videos for learning templating. Thank you! However, some code is not working anymore, perhaps due to updates.
@SmartHomeMakers Жыл бұрын
Thanks Mark for the heads up!
@boomsig90692 жыл бұрын
Absolutely fantastic tutorial!
@SmartHomeMakers2 жыл бұрын
Thanks so much Boomsig!
@BenGmuN2 жыл бұрын
Dude, thank you for making this video. Really great and has helped me understand templating a lot.
@SmartHomeMakers2 жыл бұрын
Appreciate your comment Ben, which part did you enjoy the most ?
@BenGmuN2 жыл бұрын
@@SmartHomeMakers Well, thanks to your explanation of setting variables, I was finally able to figure out how to create a sensor that would show me the last command issued to any of my Alexa voice assistants. {% set last_alexa = expand('group.voice_assistants') | selectattr('attributes.last_called','eq',true) | map(attribute='entity_id') | first %} {{ last_alexa }} {{ state_attr(last_alexa,'last_called_summary') }}
@SmartHomeMakers2 жыл бұрын
@@BenGmuN Very smart! and which automations are you building from this sensor?
@BenGmuN2 жыл бұрын
@@SmartHomeMakers Thanks! So, I actually just wanted to display the last Alexa command in Lovelace, but I'm thinking about attempting to use it to build an automation for context-sensitive voice control of curtains, blinds and TVs, i.e. if I'm in the lounge and say "Alexa, open curtains", my automation will know I want the lounge curtains because the command originated from the lounge Echo - I don't have to say "Alexa, open the lounge curtains" Make sense? Not sure how I achieve this though. Currently, I'm using a separate automation for each different TV, blind, and curtain, which is a bit complicated.
@julianhall40522 жыл бұрын
Wow. You got me flying. My HA has just gone into orbit!
@SmartHomeMakers2 жыл бұрын
Thanks Julian!!
@michaeldearth58738 ай бұрын
Thank you so much, really informative!
@SmartHomeMakers7 ай бұрын
You're very welcome!
@crsmale2 жыл бұрын
Cool video, thanks! But please learn what an "operand" is: In "a+b", "a" and "b" are the operands, and "+" is the operator!
@SmartHomeMakers2 жыл бұрын
Thanks Colin for pointing out my mistake!
@krisdevoecht Жыл бұрын
Thanks for the good explanation! 👍
@SmartHomeMakers Жыл бұрын
Hey Kris, My pleasure!
@ajithprabhakar2 жыл бұрын
Very good tutorial, though I have been using HA for a while now, I haven’t used templates much, this video surely will help me in reducing my configuration yamls a lot :)
@SmartHomeMakers2 жыл бұрын
Appreciate your support!
@pcb196210 ай бұрын
very useful video, thank you
@SmartHomeMakers10 ай бұрын
Glad it was helpful!
@NunoSoares222 жыл бұрын
GREAT Work! Keep them coming!
@SmartHomeMakers2 жыл бұрын
Thanks Nuno!
@Turbs Жыл бұрын
Great video that I've referred to many times over the last few months. Many thanks. Have you made any videos on using regular expressions in templates? I can't find any and the HA Templating docs are a little light on real world examples.
@SmartHomeMakers Жыл бұрын
Hey Mike! What are you trying to achieve ? :)
@jazautomation2 жыл бұрын
Nice walkthrough and good tempo #smarthomemakers!
@SmartHomeMakers2 жыл бұрын
Thanks Jaz!
@nstufflebeam Жыл бұрын
Thanks!
@SmartHomeMakers Жыл бұрын
Thank you soo much Nathan!!!!!
@xXDeadJesterXx Жыл бұрын
Thank you for this. I was looking for a way to parse variables to convert the 24hr time format to a 12hr that can be spoken by my Alexa device. This should work perfectly.
@SmartHomeMakers Жыл бұрын
Glad it was helpful!
@xXDeadJesterXx Жыл бұрын
Is it possible to do functions/methods in Home Assistant? I am working on my script and I want to get the month name from the date variable. I want to create a function within the template that I can pass the month integer to and it returns the month name by either using IF statements or a Switch Case.
@LEDGardener2 жыл бұрын
Fantastic video.
@SmartHomeMakers2 жыл бұрын
Thanks a lot!
@TheCozzman Жыл бұрын
This was fantastic, thank you!!
@SmartHomeMakers Жыл бұрын
Glad you enjoyed it!
@fransmulder93262 жыл бұрын
Thanks it helped me a lot.
@SmartHomeMakers2 жыл бұрын
Thanks Frans for watching !
@anyDiy Жыл бұрын
Brilliant video. Very clear. I learned lots from this video. Thanks a lot. Just have a question: How do we use global variants in templates? For example: - binary_sensor: - name: "On fire" state: > {% set AlarmTemp = 50 %} ..... attributes: test: "{{ AlarmTemp }}" I define AlarmTemp in "state", and want to access AlarmTemp's value from "attributes".
@SmartHomeMakers Жыл бұрын
Hi Dong! You can create your own sensor in the configuration.yaml and refer to it!
@anyDiy Жыл бұрын
@@SmartHomeMakers Yeah, I found the way. Thanks a lot.
@picotrain59592 жыл бұрын
Question: In the example you used for ground temp you used {% %} for the variables and then used {{ }} for the statement which I understand completely. I also understand you could have also listed all the variables and the math completely in the statement itself. So my question is, what’s the difference if any and or the pros and cons to doing it the 2 different ways. I have a template sensor that reports a room temp based on multiple temp sensor sources in the same room, but have simply listed all the sensors and the math in one statement and never considered doing in any differently? Thanks for the great videos and if you don’t mind me saying they are getting better with each and every one 😉
@SmartHomeMakers2 жыл бұрын
Just how easy it is to read, when doing these videos and sharing code sometimes I need to break things down a bit. Also good to verify your math as you go along
@rebe78002 жыл бұрын
Excellent GOOD!
@SmartHomeMakers2 жыл бұрын
Thanks!!
@Bonaur Жыл бұрын
Good tutorial I learned a lot ! But how do I assign/set a value TO an entity.state ? Fx. I have a Number Helper that I want to assign a state value, because I need the stored value in other calculations later on ?! Or are there an other way to store values ? Thank you.
@SamuelWakefield2 жыл бұрын
I'd say templating and Node Red are top on my list of things to master this year! Great video!
@SmartHomeMakers2 жыл бұрын
There is always going to be a lot to learn :) I guess that is part of the fun
@muellerworld Жыл бұрын
Great tutorial, thank you. I am, however, running into a few syntax issues: What version of HA was this video made for? Has HA made some syntax changes since this video was released? For example, I get errors with: {% for state in states.sensor | selectattr('attributes.device_class','==','temperature') %} However, this works: {% for state in states.sensor | selectattr('attributes.device_class','defined') | selectattr('attributes.device_class','==','temperature') %} Also "unknown" errors with this: {{ states('sensor.date') }} Is there new syntax for HA Templates in 2023.6.3?
@SmartHomeMakers Жыл бұрын
Hello! I think this video now might be a year old :) Can't remember which version it was!
@garysteo33982 жыл бұрын
great information would you have a sample template for adding how many lights have a state = on
@SmartHomeMakers2 жыл бұрын
Yep in this video!
@andymok7945 Жыл бұрын
Thanks
@SmartHomeMakers Жыл бұрын
Thanks Andy!!! happy new year!!!
@spencerbigum13092 жыл бұрын
As a javascript developer, if I want to dive into coding custom layouts and designs for lovelace(as an example) does this cover everything I need to know? Thanks!
@SmartHomeMakers2 жыл бұрын
More about jinja templating Spencer!
@spencerbigum13092 жыл бұрын
@@SmartHomeMakersThanks! I've done more research and it looks like I need to learn more about jinja to better manipulate devices and entities and then I can pass it to my card design that I create in JS. Is there a list of functions that we can call in HA in the templating development area? I'm sure there are more than state_attr() or others you've mentioned in the video...
@stephenpearse9778 Жыл бұрын
Very nice tutorial! But I'm trying to figure out how to use your examples. The list of temperatures, how would you view them in Lovelace? There is no card that will display the output of a template, right? What exactly do you use these text list templates FOR?
@SmartHomeMakers Жыл бұрын
Hi Steve! In my latest video I showcase how to use the markdown card and a for loop
@stephenpearse9778 Жыл бұрын
@@SmartHomeMakers by coincidence I just did this myself. But mark down is finicky!
@rebe78002 жыл бұрын
Make part 2. You show a lot used in Developer Tools. Show more (if possible) integrated in automations en in dashboards
@SmartHomeMakers2 жыл бұрын
Hi Re Be, what would you like to see in part 2 specifically ?
@JoseBerruezo2 жыл бұрын
Nice video!
@SmartHomeMakers2 жыл бұрын
Glad you enjoyed it Jose!
@tinespotgieter35522 жыл бұрын
Great Video, Was wondering is it possible to change 2 "items" of a sensor with templating. I know you can change the icon based on the state, you can also change the color of the icon. How would you change both?
@SmartHomeMakers2 жыл бұрын
Potentially if they are stored in different key value pairs
@tinespotgieter35522 жыл бұрын
@@SmartHomeMakers - ```{% elif is_state('sensor.tv_state','player') %} {{ 'mdi:alpha-b-circle-outline' }}``` but want the icon mdi:alpha-b-circle-outline to be blue. Its now, same check but two changes
@josebatalha28042 жыл бұрын
Hi, thanks for another great video ! A quick question: you used all this code inside the developer tools template area, but is it possible to use it inside the Raw Configuration Editor of the dashboards, ou inside the Code Editor of the cards ?
@SmartHomeMakers2 жыл бұрын
Yes it is, remember that sometimes it can become difficult to debug code and get it write.
@rickz60062 жыл бұрын
Thanks for this, very helpful, Questions: You mentioned that the > was needed to use multiple lines. Great this is the kind of syntax info I can't seem to locate. But in the same screen 2 lines of code used {%- what is the minus for in this use case? Then when you showed us your occupancy sensor, after the "icon_template: >-" the >- was used what is the - for in that case? These are the things that perplex me as much as anything. Thanks again
@SmartHomeMakers2 жыл бұрын
Great question Rick! I'm not sure myself, I have tried to omit it and get the same result, will continue to research, hopefully someone from the community can jump on and answer your question!
@richardharnwell33312 жыл бұрын
@@SmartHomeMakers isn’t it to trim white space in any generated output?
@sekt19532 жыл бұрын
Hi thanks for your good videos, I'm sitting now trying to make a template that mimics what is displayed when a timer has started it looks like you are using finishes_at: 2022-01-14T13: 50: 02 + 00: 00 from which to subtract now (), but how
@vitijordan19792 жыл бұрын
Great!
@SmartHomeMakers2 жыл бұрын
Thanks Victor!
@scotthewitt6047 Жыл бұрын
How do you handle your config.yaml do you split everything up or keep it all on one.
@SmartHomeMakers Жыл бұрын
Used to split when HA was more yaml based, if you are a dev it would come natural
@_Bogdan_4 ай бұрын
Hi and thanks for the nice video. I can't get the {{ state_attr('sensor.aqara_temp_humidity_sensor_temperature','temperature')}} to show the temperature I only get null as response. any idea why? tested with aqara and hue sensor.
@SmartHomeMakers3 ай бұрын
Have you got the correct entity name ?
@SmartHomeMakers3 ай бұрын
Have you got the correct entity name ?
@chrisw1462 Жыл бұрын
@24:00 "..and then we will _combat_ all of this..." What?? The CC says 'combat' but I _think_ you said 'compare'. But the '|' is a pipe, and doesn't compare anything. And the '(-1)' after it is totally baffling. Could someone explain exactly what this is doing?
@JasonBailey762 жыл бұрын
I have a large and complex template that I use in several automations. can i put that in a yaml file and referance it in an automation? the purpose is to only have to change it once for all of them.
@SmartHomeMakers2 жыл бұрын
Hi Jason! Yes you can put it into a script
@n.r.22582 жыл бұрын
Great course …. unfortunately the „Thanks“ button is not working. I tried to contribute … but it doesn’t work. Can you check that or give me another way to contribute . (perhaps via PP)
@SmartHomeMakers2 жыл бұрын
Awesome! Appreciate your support, you can find buy me a coffee links if not can send over PayPal
@n.r.22582 жыл бұрын
@@SmartHomeMakers Ok, I did. it via another video. But I have a question left: How do you implement a template, that gives you the value i.e. of a voltage reading. {{ states('sensor.sonoff_100033223e_voltage') }} into a custom button card, (switch) to replace either the name or the status. Goal is, to show this voltage value in a CBC that switches another sensor either by replacing ‚status‘ or ‚name‘ of that card. That was ( for me) missing in that tutorium, to make it perfect. But thanks again, I appreciate you’re video and I’ve learned a lot.
@Mrdsmith500 Жыл бұрын
Why do I get "none" for every one of my sensors? No matter which, it's always a value of "none" what am I missing?
@RJ-gu3wp2 жыл бұрын
Even though I have used them, I do noit understand what the triple square brackets are used for when creating IF statemets. Could someone point me in the right direction.? Thanks.
@SmartHomeMakers2 жыл бұрын
Do you mean the triple curly brackets? It is part of the syntax to highlight we are using a reserved word (if)
@efranulicm5 ай бұрын
Thank you Leonardo, fantastic job. Can you help me with this please: If I write {{ states.light.0xa4c138eec7b6bc21 }} the template is listening to light.11871832690929351713. Of course, light.11871832690929351713 thoes not exist, so the answer is none. ¿Why jinja converts to decimal the entity name, and how can I make it work?
@SmartHomeMakers5 ай бұрын
that look like a weird name for an entity, could you rename it? :)
@efranulicm5 ай бұрын
@@SmartHomeMakers Well, all my Zigbee devices (Zigbee2mqtt) has names like that, and all my automations uses this device names, so I prefere not to change it if possible.
@manuelmorillo102 жыл бұрын
What is templating?
@WiseInetellect2 жыл бұрын
Im curious about the history of templating. Did it start along side linux or was it even earlier than that?
@SmartHomeMakers2 жыл бұрын
Hi Manuel! A way to do simple home assistant logic similar to a programming language
@SmartHomeMakers2 жыл бұрын
@@WiseInetellect Hi Kobi! Good question do you mean the jinja2 initiative ?
@WoottonRivers2 жыл бұрын
This is fantastic stuff
@JasonKtheDJ2 жыл бұрын
the round function at the 17:47 mark is not working for me.
@JasonKtheDJ2 жыл бұрын
Took some tinkering, but this seems to work. Inside Average Temperature {{ (inside_temperature) | round(0) }} or Inside Average Temperature {{ (inside_temperature) | int }}
@domingoscastelhano17022 жыл бұрын
Hi: Inspires for your amazing video I've tried my first experience on templating .The idea is to manage the information from my fronius solar inverter .I built the sensor templates attached but I can't found them a s entities .Any idea of what I'm missing . template: - sensor: - name: grid_energy_fronius unit_of_measurement: 'kWh' value_template: "{{ (states('sensor.energy_real_consumed_fronius_meter_0_192_168_30_210') | float ) / 1000 }}" icon_template: mdi:grid-power state_class: total_increasing - name: produced_energy_fronius unit_of_measurement: 'kWh' value_template: "{{ (states('sensor.energy_real_produced_fronius_meter_0_192_168_30_210') | float ) / 1000 }}" icon_template: mdi:solar-power state_class: total_increasing - name: dif_prod_consumo_fronius unit_of_measurement: "W" state: > {% set prod = states('sensor.power_photovoltaics_fronius_power_flow_0_192_168_30_210') | float %} {% set consumo = states('sensor.power_load_fronius_power_flow_0_192_168_30_210') | float %} {{ ((prod + consumo) ) | round(1) }} state_class: total_increasing
@CriticalCipher2 жыл бұрын
does any one know of a way to have a sensor only change state when the condition has been met for a specified amount of time
@SmartHomeMakers2 жыл бұрын
good question, did you find out?
@iotgate29902 жыл бұрын
@40:12 how to filter list results ?
@SmartHomeMakers2 жыл бұрын
have you tried the pipe | ?
@casperghst429 ай бұрын
Very interesting, but the background music is horrific. Do you have music running in the back ground when you're in a class room? Just gave up 🤬
@SmartHomeMakers9 ай бұрын
Appreciate you taking the time to giving me feedback! Sorry about the music
@JottyOL2 жыл бұрын
I don’t know if I am the only one who says: too much input way too fast! Teaching templates on real problems with increasing complexity would be, what I need.
@SmartHomeMakers2 жыл бұрын
Thanks for your feedback
@matthewcastrigno61388 ай бұрын
Thank you for this video. I am really struggling trying to reference values from a device. I have downloaded the json file of a z-wave device but my attempt to reference for example the door code like this return none. Can you shed any insight on what I may be doing wrong? Thank you! ("value","new value" changed for privacy) {{ state_attr('lock.front_door_lock','4-99-0-userCode-3)}} yields "None" snippet from json: { "id": 4, "name": "Front Door Lock", "loc": "Living Room", "values": [ {.. .. { "id": "4-99-0-userCode-3", "nodeId": 4, "toUpdate": false, "commandClass": 99, "commandClassName": "User Code", "endpoint": 0, "property": "userCode", "propertyName": "userCode", "propertyKey": 3, "propertyKeyName": "3", "type": "string", "readable": true, "writeable": true, "label": "User Code (3)", "stateless": false, "commandClassVersion": 1, "minLength": 4, "maxLength": 10, "list": false, "value": "yyyy", "lastUpdate": 1708819929286, "newValue": "xxxx" },
@the_vccground Жыл бұрын
I'm having the following template state_attr('sensor.waqi_pusa_delhi_delhi_india','time') that results in 2023-10-21 07:00:00+05:30 How do I pull the hour digit out of it ? I was using the split function until now and it was working well but after recent HA update, it broke and now that split function is no longer working..Can you help ?
@MrDjdenny132 жыл бұрын
Guys, i've a problem, i'm using this in the template editor {{ state_attr('sensor.transmission_started_torrents','torrent_info') }} and my result is this: { "Camp.X-Ray.2014.720p.Blu-ray.DD5.1.x264.RoSubbed-playHD": { "added_date": 1656844965, "percent_done": "0.00", "status": "downloading", "id": 92 } } How can i twist it in order to show me only the name of the movie?