Home Assistant Templating Masterclass (Full Course)

Поделиться
HTML-код
  • Опубликовано: 1 дек 2024

Комментарии • 141

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

  • @robertaccess
    @robertaccess Год назад

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

  • @izemanevobike
    @izemanevobike 2 года назад

    Your channel deserves WAY more subscribers!!!

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

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

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

  • @mindracing
    @mindracing Год назад

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

  • @martinwatson8081
    @martinwatson8081 10 месяцев назад

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

  • @martinwesterberg1665
    @martinwesterberg1665 2 года назад +1

    Really good course on templating! Thank you!

  • @tomaszgasecki
    @tomaszgasecki 2 года назад

    Thank you, this makes templates more approachable.

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

  • @boomsig9069
    @boomsig9069 2 года назад +1

    Absolutely fantastic tutorial!

  • @michaeldearth5873
    @michaeldearth5873 9 месяцев назад

    Thank you so much, really informative!

  • @krisdevoecht
    @krisdevoecht Год назад

    Thanks for the good explanation! 👍

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

  • @LEDGardener
    @LEDGardener 2 года назад

    Fantastic video.

  • @julianhall4052
    @julianhall4052 2 года назад

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

  • @pcb1962
    @pcb1962 11 месяцев назад

    very useful video, thank you

  • @jazautomation
    @jazautomation 2 года назад

    Nice walkthrough and good tempo #smarthomemakers!

  • @NunoSoares22
    @NunoSoares22 2 года назад

    GREAT Work! Keep them coming!

  • @WavePuntFrl
    @WavePuntFrl 2 года назад

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

  • @TheCozzman
    @TheCozzman Год назад

    This was fantastic, thank you!!

  • @crsmale
    @crsmale 2 года назад

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

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

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

  • @rebe7800
    @rebe7800 2 года назад

    Excellent GOOD!

  • @nstufflebeam
    @nstufflebeam Год назад

    Thanks!

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

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

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

  • @garysteo3398
    @garysteo3398 2 года назад

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

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

  • @JoseBerruezo
    @JoseBerruezo 2 года назад

    Nice video!

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

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

  • @andymok7945
    @andymok7945 Год назад

    Thanks

  • @_Bogdan_
    @_Bogdan_ 5 месяцев назад

    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.

    • @SmartHomeMakers
      @SmartHomeMakers  5 месяцев назад

      Have you got the correct entity name ?

    • @SmartHomeMakers
      @SmartHomeMakers  5 месяцев назад

      Have you got the correct entity name ?

  • @spencerbigum1309
    @spencerbigum1309 2 года назад +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  2 года назад

      More about jinja templating Spencer!

    • @spencerbigum1309
      @spencerbigum1309 2 года назад

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

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

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

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

  • @tinespotgieter3552
    @tinespotgieter3552 2 года назад

    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  2 года назад

      Potentially if they are stored in different key value pairs

    • @tinespotgieter3552
      @tinespotgieter3552 2 года назад

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

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

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

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

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

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

  • @vitijordan1979
    @vitijordan1979 2 года назад

    Great!

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

  • @efranulicm
    @efranulicm 7 месяцев назад

    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  7 месяцев назад

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

    • @efranulicm
      @efranulicm 7 месяцев назад

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

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

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

  • @JasonKtheDJ
    @JasonKtheDJ 2 года назад

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

    • @JasonKtheDJ
      @JasonKtheDJ 2 года назад

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

  • @iotgate2990
    @iotgate2990 2 года назад

    @40:12 how to filter list results ?

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

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

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

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

  • @casperghst42
    @casperghst42 11 месяцев назад

    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  11 месяцев назад

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

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

  • @matthewcastrigno6138
    @matthewcastrigno6138 9 месяцев назад

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

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

  • @fransmulder9326
    @fransmulder9326 2 года назад

    Thanks it helped me a lot.