Setting up scripts and automations
Okay tough guy, are you’re frontend in a better shape and you are now ready for some extra laziness in your life? Well here’s some pointers to get you in right direction.
There are multiple ways to set scripts and automations up, I’m just covering basics of it so you can hopefully understand and make great stuff for your castle.
Okay for starters we need to know what we are gonna to make. It can be anything from turning all the lights to red and put on your’e A-game playlist on the stereo to get you better half in a jazzy mood or lock your house down, maybe both perhaps? As said earlier, only your creativity stops you here, hopefully.. I will go easy on you for now.
Setting up your first script
First thing we need to check is if scripts are enabled in configuration.yaml. Easiest way to find out is to search after «script:» and make and include of a new file
(as mentioned earlier, this gives you more overview of your application).
Allrighy, then we are one step closer to our first script. I’m now going to show you an example of what I’ve used several times to make peace in the house (run a YouTube video via ChromeCaster). I have a daughter at the age of two soon so this feature is still quite handy even though its been the same video over and over and over…. This feature is extra awsome if you can set your TV to turn on when it detects signal from the HDMI and change to right source.
This file should be pretty empty if this is your first script, so this is what I’ve implemented:
Ok cool, but how does it work?
I will try to explain how this is working line by line:
youtube_fantorangen – name of the script
alias – a description of what the script does (not required)
sequence – starting to define what the script is supposed to do
service – what service we want to call, here I’m using Media Extractor which is the one to get the video from YouTube and send it to the ChromeCast.
entity_id – what entity we want to use (still the ChromeCast)
data – what we are going to send to the entity, here were saying that its a youtube video and a specific link
So i can start use it now?
You may need to restart your home assistant first to get access to the script, and then you should be ready to start using the script.
How do I use it?
There is multiple ways to start the script. I’m using a custom card called Mini Media Player wich is very cool and let you easily set up a card with your media players (ChromeCast, Google Home, Spotify and so on). It’s worth a visit and installation of the card.
In this card you get access to the media player device info, toggle function (on/off), media controls, and you can set buttons for shortcuts. In this situation I’ve set a shortcut for my youtube_fantorangen script. And voila, a fast way to get your kids quite in a rush! 😀