Home Assistant Templating Masterclass (Full Course)

Поділитися
Вставка
  • Опубліковано 22 сер 2024

КОМЕНТАРІ • 140

  • @blakebowden955
    @blakebowden955 3 дні тому

    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!!!

  • @cupertinogeek2070
    @cupertinogeek2070 Рік тому +4

    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
      @SmartHomeMakers  Рік тому

      Thanks Cupertino! Appreciate your kind words! I hope I can pull off another gem in the near future

  • @robertaccess
    @robertaccess 10 місяців тому

    We appreciate the time you spend to make this video. Very informative. Thank you!

  • @horaciomonaco6843
    @horaciomonaco6843 2 роки тому +1

    Thank you for sharing your knowledge. Even for people non English mother tongues, your explanations are crystal clear. Grazie!!

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Thanks Horacio, where do you come from? :)

    • @horaciomonaco6843
      @horaciomonaco6843 2 роки тому

      @@SmartHomeMakers Citizen of the world ... I was born in Argentina but but I have lived in Italy for 20 years

    • @SmartHomeMakers
      @SmartHomeMakers  Рік тому

      @@horaciomonaco6843are you happy Argentina are in the final of the World Cup?

    • @horaciomonaco6843
      @horaciomonaco6843 Рік тому

      @@SmartHomeMakers Yes, of course I am ... but I always keep in mind that it's just a game 🙂

  • @brunofreitag9474
    @brunofreitag9474 2 роки тому +3

    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.

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Thanks Bruno for the kind words! Feel free to share this video so it can help more people :)

  • @izemanevobike
    @izemanevobike 2 роки тому

    Your channel deserves WAY more subscribers!!!

  • @BenGmuN
    @BenGmuN 2 роки тому +1

    Dude, thank you for making this video. Really great and has helped me understand templating a lot.

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Appreciate your comment Ben, which part did you enjoy the most ?

    • @BenGmuN
      @BenGmuN 2 роки тому

      @@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') }}

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      @@BenGmuN Very smart! and which automations are you building from this sensor?

    • @BenGmuN
      @BenGmuN 2 роки тому

      @@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.

  • @mindracing
    @mindracing Рік тому

    Well done, Gio. Templates are now sinking in, at last!

  • @TheNico9870
    @TheNico9870 2 роки тому

    Thanks, I'm a frequent flyer here. Learning a lot every time.

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Are you watching the videos offline with premium?

    • @TheNico9870
      @TheNico9870 2 роки тому

      @@SmartHomeMakers Don't think so. Why do you ask? ;)

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      @@TheNico9870 I thought you were watching the videos offline :)

  • @tomaszgasecki
    @tomaszgasecki 2 роки тому

    Thank you, this makes templates more approachable.

  • @martinwesterberg1665
    @martinwesterberg1665 2 роки тому +1

    Really good course on templating! Thank you!

  • @ziezoenie-2023
    @ziezoenie-2023 Рік тому +1

    This is one of the best videos for learning templating. Thank you! However, some code is not working anymore, perhaps due to updates.

  • @martinwatson8081
    @martinwatson8081 7 місяців тому

    Excellent tutorial I have learnt a lot - thank you 👍🏻

  • @julianhall4052
    @julianhall4052 Рік тому

    Wow. You got me flying. My HA has just gone into orbit!

  • @boomsig9069
    @boomsig9069 2 роки тому +1

    Absolutely fantastic tutorial!

  • @ajithprabhakar
    @ajithprabhakar 2 роки тому +1

    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 :)

  • @crsmale
    @crsmale Рік тому

    Cool video, thanks! But please learn what an "operand" is: In "a+b", "a" and "b" are the operands, and "+" is the operator!

  • @pcb1962
    @pcb1962 8 місяців тому

    very useful video, thank you

  • @michaeldearth5873
    @michaeldearth5873 6 місяців тому

    Thank you so much, really informative!

  • @xXDeadJesterXx
    @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
      @SmartHomeMakers  Рік тому +1

      Glad it was helpful!

    • @xXDeadJesterXx
      @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.

  • @SamuelWakefield
    @SamuelWakefield 2 роки тому +1

    I'd say templating and Node Red are top on my list of things to master this year! Great video!

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      There is always going to be a lot to learn :) I guess that is part of the fun

  • @anyDiy
    @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
      @SmartHomeMakers  Рік тому

      Hi Dong! You can create your own sensor in the configuration.yaml and refer to it!

    • @anyDiy
      @anyDiy Рік тому

      @@SmartHomeMakers Yeah, I found the way. Thanks a lot.

  • @nstufflebeam
    @nstufflebeam Рік тому

    Thanks!

  • @krisdevoecht
    @krisdevoecht Рік тому

    Thanks for the good explanation! 👍

  • @NunoSoares22
    @NunoSoares22 2 роки тому

    GREAT Work! Keep them coming!

  • @Turbs
    @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.

  • @picotrain5959
    @picotrain5959 2 роки тому

    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 😉

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому +1

      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

  • @WavePuntFrl
    @WavePuntFrl 2 роки тому

    Thanks for this video,, i learned a lot from it.

  • @TheCozzman
    @TheCozzman Рік тому

    This was fantastic, thank you!!

  • @fransmulder9326
    @fransmulder9326 2 роки тому

    Thanks it helped me a lot.

  • @jazautomation
    @jazautomation 2 роки тому

    Nice walkthrough and good tempo #smarthomemakers!

  • @Bonaur
    @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.

  • @rebe7800
    @rebe7800 2 роки тому

    Make part 2. You show a lot used in Developer Tools. Show more (if possible) integrated in automations en in dashboards

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Hi Re Be, what would you like to see in part 2 specifically ?

  • @LEDGardener
    @LEDGardener 2 роки тому

    Fantastic video.

  • @andymok7945
    @andymok7945 Рік тому

    Thanks

  • @garysteo3398
    @garysteo3398 2 роки тому

    great information would you have a sample template for adding how many lights have a state = on

  • @muellerworld
    @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
      @SmartHomeMakers  Рік тому

      Hello! I think this video now might be a year old :) Can't remember which version it was!

  • @spencerbigum1309
    @spencerbigum1309 Рік тому +1

    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!

    • @SmartHomeMakers
      @SmartHomeMakers  Рік тому

      More about jinja templating Spencer!

    • @spencerbigum1309
      @spencerbigum1309 Рік тому

      @@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...

  • @rebe7800
    @rebe7800 2 роки тому

    Excellent GOOD!

  • @stephenpearse9778
    @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
      @SmartHomeMakers  Рік тому

      Hi Steve! In my latest video I showcase how to use the markdown card and a for loop

    • @stephenpearse9778
      @stephenpearse9778 Рік тому

      @@SmartHomeMakers by coincidence I just did this myself. But mark down is finicky!

  • @tinespotgieter3552
    @tinespotgieter3552 Рік тому

    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?

    • @SmartHomeMakers
      @SmartHomeMakers  Рік тому

      Potentially if they are stored in different key value pairs

    • @tinespotgieter3552
      @tinespotgieter3552 Рік тому

      @@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

  • @JoseBerruezo
    @JoseBerruezo 2 роки тому

    Nice video!

  • @rickz6006
    @rickz6006 2 роки тому

    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

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому +1

      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!

    • @richardharnwell3331
      @richardharnwell3331 2 роки тому

      @@SmartHomeMakers isn’t it to trim white space in any generated output?

  • @vitijordan1979
    @vitijordan1979 2 роки тому

    Great!

  • @chrisw1462
    @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?

  • @josebatalha2804
    @josebatalha2804 2 роки тому

    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 ?

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому +1

      Yes it is, remember that sometimes it can become difficult to debug code and get it write.

  • @Mrdsmith500
    @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?

  • @sekt1953
    @sekt1953 2 роки тому

    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

  • @scotthewitt6047
    @scotthewitt6047 Рік тому

    How do you handle your config.yaml do you split everything up or keep it all on one.

    • @SmartHomeMakers
      @SmartHomeMakers  Рік тому

      Used to split when HA was more yaml based, if you are a dev it would come natural

  • @_Bogdan_
    @_Bogdan_ 2 місяці тому

    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.

  • @RJ-gu3wp
    @RJ-gu3wp 2 роки тому

    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.

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Do you mean the triple curly brackets? It is part of the syntax to highlight we are using a reserved word (if)

  • @JasonBailey76
    @JasonBailey76 2 роки тому

    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.

  • @manuelmorillo10
    @manuelmorillo10 2 роки тому +2

    What is templating?

    • @WiseInetellect
      @WiseInetellect 2 роки тому

      Im curious about the history of templating. Did it start along side linux or was it even earlier than that?

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Hi Manuel! A way to do simple home assistant logic similar to a programming language

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      @@WiseInetellect Hi Kobi! Good question do you mean the jinja2 initiative ?

    • @WoottonRivers
      @WoottonRivers 2 роки тому

      This is fantastic stuff

  • @efranulicm
    @efranulicm 3 місяці тому

    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?

    • @SmartHomeMakers
      @SmartHomeMakers  3 місяці тому

      that look like a weird name for an entity, could you rename it? :)

    • @efranulicm
      @efranulicm 3 місяці тому

      @@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.

  • @n.r.2258
    @n.r.2258 2 роки тому

    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)

    • @SmartHomeMakers
      @SmartHomeMakers  2 роки тому

      Awesome! Appreciate your support, you can find buy me a coffee links if not can send over PayPal

    • @n.r.2258
      @n.r.2258 2 роки тому

      @@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.

  • @CriticalCipher
    @CriticalCipher 2 роки тому

    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

  • @JasonKtheDJ
    @JasonKtheDJ Рік тому

    the round function at the 17:47 mark is not working for me.

    • @JasonKtheDJ
      @JasonKtheDJ Рік тому

      Took some tinkering, but this seems to work.
      Inside Average Temperature {{ (inside_temperature) | round(0) }}
      or
      Inside Average Temperature {{ (inside_temperature) | int }}

  • @iotgate2990
    @iotgate2990 Рік тому

    @40:12 how to filter list results ?

  • @domingoscastelhano1702
    @domingoscastelhano1702 2 роки тому

    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

  • @casperghst42
    @casperghst42 7 місяців тому

    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 🤬

    • @SmartHomeMakers
      @SmartHomeMakers  7 місяців тому

      Appreciate you taking the time to giving me feedback! Sorry about the music

  • @JottyHB
    @JottyHB 2 роки тому

    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.

  • @the_vccground
    @the_vccground 10 місяців тому

    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 ?

  • @matthewcastrigno6138
    @matthewcastrigno6138 5 місяців тому

    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"
    },

  • @MrDjdenny13
    @MrDjdenny13 2 роки тому

    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?