In this video we're going to have a look at scenes in Home Assistant - what they
are, and how you can make the most out of them. Make sure you stick around, and if
you like what you see make sure you hit subscribe below so you don't miss out on
future videos.
Hi I'm Will from Will Surridge Tech, and in this video we're going to be looking at
scenes - different ways we can set them up and trigger them or even automate them.
Now if you stick around until the end I'm going to show you how you can run
effects on your hue light bulbs in node-red. So let's get going! First of all, what is
a scene? Well a scene is a way of capturing multiple states of multiple
devices in one place. Do you find yourself, when you go to dinner, always
having to turn the same lights off, the same lights on, and constantly playing
the same music, or turning the volume to the same level - well all of that can be
captured in one single scene; so you just have to press one button it all happens
for you. There are two main ways of achieving this effect in Home Assistant -
you either use the Home Assistant scene functionality, or you create an automation
using the Home Assistant automation features, or node-red; or you could use a
combination of the two to create an ideal scene. Let's have a look at the
pros and cons of each method. Using the scene function is a very easy way to
create a simple scene - you just put your entities in put the data that you want
your entities to abide by and that's it. The problem with the scene function is
you can't do anything complicated - you can't put any delays in for example, and
you can't put any conditions in - so you might want some things to happen but
only if it's something else; for example if you're watching a film you might want
the heating to come on but only if the room is below 17 degrees. This is where
automations come in. With automations you can include conditions and timings; for
example your dining room curtains might only want to shut if it's dark outside.
The beauty of an automation is you can include a scene in it, so you can create
a scene that sets up your lighting state, and then use the automation to change
the conditions for your curtains for example. It's a great way to use both
together to create the same effect. The first thing I recommend you do when you
start out making scenes is to write them all down. This doesn't have to be
anything fancy, but just writing down what you want to happen, any conditions
you want, and then any settings you want each device to have, is a really easy way
to keep your workflow organised - it means you can make sure you're achieving
everything you to achieve with the right conditions at
the right time. These are the scenes that I'm going to be using today as my
demonstration. As you can see most of my scenes are just using media players and
lights, but you can use any entities that you have and you can use any sensors you
have with your conditions if you want. With the built-in scenes and automations
features you can either create them using a visual editor or in the yaml. If
you create it using a visual editor, it will then appear in that yaml later if
you want to go and edit it there. So let's start off creating the dinner
scene in the visual scene editor. All we have to do is add all the entities that
we want to control in our scene. This is really easy, and then we click on each
entity and set it to what we want it to be, for example turning the lights on to
a certain colour temperature, or a certain colour. Unfortunately because of the way
some things are integrated, for example the Sonos, we can't have full
functionality. For example I can't actually select a correct playlist in
this scene so I've got to select a playlist in my app and then it will
transfer over and once that's done I can just save it. I also can't force the
Sonoses to not be grouped at this point - another downside of using the scenes
integration. Once we're happy, we click Save. This will create a scene entity
that we can then trigger directly - which is a great bonus of the scenes editor. If
we want a bit more control then we can use an automation. The main difference
between a scene and an automation is an automation needs a trigger. This could be
the time of the day, a specific sensor reaching a certain point, or just a
manual button. It's not really a problem, because if we just want it to be a
manual button, then we can create one using an input boolean. I'm going to do
that now for the three scenes that I'm going to create today. This is very easy
to do - we just go to our configuration file and add a new input_boolean. As you
can see I've got mine referenced elsewhere, so we're going to go into that
file and add some more input booleans. We give it a name, an icon, and a title. We're
also going to want to set the initial to off. That means that if you restart Home
Assistant it won't turn on automatically; otherwise that would trigger all your
scenes in one go which isn't very good. Now we can create the automation. We're
going to start off using the automation visual editor.
I don't use this myself because I think there's much more capability in node-red,
but we'll give it a go. As I said you start off with a trigger - this is going
to be our input boolean going from off to on. We can then ignore the conditions
and start adding all our entities. If you use device as the action type, then you
can only set the brightness of the light. We want to have more control - we want to be
able to control the colour, and the colour temperature, and other things potentially.
So we're going to use the call service type instead. In here we can add the
service data for all our brightnesses, our colour temperatures, and that kind of
thing. It gives us much more flexibility. As you can see you can also trigger a
scene here, so maybe you might set up your light state in a separate scene
that you can recall in multiple different automations, and then you
recall that here with some other devices with other features instead. This is how
you can combine both scenes and automations into one. For some reason
this automation isn't actually working, and because I don't actually need it to
work because I much prefer to use node-red we're just going to ignore that. But this
does give us an excuse to give up on this method and move on to node-red
instead. As with normal automations you can control scenes and devices in node-
red. But the added benefit of node-red is palettes - you can download certain
palettes with certain types of devices which give you direct control of the
device API - this means you have much more precise control and more functionality.
I have palettes for my Evohome setup, my Hue lights, and my Sonos speakers. So
let's start off by making the dinner scene. First of all I'm going to label
this scene so I know what the flow's for. Next up, we're going to set the
trigger as the input boolean. What we're going to need to do, is turn off the
input boolean so it's ready for use next time, but I'm going to add a little delay
so I can be sure that the scene has triggered before it turns off again,
otherwise you wouldn't see that you've triggered the input boolean. Next up we
can start adding some entities. First we're going to control the main lights - I
have a dinner scene set up in my hue app so I can use one of the hue nodes in the
palette to control this and trigger it directly. Equally if you had a scene set
up in the normal scene section of Home Assistant you could trigger that using a
call service, or if you don't you can just trigger
each light individually using the call service nodes. Once we're happy that the
main lights done, we can control the other lights. I'm going to control these
using a call service node, entering the brightness and the colour of each light.
The great thing about this you can add multiple entities to one call service, so
I'm going to control the left kallax lights and the right kallax lights in one node. This
reduces the number of nodes you need and makes things a lot more streamlined and
efficient, and it means you're sure that both lights are going to do the same
thing. Now we can do the music I'm going to use a selection of Universal Sonos
nodes from the Sonos palette to do this. I don't really understand how these
workers - they've got recently updated the palette; but using some examples they
give you it's quite simple to follow. What we want to do is make the kitchen
and the dining room leave any groups they're in. We're going to pause the music
in the kitchen, we're going to clear the queue in the dining room, and then add a
certain playlist as a new queue using the My Sonos node, and then we want to
play that queue. We're also going to want to change the volume so it's nice and
quiet. If that works we can move on to the film scene. This is the same
principle again - we have an input boolean and we turn it off after 10 seconds; we
have a selection of call service nodes for various lights and various devices,
and we have a Hue node for the Hue lights. We also stopped some Sonos music
playing that might be distracting. Now we can move on to the heating. I'm going to
have a condition in my heating that if the temperature is below 15 degrees then
I turn the heating on to 21 degrees. To do this we're going to use a get state
node to get the state of our climate, and then a conditional node to switch it so
if it is above 15 degrees it triggers the next node and if it's not then it
doesn't. So in the next node we're going to use a call service for the climates
and set it to 21 degrees. It's very simple and easy to follow using this
method of node-red. Lastly we're going to have a call service node to turn on the
TV. We can link it up and test it out. If it works then we can move on to any
other scenes that we want to create and we can just keep going - the possibilities
of node-red are endless. I said show you how to run effect on your hue light
bulbs, so here we go! We're going to be using
the hue palette for this - we're going to need a trigger which can just be an
inject node, or whatever else you want to use, the Hue magic node and a Hue bulb
node. You set the bulb to the bulb that you want to trigger, link it all up, and
then you can select the animation in the Hue magic node. For this example I'm just
going to use the fireplace as a demonstration but there are plenty to
choose from - for example you could use the sunrise node and integrate it into your
alarm sequence; so every morning your lights come on with the sunrise - wouldn't
that be a great little feature to have. If we link it up, we can test it out and
see that our flickering is happening on our light bulb. And there we go - we've had
a look at multiple ways of setting up and triggering different scenes. Make
sure you hit subscribe below to find out more about my smart tech, and how you can
build yourself the ultimate smart home!