Mastering Scripts in Home Assistant: A Comprehensive Guide

  Рет қаралды 47,384

Smart Home Junkie

Smart Home Junkie

Күн бұрын

Пікірлер
@simonknight2973
@simonknight2973 Жыл бұрын
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 Жыл бұрын
Awesome to hear!
@PosiCat
@PosiCat 5 ай бұрын
I was banging my head against scripts and return values, your video got my scripts working perfectly now thanks!
@nthomasaz
@nthomasaz Ай бұрын
I probably watched this a dozen times and finally got all three working! Thank you! I am now struggling with the next level, call the script, get the response_variable and now trying to call a script based on the value in the response_variable. If you want to do another video for this or help that would be awesome. example, response_variable returns the number of garage doors that are open. If none are open call script x and if one is open call script y etc... Thanks again.
@videomichel
@videomichel Жыл бұрын
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 Жыл бұрын
That's great to hear! 👍🏻👍🏻
@ricardoramirez-ue5li
@ricardoramirez-ue5li 10 ай бұрын
"Wife acceptance" is a fundamental variable in HA settings, lol
@jamesdavis-claydon8520
@jamesdavis-claydon8520 Жыл бұрын
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
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thank you.
@TheBroz
@TheBroz 9 ай бұрын
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 9 ай бұрын
That's awesome to hear. Have fun with HA! It's a rabbithole, but also a lot of fun.
@alexkerin3691
@alexkerin3691 Жыл бұрын
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 Жыл бұрын
That's awesome to hear!
@christophhulsmann7430
@christophhulsmann7430 Жыл бұрын
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 Жыл бұрын
Thank you so much for your compliment! 🙏🏻
@emms-place
@emms-place 3 ай бұрын
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 Жыл бұрын
Great video as per usual!!! Keep them coming.
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thank you Andrej! You're the best!
@PontusWelin
@PontusWelin Жыл бұрын
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 Жыл бұрын
Great to hear that it helps!
@esenterre
@esenterre 5 ай бұрын
You made simple explanations, easy to follow. Now it's time to see if I can make it work! Thanks!
@thehostler0
@thehostler0 5 ай бұрын
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.
@Rob_65
@Rob_65 Жыл бұрын
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 😀
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
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! ⭐
@GregGranito
@GregGranito 8 ай бұрын
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?
@johnnynobels
@johnnynobels Жыл бұрын
Thank you for this vety usefull tutorial. I didnt not know using parameters in scripts was that easy.
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Glad it was helpful!
@johnnynobels
@johnnynobels Жыл бұрын
@@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.
@bertrandmauge9832
@bertrandmauge9832 Жыл бұрын
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 Жыл бұрын
That's great to hear. Thank you for responding! 🙏🏻
@robhoogland01
@robhoogland01 Жыл бұрын
Great video. Good explanation. I will be going to use this for sure. Thanks, Ed.
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thank you for your kind words. This keeps me going! 🙏🏻
@kindred27
@kindred27 6 ай бұрын
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.
@EsotericArctos
@EsotericArctos Жыл бұрын
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.
@MrNetworkG
@MrNetworkG Жыл бұрын
Great video, more videos like this. Thank you, sir!
@hillstreesandstreams
@hillstreesandstreams 11 ай бұрын
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 11 ай бұрын
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.
@DavidWhatfor
@DavidWhatfor Жыл бұрын
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.
@tgf2004nl
@tgf2004nl Жыл бұрын
Briljante video weer, daar heb ik echt wat aan 🙂
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thx!
@alexicna92
@alexicna92 Жыл бұрын
Great video again ! So useful ! Thanks a lot.
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thank you for the compliment.
@janiguzhuni3490
@janiguzhuni3490 10 ай бұрын
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 😅
@MikaCinema34
@MikaCinema34 Жыл бұрын
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 Жыл бұрын
Thanks! I believe the Aqara FP2 has human fall detection. I did not test that feature though.
@sevagjb
@sevagjb Жыл бұрын
Thanks Ed let say this is lesson 1 i will wait the lesson 2 🥰
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
What do you mean?
@sevagjb
@sevagjb Жыл бұрын
I mean, this is wonderful tutorial and I hope we can get more like this @@SmartHomeJunkie
@Superawesomeduckface
@Superawesomeduckface Жыл бұрын
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 10 ай бұрын
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
@squalazzo
@squalazzo Жыл бұрын
great content as always, thanks!
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Glad you enjoyed it!
@adamg3402
@adamg3402 10 ай бұрын
Dziękujemy.
@JohanVromans
@JohanVromans Жыл бұрын
Good job (again)!
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Thank you! 🙏🏻🙏🏻🙏🏻
@jfs43
@jfs43 Жыл бұрын
Great lesson, this has got me thinking. However, I'm missing the 'Add Fields' option on my menu, why would that be?
@ZoomtronicBlogspot
@ZoomtronicBlogspot Жыл бұрын
I also have no add fields option
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Are you using the latest version of Home Assistant?
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
It's a new feature since version 2023.11 of Home Assistant.
@jfs43
@jfs43 Жыл бұрын
@@SmartHomeJunkie aha, thanks. I usually update in the middle of the month.
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
@@jfs43 No problem.
@Mr-Coke
@Mr-Coke 10 ай бұрын
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?
@davidfarrell1062
@davidfarrell1062 Ай бұрын
Is it possible to add strings like these to a template like you create so information appears in the message. %device% , %value% , %text% , %time% , and %date% Other platforms used this approach but cant see it in home assistant. Dont want just prefilled text. Want to see the value and time etc.
@psylenced
@psylenced Жыл бұрын
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 Жыл бұрын
Thanks. It's just an example... This video is not about how to create perfect template code, but on how to use scripts...
@bgable7707
@bgable7707 4 ай бұрын
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.
@serichard
@serichard 8 ай бұрын
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 11 ай бұрын
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']
@RobertoMello79
@RobertoMello79 Жыл бұрын
Great video, as always :) When would you use Scripts instead of NodeRed?
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
Always 😉
@Wimpieseigen
@Wimpieseigen Жыл бұрын
Thanks
@gumbypokey7
@gumbypokey7 Жыл бұрын
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 Жыл бұрын
There will be some modifications in the next release of HA already. But, YAML is not that difficult imho.
@metoo7587
@metoo7587 7 ай бұрын
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 7 ай бұрын
It's a challenge indeed, but the functionality should still work because the YAML does not change.
@metoo7587
@metoo7587 7 ай бұрын
@@SmartHomeJunkie Hi, I found my error. I had overlooked the piping symbol in the script. A small, but oh so important detail. 😶
@metoo7587
@metoo7587 7 ай бұрын
@@SmartHomeJunkie Well, now I get "Error: Service response data expected a dictionary, was
@syukrishahabuddin4618
@syukrishahabuddin4618 Жыл бұрын
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 Жыл бұрын
Interesting. Can you elaborate on your use case?
@syukrishahabuddin4618
@syukrishahabuddin4618 Жыл бұрын
@@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 Жыл бұрын
@@syukrishahabuddin4618 I'm not aware of a chat functionality like this in HA.
@jamesdavis-claydon8520
@jamesdavis-claydon8520 Жыл бұрын
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 Жыл бұрын
Yup. According to the error message you most likely made a mistake in your template code. You do have Openweathermap installed, right?
@Dendee2
@Dendee2 Жыл бұрын
What's the name of the panel in the back that says Please subscribe? Is it also connected to HA?
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
It's this one: This is the BEST MATRIX DISPLAY CLOCK for Home Assistant! kzbin.info/www/bejne/hGGxfIOAr6x7q6M
@Dendee2
@Dendee2 Жыл бұрын
Thanks this is exactly what I was looking for the last few weeks 👍🏻
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
@@Dendee2 That is great to hear!
@Raymond.Jansen
@Raymond.Jansen Жыл бұрын
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 Жыл бұрын
I'm not sure what you mean.
@Raymond.Jansen
@Raymond.Jansen Жыл бұрын
@@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 Жыл бұрын
@@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 Жыл бұрын
@@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!
@pickachublast8
@pickachublast8 16 күн бұрын
I wish I knew this sooner before I made all these automations >.
@SmartHomeJunkie
@SmartHomeJunkie 13 күн бұрын
I feel you! We’ve all been there. Just chalk it up to experience and keep pushing forward! You got this!
@pontuslandin6883
@pontuslandin6883 5 ай бұрын
It is awesome to see that there is so much left to learn in HA. It’s a deep hole 😂
@metoo7587
@metoo7587 7 ай бұрын
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 7 ай бұрын
Might be a setting on your phone. 🤷🏼‍♂️
@Jcarlier50
@Jcarlier50 Жыл бұрын
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 Жыл бұрын
Unfortunately, I don't...
@RMyren
@RMyren Жыл бұрын
When I started watching this video, I did not understand what to use scripts for, and I still don't🤷‍♂️
@SmartHomeJunkie
@SmartHomeJunkie Жыл бұрын
You will overtime...
@RMyren
@RMyren Жыл бұрын
@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 Жыл бұрын
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 Жыл бұрын
@@gorgorgonzales3090 Yes, you got it!!!
@FilipeNeto616
@FilipeNeto616 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@rickpoeling6831 I suspected this a bit already. Great that you found the solution!
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 101 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
Templates and Custom Sensors in Home Assistant - How To TUTORIAL
30:09
Smart Home Junkie
Рет қаралды 147 М.
Create a Pro-Level Dashboard in Home Assistant!
17:40
Smart Home Junkie
Рет қаралды 118 М.
Shelly Wall Display vs Sonoff NS Panel Pro for Home Assistant Dashboards
11:33
Dynamic Home Assistant Dashboards
17:00
Home Automation Guy
Рет қаралды 61 М.
How to use Trigger IDs in Home Assistant - Tutorial
13:15
Smart Home Junkie
Рет қаралды 66 М.
Scenes on Steroids in Home Assistant - How To - Tutorial
13:42
Smart Home Junkie
Рет қаралды 39 М.
5 MUST HAVE SCRIPTS for Home Assistant (Coding Tutorial)
16:24
Smart Home Makers
Рет қаралды 48 М.
5 ways Presence Detection makes Home Assistant Smarter
8:59
SlackerLabs
Рет қаралды 16 М.
Room presence detection with Bermuda BLE and ESPHome
14:33
Home Automation Guy
Рет қаралды 25 М.
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 101 МЛН