Mastering Scripts in Home Assistant: A Comprehensive Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024

ความคิดเห็น • 112

  • @PosiCat
    @PosiCat 3 หลายเดือนก่อน +2

    I was banging my head against scripts and return values, your video got my scripts working perfectly now thanks!

  • @simonknight2973
    @simonknight2973 10 หลายเดือนก่อน +7

    Finally the difference between scripts and automations is clear to me. Thank you. Going to try these custom fields out. I’ve mainly been using scripts when I want them to automatically get discovered as scenes in Alexa.

  • @SmartHomeJunkie
    @SmartHomeJunkie  10 หลายเดือนก่อน +4

    Be a Scripts pro in Home Assistant! Learn about using Fields and Response variables in Scripts in Home Assistant and let me know what advanced scripts you can think of!
    ⭐See the description of this video for all the links to other tutorials and sponsoring options! ⭐

  • @videomichel
    @videomichel 10 หลายเดือนก่อน +3

    Your content made me re-engage with my home automation after getting accustomed to so many glitches and nuisances and things that 'should work better but eh, it is good enough'. Sorting all of these out one by one not only made me enjoy all the smart things I have more, it also increased the wife acceptance factor by miles. Thank you so much for your work.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      That's great to hear! 👍🏻👍🏻

    • @ricardoramirez-ue5li
      @ricardoramirez-ue5li 8 หลายเดือนก่อน +2

      "Wife acceptance" is a fundamental variable in HA settings, lol

  • @emms-place
    @emms-place หลายเดือนก่อน +1

    Thanks for this very informative tutorial on using scripts Ed. Cant wait to see what I can come up with in my setup

  • @BeardedTinker
    @BeardedTinker 10 หลายเดือนก่อน +4

    Great video as per usual!!! Keep them coming.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +2

      Thank you Andrej! You're the best!

  • @jamesdavis-claydon8520
    @jamesdavis-claydon8520 10 หลายเดือนก่อน +3

    Thank you for going slowly, if I watch this a few times, I should be able to understand enough to accomplish what I wanted to do, which is check my home temperature to see if is hot or cold. If it is hot which for me is above 25C, and I have been away and am now 15Km from home, send the RF code that turns my portable air conditioner on. If it's cold which for me is below -20C, set the thermostat to 23. I learn much better thru audio and video due to a brain injury.. Reading and typing takes a lot more effort

  • @esenterre
    @esenterre 3 หลายเดือนก่อน

    You made simple explanations, easy to follow. Now it's time to see if I can make it work! Thanks!

  • @TheBroz
    @TheBroz 7 หลายเดือนก่อน

    Got my Home Assistant Green today and screwing about with notifications was one of the first things I did. Managed to setup a script to send a custom message to the phones and the living room TV. Early days but I’m already impressed with the power and flexibility of HA.

    • @SmartHomeJunkie
      @SmartHomeJunkie  7 หลายเดือนก่อน +1

      That's awesome to hear. Have fun with HA! It's a rabbithole, but also a lot of fun.

  • @alexkerin3691
    @alexkerin3691 10 หลายเดือนก่อน +1

    You really inspired me. I created a script that allows the automation creator to select which of the family phones the notification should go to, and whether it should be a critical notification. Much appreciated.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      That's awesome to hear!

  • @johnnynobels
    @johnnynobels 10 หลายเดือนก่อน +2

    Thank you for this vety usefull tutorial. I didnt not know using parameters in scripts was that easy.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Glad it was helpful!

    • @johnnynobels
      @johnnynobels 10 หลายเดือนก่อน +1

      @@SmartHomeJunkie , I tried to use parameters right away but noticed I did not have this option in my HA configuration. I found out you must have version 2023.11 installed. Perhaps also important for others who want to try.

  • @PontusWelin
    @PontusWelin 10 หลายเดือนก่อน +1

    Very helpful! I had an issue where this would have helped just this past week. I had notifications in my automations set to the wrong phone. Thanks!

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      Great to hear that it helps!

  • @christophhulsmann7430
    @christophhulsmann7430 10 หลายเดือนก่อน +1

    So I'm dizzy ;-), I translated first and will try the scripts and automations - Thanks!
    Once again you helped me a lot to understand more!
    "Get Notified And Respond Immediately Using Actionable Notifications in Home Assistant"
    was also a very good tutorial, I continue with “Mastering Scipts in Home Assistant”...
    greeting - Your work is simply great and important for understanding Home Assistant!

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Thank you so much for your compliment! 🙏🏻

  • @thehostler0
    @thehostler0 3 หลายเดือนก่อน

    The saddest part about this is going back into all of the automations and swapping out the phone notifications actions for the script. Thanks, this helped me understand scripts much better.

  • @robhoogland01
    @robhoogland01 10 หลายเดือนก่อน +2

    Great video. Good explanation. I will be going to use this for sure. Thanks, Ed.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      Thank you for your kind words. This keeps me going! 🙏🏻

  • @GregGranito
    @GregGranito 6 หลายเดือนก่อน

    This is so great. As someone who just had to update many many automations when I got a new phone, the script template is fantastic.
    One question: Any idea how we could add actionable notifications via the script with fields?

  • @bertrandmauge9832
    @bertrandmauge9832 10 หลายเดือนก่อน +1

    Tks a lot for your help / tuto, you inspired me a lot. I'm a beginner and of course I'm stuck on the more advance user. I have try to adapted the script to the fire alarm: I've got a few of them (zwave and zigbee) and I would like to get the information on my phone of which one is active. And, of course, I will then use it for the leak sensor as well. Also, tks for the idea of the script for the phone: I'm getting more and more automatisations and you help me to realised how helpfull it would to change only one script for a new phone.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      That's great to hear. Thank you for responding! 🙏🏻

  • @hillstreesandstreams
    @hillstreesandstreams 9 หลายเดือนก่อน

    Fab, thank you. Used the phone notification script in 3 of my automations already. Great tips and I'm off to watch som more vidoes.

    • @SmartHomeJunkie
      @SmartHomeJunkie  9 หลายเดือนก่อน

      Looks like you're on a roll with those automations! Don't forget to take breaks and grab some popcorn before diving into more videos.

  • @kindred27
    @kindred27 4 หลายเดือนก่อน

    This video helped me to look closer for typos in my script.
    I was 100% sure I had written everything correctly but I got no variable sent to my phone. Only : The weather is ......... and nothing.
    Went back to the script an saw an typo
    variables:
    weatcher_condition:
    Still did not get anything sent to my phone and then I saw the other typo
    response_variable: weather_codition
    Slow an steady I guess. Thank you for sharing examples.

  • @MrNetworkG
    @MrNetworkG 10 หลายเดือนก่อน +1

    Great video, more videos like this. Thank you, sir!

  • @tgf2004nl
    @tgf2004nl 10 หลายเดือนก่อน +1

    Briljante video weer, daar heb ik echt wat aan 🙂

  • @alexicna92
    @alexicna92 10 หลายเดือนก่อน +1

    Great video again ! So useful ! Thanks a lot.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Thank you for the compliment.

  • @adamg3402
    @adamg3402 8 หลายเดือนก่อน +1

    Dziękujemy.

  • @EsotericArctos
    @EsotericArctos 10 หลายเดือนก่อน

    A lot of stuff scripts do can also be done in scenes now. I am not really sure about needing both scripts and scenes in Home Assistant. They use to be quite different, but these days they are quite similar.
    I use scripts a lot because this is how I use to do all my scenes, because the scenes feature use to be really rubbish back in 2018 when I first got serious with Home Assistant. Scripts are definitely handy, much better than having super complex automations with so much code beign repeated.
    My first script was a "night mode" script, which triggered at bed time to lock doors and turn off lights.

  • @squalazzo
    @squalazzo 10 หลายเดือนก่อน +1

    great content as always, thanks!

  • @janiguzhuni3490
    @janiguzhuni3490 8 หลายเดือนก่อน

    Very nice 👌
    How to create long press button dimming increase or decrease lights in home assistant in 1 single buton automation? Can you help me for this 😅

  • @Superawesomeduckface
    @Superawesomeduckface 10 หลายเดือนก่อน +1

    This is so helpful to simplify all of my notification automations! Any suggestions on how to add a field for adding actions to the script? A lot of mine have an action and it would be greatto add a YAML field.

    • @durtoffmyshoulda
      @durtoffmyshoulda 8 หลายเดือนก่อน

      I'm sure this formatting won't come across here correctly..but I viewed my action notification in YAML and then copied it to this script and it worked well! It looks like you might need a separate script for an action that won't change. Here is what mine looks like
      message: "{{message}}"
      title: "{{title}}"
      data:
      actions:
      - action: URI
      title: Open Unifi Protect
      uri: app://com.ubnt.unifi.protect

  • @DavidWhatfor
    @DavidWhatfor 10 หลายเดือนก่อน +1

    Use case for me was having multiple helper toggles changing at the same time :-) I use conditional cards a lot to free up dashboard space and only give relevant options and these rely on my helpers. On another note have you or anyone done a video on the different installation options and their Pros/Cons. I run a VM image but the HA instance is in a docker within that VM and I want to rebuild possibly in docker outside of that VM rather than on dedicated hardware because of the flexibility and not have to go through so many layers when it comes to USB devices i.e. Zigbee, Bluetooth, etc.

  • @JohanVromans
    @JohanVromans 10 หลายเดือนก่อน +1

    Good job (again)!

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Thank you! 🙏🏻🙏🏻🙏🏻

  • @MikaCinema34
    @MikaCinema34 10 หลายเดือนก่อน +1

    Thank you very much for your high-quality videos. I have a question; my mother has fallen several times in the house, and I'm thinking of installing Home Assistant with a video camera. However, do you know if there is a plugin available to monitor her vital signs (such as heart rate and blood pressure) and, MOST importantly, a fall detector so that I can quickly intervene? Thank you.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Thanks! I believe the Aqara FP2 has human fall detection. I did not test that feature though.

  • @bgable7707
    @bgable7707 หลายเดือนก่อน

    Though, I have the HA "companion" app installed on my Android phone, after selecting the device that has the App installed, I never received a notification from it, hmm.
    Additionally the flow from Create New Script popup, next screen only displays Sequence: + Add action or + Add Building Block.

  • @Wimpieseigen
    @Wimpieseigen 10 หลายเดือนก่อน +1

    Thanks

  • @Mr-Coke
    @Mr-Coke 8 หลายเดือนก่อน

    i have bought me the S3 lite. But the voice is really low and you cant set it louder. How is this with the S3 Box? Can you adjust there the volume? Or can we send the sound to an integrated speaker? So we only use the display microphone and the voice comes from speakers?

  • @serichard
    @serichard 6 หลายเดือนก่อน

    So I'm working on a notification engine for my duplex with both sides involved was looking at the fields particulary the selector type field... It has the blank selector options, but for the love of god I can't find anything on how to setup a list to select between there.

  • @empewoow
    @empewoow 9 หลายเดือนก่อน

    Can you help me out? The Response variable field is not there when I use the visual editor. when I try the YAML editor, and add it manually, I get this error:
    Message malformed: extra keys not allowed @ data['sequence'][0]['response_variable']

  • @pontuslandin6883
    @pontuslandin6883 3 หลายเดือนก่อน

    It is awesome to see that there is so much left to learn in HA. It’s a deep hole 😂

  • @metoo7587
    @metoo7587 5 หลายเดือนก่อน

    A challenge when making such superior videos is that in less than a month, the video content often becomes obsolete because HA has changed so much, many of the screens (UI) and instructions are incorrect. In HA 2024.4.3 the Fields option has several new entries, like Selector Type, Selector Options etc. I tried to follow your video, but at the end I couldn't get it to combine the text with the condition variable (value). I only got the text coming out on my phone. I suspect that this might be related to the field selector option being set to Text.

    • @SmartHomeJunkie
      @SmartHomeJunkie  5 หลายเดือนก่อน

      It's a challenge indeed, but the functionality should still work because the YAML does not change.

    • @metoo7587
      @metoo7587 5 หลายเดือนก่อน +1

      @@SmartHomeJunkie Hi, I found my error. I had overlooked the piping symbol in the script. A small, but oh so important detail. 😶

    • @metoo7587
      @metoo7587 5 หลายเดือนก่อน

      @@SmartHomeJunkie Well, now I get "Error: Service response data expected a dictionary, was

  • @psylenced
    @psylenced 10 หลายเดือนก่อน

    One suggestion - you don't need to add 2 conditions to your "else if" because it's implied by the previous conditions. The only time you'd need to add both is if they were standalone "if" statements.
    so:
    If (temp < 5)
    elif (temp < 15)
    elif (temp < 20)
    elif (temp < 30)
    endif
    or:
    if (temp < 5)
    endif
    if (temp >= 5 and temp < 15)
    endif
    if (temp >= 15 and temp < 25)
    endif
    Also might help to add an "else" at the end - to handle the situation that temp is over 30.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Thanks. It's just an example... This video is not about how to create perfect template code, but on how to use scripts...

  • @gumbypokey7
    @gumbypokey7 10 หลายเดือนก่อน

    Very informative but I think a big turn off for some users is going to be the need to jump into YAML at even the simplest of scripts. Even in the example of using fields in a notification service call required directly editing the YAML. Might be nice if the script editor UI got some love to help novice users.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      There will be some modifications in the next release of HA already. But, YAML is not that difficult imho.

  • @jamesdavis-claydon8520
    @jamesdavis-claydon8520 10 หลายเดือนก่อน

    I followed all of the steps in the video, but I obviously missed something because when I toggle the dummy switch I get the following error :
    "Call-service error. TypeError: '

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Yup. According to the error message you most likely made a mistake in your template code. You do have Openweathermap installed, right?

  • @syukrishahabuddin4618
    @syukrishahabuddin4618 10 หลายเดือนก่อน

    I would like to know if there’s a way to create a chatbox dashboard card for family members that are on my HA to use. I imagine i would need helper and scripts but don’t know how to go about it. Would appreciate a tutorial if available.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Interesting. Can you elaborate on your use case?

    • @syukrishahabuddin4618
      @syukrishahabuddin4618 10 หลายเดือนก่อน

      @@SmartHomeJunkie sure. 1. Experimenting on a localized on HA chat window between users/family members.
      2. Maybe replicating the “refrigerator post its” in the home , for reminders, notes, to-dos.
      Would be a 5-10 line latest “messages/notes/inputs” that will be visible on the dashboard.
      Am struggling to find something similar to extrapolate.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      @@syukrishahabuddin4618 I'm not aware of a chat functionality like this in HA.

  • @Dendee2
    @Dendee2 10 หลายเดือนก่อน

    What's the name of the panel in the back that says Please subscribe? Is it also connected to HA?

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      It's this one:
      This is the BEST MATRIX DISPLAY CLOCK for Home Assistant!
      th-cam.com/video/N0NKPJzGHuA/w-d-xo.html

    • @Dendee2
      @Dendee2 10 หลายเดือนก่อน +1

      Thanks this is exactly what I was looking for the last few weeks 👍🏻

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      @@Dendee2 That is great to hear!

  • @metoo7587
    @metoo7587 5 หลายเดือนก่อน

    At least on my Samsung Galaxy S21+ these notifications doesn't show up anywhere before I unlock the phone - which makes it much less useful.

    • @SmartHomeJunkie
      @SmartHomeJunkie  5 หลายเดือนก่อน

      Might be a setting on your phone. 🤷🏼‍♂️

  • @Raymond.Jansen
    @Raymond.Jansen 10 หลายเดือนก่อน

    Is it possible to also add the data field in the notify script? When I add a field data, and add it to the yaml section in the script, it doesn't work.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      I'm not sure what you mean.

    • @Raymond.Jansen
      @Raymond.Jansen 10 หลายเดือนก่อน

      @@SmartHomeJunkie When I select the notify service, I have 4 fields. Message, Title, Target and data. The message and title you explained in your video (thanks, works great). But for some automations I also use the data field in the notify service. Sometimes to add an image in the message, sometimes to make an actionable notification (select yes or no). But it doesn't just work if I add a field in the notify script (data) and add: data: "{{data}}" in the yaml code under action. It would be great if this could work, because then I could call the script allways. Makes it much easier when changing phones.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      @@Raymond.Jansen Ah, now I understand what you mean. I didn't try this myself tbh. Maybe the issue is that the data field contains more complex yaml. I will experiment a bit with this.

    • @dennisschoenmakers5716
      @dennisschoenmakers5716 10 หลายเดือนก่อน +1

      @@SmartHomeJunkie That would be great, I'm trying that to. I've got an automation that sends me a message to my phone when traffic is piling up before I go to work with a link that shows me the map.
      I did change all the other notifications using scripts, that was a great tip, thanks again!

  • @Rob_65
    @Rob_65 10 หลายเดือนก่อน +1

    I do have to play with this on my system. It's time to do more than just switching lights and other equipment on and off 😀

  • @Jcarlier50
    @Jcarlier50 10 หลายเดือนก่อน

    Great video but ... do you have a video which explains the possibilities of the amazon players (echo**) I find this type of player very restrictive (no mp3 playback, no radio browser, not possible with chime tts etc) except perhaps with nabu casa. google player doesn't have all these problems

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Unfortunately, I don't...

  • @RMyren
    @RMyren 10 หลายเดือนก่อน

    When I started watching this video, I did not understand what to use scripts for, and I still don't🤷‍♂️

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +2

      You will overtime...

    • @RMyren
      @RMyren 10 หลายเดือนก่อน +1

      @SmartHomeJunkie I hope so. Your videos have helped me a lot, but they require that the watcher already know most of the basics, which I don't. Went from not having written a code in my life to a fully functioning HA setup in 3 weeks' time.

    • @gorgorgonzales3090
      @gorgorgonzales3090 10 หลายเดือนก่อน +2

      Once you have over 50 automations, that do almost the same thing you will lern to love scripts 😅
      I didn't understand what they were for in the beginning as well. But over time realized how much they help to keep everything clean and accessible, especially if switching devices later in your setup.. I just rebuilt my whole setup with using scripts and love how simple everything is now...

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      @@gorgorgonzales3090 Yes, you got it!!!

    • @FilipeNeto616
      @FilipeNeto616 10 หลายเดือนก่อน +1

      You will over the time. I use HA for almost two years, started automation only one year ago and I'm finally scratching scrips

  • @rickpoeling6831
    @rickpoeling6831 10 หลายเดือนก่อน

    I followed along in the steps and after I saved it and set up the automation it fired (I went to the trace) and it showed the following instead of the {{message}} and {{title}} that I had entered. I tried again and when I go back into the script and view in yaml, it has replaced what I typed with the following:
    service: notify.mobile_app_sm_s908u
    data:
    message:
    "[object Object]": null
    title:
    "[object Object]": null

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      No idea why you see that. It doesn't show that behavior at my side. 🤷🏼‍♂️ I guess you did something different than what I show in the video.
      The script shouldn't show the sequence in the visual editor at all. It should show that you cannot view the action in the visual editor

    • @rickpoeling6831
      @rickpoeling6831 10 หลายเดือนก่อน +1

      I see my mistake. I forgot to put those items in quotes. I can't believe I made that same mistake two times in a row. 😞

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      @@rickpoeling6831 I suspected this a bit already. Great that you found the solution!

  • @chimpsinties
    @chimpsinties 10 หลายเดือนก่อน

    I'm wondering why my HA doesn't allow me to "add fields" in the script like in your video

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +1

      Because you don't have the latest HA version 2023.11 installed...

    • @chimpsinties
      @chimpsinties 10 หลายเดือนก่อน +1

      @@SmartHomeJunkie You're right of course. Thanks for pointing that out. I use docker containers and the UI doesn't show there is an update. I forgot I have to pull it myself. Sorted now. Cheers

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      @@chimpsinties No problem!

  • @jfs43
    @jfs43 10 หลายเดือนก่อน +1

    Great lesson, this has got me thinking. However, I'm missing the 'Add Fields' option on my menu, why would that be?

    • @ZoomtronicBlogspot
      @ZoomtronicBlogspot 10 หลายเดือนก่อน

      I also have no add fields option

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      Are you using the latest version of Home Assistant?

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน +2

      It's a new feature since version 2023.11 of Home Assistant.

    • @jfs43
      @jfs43 10 หลายเดือนก่อน +1

      @@SmartHomeJunkie aha, thanks. I usually update in the middle of the month.

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      @@jfs43 No problem.

  • @sevagjb
    @sevagjb 10 หลายเดือนก่อน +1

    Thanks Ed let say this is lesson 1
    i will wait the lesson 2 🥰

    • @SmartHomeJunkie
      @SmartHomeJunkie  10 หลายเดือนก่อน

      What do you mean?

    • @sevagjb
      @sevagjb 10 หลายเดือนก่อน

      I mean, this is wonderful tutorial and I hope we can get more like this @@SmartHomeJunkie

  • @RobertoMello79
    @RobertoMello79 10 หลายเดือนก่อน

    Great video, as always :)
    When would you use Scripts instead of NodeRed?