In my hallway there are a few Phillips Hue White and Color Ambiance Bulbs that I’ve had some fun with the last couple of years. Originally automated through IFTTT, they change color if one of my favorite football teams play a match. This has been working well for quite some time, but with IFTTT recently starting to limit the amount of Applets you can create, and the fact that they only run every 15 minutes, I decided to try and emulate the functionality I used with Home Assistant and Node-RED instead.
This series of posts is not intended to be a Node-RED and Home Assistant 101 introduction. There are other resources for that readily available, that does a very good job at explaining how to get up and running:
My Workflow description #
- Check a calendar for match events
- When a match starts, change the light color to the correct RGB value
In order to get this working, there are a couple of Home Assistant Integrations and Add-ons that needs to be installed and configured:
Of course, I also need the fixture lists available in Google Calendar, which is easily done by subscribing to publicly available calendars. fixtur.es takes care of that part, and seems to be doing a very good job at updating the calendars if there are changes. I based my previous IFTTT workflows on the same calendar, and it has worked well for years.
Once the calendars are available in Home Assistant, you can start automating based on the events in them.
My final workflow looks like this:
Node-RED and Home Assistant Workflow Walkthrough #
1. Trigger: State Node
First there is a Trigger: State Node that checks the corresponding calendar for events
Name is my given name for the trigger. Server is Home Assistant, and the Entity ID is the device_id name given for the calendar in it’s configuration in google_calendars.yaml, prefixed by calendar. In this setup, the entity id is calendar.liverpool.
- cal_id: firstname.lastname@example.org
- device_id: liverpool
name: Fixtures Liverpool
The way the calendar integration works, is that if there is an event in calendar.yourname, its state is on. If it’s on, there is a match, so we can work from that.
2. Call Service Node
The next is a Call Service Node, that calls a service within Home Assistant, to make something happen.
Name is once again the name I gave the it, Server is Home Assistant. Since we’re changing a light, the Domain is light, the entity id is the light or group of lights in this case (these bulbs are grouped in Home Assistant to one group light.hallway) and the Service we want to call is turn_on. The turn_on service works even if the light is already on, so there is no need to create any logic around checking if the light(s) are on or off before sending data to them. The “magic” here is within the Data field, which is where the payload we send to the Hue integration is stored.
In this case, I want to change the light color, and brightness, so the JSON contained in the data field looks like this:
Liverpool FC #
This sets the color to the RGB value of 208,0,39, and maximum brightness of 255.
Since this example uses the Liverpool FC calendar, I picked the RGB value for the light from their official logo. I did the same and use a different color value for for the SK Brann trigger:
SK Brann #
Once all the different nodes are configured, it’s just a matter of connecting them together to create a full workflow. The top most connector on the node, is the one that gets triggered when a calendar event is “on”, so in this automation I have only connected an action there.
If there is nothing in the calendar, I don’t want to do anything so I leave that as is.
Duplicate this for any other calendar events, and / or colors you want, and that’s it.
In the screenshot above, there is also a Debug Node connected, just to make sure I catch debug data when the events trigger.
I am sure there are loads of other use cases for calendar based automation in Home Assistant and this might perhaps not the most useful automation ever, but it is a fun one! There are probably many other use cases for this as well, like doing special lighting for your spouse or kids birthdays.
- How I Use Home Assistant: Part 4 — Automatically Enable and Disable Sonos Night Mode with Node-RED — Published
- How I Use Home Assistant: Part 3 — Morning Coffee — Published
- How I Use Home Assistant: Part 1 — My Setup — Published
- Casting Home Assistant Dashboards to Google Nest Hub 2nd Gen — Published
- Combined Pi-Hole Statistics in Home Assistant — Published