Google Calendar and “On Air” Light
I have been working from home for quite a long time and with me being in a small box room as an office there is no way for anyone outside the room to know if I am in a meeting or not, so I wanted to set up something simple that would alert people whether I was in a meeting or not.
I have a lot of hue bulbs in the house and I also use home assistant, and that is more than enough to get something configured.
The aim is to have Home Assistant access (read only) my work google calendar, and when a calendar event triggers it turns on a light to a specific colour. When the event no longer exists then turn off said light. Also, would it be possible to have a Lovelace card on a dashboard that shows the current meeting name and/or when the next meeting is?
Before starting, I will mention that some of what I configured was thanks to https://smarthomepursuits.com as there is not many guides out there for this.
With that intro done let's get stuck in.
Configure Home Assistant to be able to access your Google Calendar.
The easiest way to do this is to follow the instruction on the home assistant integration page, link is here: https://www.home-assistant.io/integrations/google/
With the integration set up and configured you should have a google_calendars.yaml
file. You can edit configuration files on Home Assistant by adding the File Editor from the Add-On store.
Inside this file it should look similar to this
- cal_id: [email protected]
entities:
- device_id: email123_gmail_com
ignore_availability: true
name: [email protected]
track: true
max_results: 42
If that is looking good, on the sidebar you should now see a new addition
That should take you to a simple monthly view with all your calendar entries.
This means you have configured the integration correctly, and it is pulling events from the Google calendar API.
The entity created will have a state of ON when an event is scheduled and OFF when there is no event scheduled. With that known the rest of this is a little easier.
The last bit is actually setting up the automation. The automation below is quite simple. It will turn a light bulb on and set it to red. You can set whatever colour you want, I found red to be a colour which catches my eye and as such I will notice it. Remember to edit the device IDs and entities.
alias: Meeting Active
description: ''
trigger:
- platform: state
entity_id: calendar.my_calendar_entity
to: 'on'
from: 'off'
- platform: state
entity_id: calendar.my_calendar_entity
from: 'on'
to: 'off'
condition:
- condition: time
after: '09:00:00'
before: '17:30:00'
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- choose:
- conditions:
- condition: state
entity_id: calendar.my_calendar_entity
state: 'on'
sequence:
- service: light.turn_on
target:
device_id: device_id
data:
color_name: red
default:
- service: light.turn_off
target:
device_id: device_id
mode: single
I have found that at the end of the day the last known state of the bulb is red, so I have a second automation which turns it on for 2 seconds to a warm white and then turns off. There is probably an easier way to do this in the previous automation but for simplicity I chose this way. Remember to edit the device IDs and entities.
alias: Reset Desk Lamp After Work Hours
description: ''
trigger:
- platform: time
at: '17:31:00'
id: reset_light
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
after: '17:30:00'
action:
- service: light.turn_on
data:
color_temp: 370
target:
device_id: device_id
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- type: turn_off
device_id: device_id
entity_id: light.light_entity
domain: light
mode: single
The next part is to actually put this automation into something pretty like an on air light box, old school radio station style, but for now it helps a lot to have this simple automation.
I will add that there is more tweaking that can be done like for example selecting only certain events based on the name, but that may be for another day.
Lovelace Card Bonus
This bit was with a lot of help from the Smart Home Pursuits blog. But this is what the Lovelace card looks like and also the YAML for it.
That is it, the below Lovelace cards do require extra plugins which you can get from HACS.
Open HACS > Integrations > frontend tab.
Add Multiple Entity Row and Vertical Stack in Card:
type: entities
entities:
- type: custom:multiple-entity-row
entity: sensor.next_work_meeting_date
image: /local/icons/pug.png
name: Next Meeting
secondary_info:
entity: sensor.meeting_name
name: false
title: Work Meeting
type: custom:atomic-calendar-revive
entities:
- entity: calendar.<email-address>
titleColor: red
name: Calendar Card
enableModeChange: true
firstDayOfWeek: 1
maxDaysToShow: 7
refreshInterval: 60
dimFinishedEvents: true
calShowDescription: false
defaultMode: Calendar
showDeclined: false
sortByStartTime: true
hideFinishedEvents: true
showDate: true
Have a go and see what you create
Round Up
My goal for this tiny project was to make a visual notification of when I was in a meeting, it may be simple but has turned out to be very effective with the family who now know when I am in a meeting. Next up on my list of tasks will be working on furthering this automation to add more logic and make it pretty.
This will involve things along the lines of an old school On Air box outside the room, and/or different colours and intensities depending on meeting importance.