We’ve walked through the build of Home Assistant, we’ve talked through the basics, now let’s focus a little on what most people will be doing in their Smart Home – Lighting and while we’re at it, talk through some handy automations.
Whether you’ve decided to go down the Philips Hue bulbs, whether you’ve gone all in (as I have) with Shelly in-switch relays, or spent big with Lutron switches then you’ll want to try and get building those automations and getting smart with your lighting.
I want to use this blog to talk through some of the common scenarios and automations that you can set up, but also a little around the dashboard and the options within there too. So let’s get started…
Grouping Lights
Whether you decided to install a load of Hue bulbs, or whether you’ve got a large room (e.g. Kitchen/Diner) and you have different ‘zones’ of lights – this is a pretty common scenario as you may want them all to switch on together.
Helpers
Home Assistant allows you to do this in a few different ways, first up are helpers. Once you have your switches or your bulbs in HA, and you have entities for them – go into Settings > Devices and Services > Helpers.
In the bottom right hand corner, it’ll allow you to create a helper for many different things and believe me, these are super powerful. But for now, select Group and then choose your entity type (this could be a switch or a light, depending on your device) and then give the group a name and add your entities. You can then add that group to a dashboard, an automation – anything. You can pretty much treat it as you would do any entity.
Labels
Labels are a pretty new feature to Home Assistant, only being introduced early in 2024, but boy are they useful. As the name label kinda explains, the feature lets you ‘label’ any entity, irrelevant of entity type. So, let’s say you want to label all switches, bulbs, lamps, and just call them Lighting, then you can.
To create a label, go into Settings > Areas, labels and zone
Click across to the Labels tab at the top.
Click on the ‘Add Label’ button on the bottom right
Once its created, you can go into either Devices or Entities, click the ‘select button’ on the top left corner (to the right of the filter button)
Select the ones you want and the press the add label from the notification bar at the top.
The video below probably explains it far better:
Physical Switch turning on Automations
This is a kinda cool feature of having a full integrated Smart Home. If you’ve got a physical switch in your home, that you’ve made ‘smart’ either by using a relay (i.e. a Shelly or Hue) or a smart faceplate (Aqara, Lutron, etc) then you can then use it to turn on any other device with a simple automation.
My scenario is pretty simple. I have an internal switch (which I made smart using a Shelly 1PM) which turns on 2 outside lights in my back garden. I also have some lights, to make the garden look ‘pretty’ (Quote wife, 2023) that are plugged into an outside double plug socket. I swapped that plug socket for a smart one, so both plug sockets show up as entities. Because of that, I can do these automations:
or if you’re a YAML kinda guy or gal:
alias: "Action: Back Garden Light Sync"
description: ""
trigger:
- platform: device
type: changed_states
device_id: 4ec8b8293d84e19c9a6e3ad7ea2b1a98
entity_id: switch.shelly1pmmini_6055f99ef9c8_switch_0
domain: switch
condition: []
action:
- service: switch.toggle
metadata: {}
data: {}
target:
entity_id: switch.outside_plugs_switch_2
mode: single
Essentially, anytime that physical switch is toggled, it will toggle the power to the socket on the outside socket, essentially turning them on at the same time. So simple, but works perfectly.
Integration into Elgato Stream Deck
Now we should talk about what I do at my desk too – cause to be fair, I spend most of my time sat at it! Turns out there is an integration into Home Assistant – so next we will cover how you set it up and how I’m using it.
There is an assumption here, that you have your Stream Deck set up already and are familiar with setting up new actions. On the Elgato Marketplace you can find the Home Assistant Plugin here.
Once that has been installed, there are further details on how to set it up here, but in short you essentially need to provide a URL and a access token.
URL should be in the format: ws://ipaddress:8123/api/websocket
The access token can be created by clicking on your name in the very bottom left of HA, and clicking on the ‘security tab’. Scroll to the bottom and you’ll see a section for ‘Long-Lived Access Tokens’. Create one there and paste it into your config in the Stream Deck config. From there you’ll be able to see your entities and actions applied to them.
I have an Elgato Key Light Air (Link) which I’ve added to my Home Assistant, its essentially a wifi connected light. From Home Assistant (and also from the stream deck) I can choose to turn it off and on. To those of you saying – why not just add it directly to Streamdeck, as they are both elgato products – you are completely correct, but I like to makes things more complex 😉
Parameter-based Lighting
I couldn’t think of a better name for this section, but essentially, in my office I have a number of smart products:
- Elgato Key Light Air
- Aqara Motion Sensor P2
- Aqara Light Switch H1
- Aqara Roller Shade Drive E1
The key to the automations in this room is the motion sensor. Why you ask? Well because not only can it detect motion, but also Illuminance, the measure of how much light is landing on a surface, or in this case the sensor in the little battery powered Aqara device
You see, with this, I can automatically turn on my light when it detects movement, but let’s be honest, we don’t want the light on in the height of summer when it doesn’t need to be on, so we add a little bit of intelligence to the automation. This does take a bit of playing round with to get the right luminiscence that triggers it (everyone is different right?).
alias: "Action: Office Light on"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.office_sensor_motion
to: "on"
condition:
- type: is_illuminance
condition: device
device_id: cf5fef86bcd025b9ea20029c8acd0222
entity_id: 4182ee56d60328386f3adf4fe26cf153
domain: sensor
below: 120
action:
- type: turn_on
device_id: cd72a23f4996c9c1df47e565a7277b2a
entity_id: aa9635714b111c0e12d458d4f977f9a5
domain: switch
mode: single
Now if even if you didn’t have the motion sensor, if you correctly entered your location during the HA setup, it will know when the sun rises and sets. Which means you can do an automation that only turns the light on if it detects motion AND if its after sunset and before sunrise. That would look a bit like this:
alias: "Action: Office Light on"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.office_sensor_motion
to: "on"
condition:
- condition: sun
before: sunrise
after: sunset
action:
- type: turn_on
device_id: cd72a23f4996c9c1df47e565a7277b2a
entity_id: aa9635714b111c0e12d458d4f977f9a5
domain: switch
mode: single
Obviously you need to create an automation to turn your light off, or you could be old school and use the light switch!
Night Time Mode
In my house, I’m always the last awake – so it falls on me to ensure everything turned off – lights included. Now, this is the world’s most simple thing to do in the world of Home Assistant. I could just either set up an automation based on a set time to turn off all the lights. But what if I am awake late for some reason, well I automated that too!
I could of cause create an action that I need to press before bed that turns everything off, but if I’m honest, I’d probably forget to press it. So I thought of my bedtime routine (I know too much info right?)
I (like many), put my phone on charge when I go to bed, sadly the charger isn’t smart but if that charger is plugged into something smart like a plug, and that plug can report back increases in power then… I think we got something here.
alias: "Action: Night Lights Out"
description: ""
trigger:
- type: power
platform: device
device_id: c6e35c71a41e5a7654534d5e40e2718e
entity_id: 0596e757289e6be4a5712b9a63182523
domain: sensor
above: 8
condition:
- condition: time
after: "22:30:00"
before: "07:00:00"
action:
- service: switch.turn_off
target:
label_id: lighting
data: {}
mode: single
Worth noting a little ‘quirk’ here, the “after:” switch only works till midnight so by putting a “before:” ensures that the automation will still work if I don’t put my phone on charger until after midnight.
I think that probably covers a few nice automations and things you can do with smart lighting in Home Assistant. As always, if you’ve got any cool automations or ideas you want to share, I’d be happy to see or work on one 🙂