Phillips Hue Lightstrip Change Color During Meetings

November 16, 2020

Overview

This post will cover how to set up a Phillips Hue Lightstrip to change color automatically to red during a meeting, and green when not in a meeting.

Required Materials

  1. Phillips Hue Lightstrip
  2. Phillips Hue Smart Hub

Prerequisites

  1. nodejs and npm
  2. Command line git
  3. Computer with Mac OSX Catalina

Installation

My instructions will walk through setting up the script at the following location:

$HOME/Library/cron

If you place your script at a subdirectory of $HOME/Documents you will have to add permissions for cron to access all files and folders via system preferences.

Downloading and connecting to the hub

We will be using phillips-hue-experiments by Armando Magalhães to connect to our hue smart hub.

Download the code to $HOME/Library/cron

mkdir -p $HOME/Library/cron
cd $HOME/Library/cron
git clone https://github.com/armand1m/philips-hue-experiments
cd philips-hue-experiments
npm ci

Setting up your API key

In order to make calls to Philips Bridge, you need to authenticate your device.

Keep in mind you need to press the button in Philips Bridge before running this command in order for it to work (you’ll have an error message telling you to do so, if you forget to do this).

npm-run-register-user.gif
npm-run-register-success.gif

Storing your API key

Once you obtain your API key place it file $HOME/.hue like this

PHILIPS_HUE_USERNAME="<FULL KEY GOES HERE>"

Setting up the Meeting Checker

Download the code to check if a meeting is running and change the color of the light

cd $HOME/Library/cron/philips-hue-experiments
curl -L -O https://gist.githubusercontent.com/ssstonebraker/fb808b27a688cacabcaca60289f12a59/raw/b5ab6578499ab6cc7b219b76ee923fd439577dfd/hue.sh
sudo chmod +x hue.sh

Meeting Checker Code Details

The code will check if the GotoMeeting, Zoom, Teams, or WebEx teams process is running.

If true the light will turn red:

If false, the light will turn green:

Known Issues

Right now the code will attempt to change all lights connected to the hub to either red or green

Running the Code Every Minute

To run the code every minute you will need to modify the crontab

Opening the Crontab

Specify your preferred editor via the EDITOR variable, then open the crontab via ‘crontab -e’.

Example:

export EDITOR=nano
crontab -e
 

Modifying the Crontab

To run the script every minute, add the following code at the bottom of the crontab:

* * * * * . $HOME/.bash_profile; cd $HOME/Library/cron/philips-hue-experiments && $HOME/Library/cron/philips-hue-experiments/hue.sh 2>&1 >> $HOME/Library/cron/philips-hue-experiments/log/hue.log
@daily /bin/echo "" > $HOME/Library/cron/philips-hue-experiments/log/hue.log

Code can also be found here:

https://gist.github.com/ssstonebraker/0a2c372c36b0b0efdbf24fde67be9091

Debugging the Crontab

You can use mail and console.

mail

Crontab messages can be found by running the “mail” command from the terminal. You may see a message that reads:

Failed to run operation "set color to 'weird green (#42f581)'": { Api Error: parameter, xy, not available

That is okay as long as your light strip is still changing color. That message means that the app tried to change the color of lights on the hub that did not have that ability.

console

Open the console.app and search for the word "hue" to find any permissions related issues to our hue app.

You can launch the Console app from Spotlight by pressing Command+Space and searching for it, or from the Utilities folder in your Applications directory. (Open Finder and select “Applications” to find it.)