Philips Hue

Pierre Kil edited this page Jan 13, 2017 · 7 revisions
Clone this wiki locally

Philips Hue is the lighting system of Philips which enables remote control of lamps, led strips, and luminaires. You can choose between a wide spectrum of color temperatures as well as full RGB, and there is an extensive range of applications made by the community. When integrating Philips Hue with OpenRemote, you gain a customizable user interface and also an ability to control Philips Hue from existing automation systems such as KNX, Z-Wave or EnOcean. This way you can integrate Philips Hue into your home automation system.

Introduction

The Philips Hue comes with an Ethernet bridge that allow you to connect to Philips SmartLink products. OpenRemote allows you to control basic lighting functions: switching and dimming, color setting, and saturation. This document describes how to integrate OpenRemote with Philips Hue using the low-level HTTP interface.

IMPORTANT NOTE: Successful integration of OpenRemote with Philips Hue currently requires an "ORCJAVA-400" patch in OpenRemote controller. A binary version of the OpenRemote controller with the patch applied is available here: OpenRemote-Controller-2.1.0_FM_ORCJAVA-400.zip.

As of version 1.0.12, the Pro version of the controller includes the required patch.

This patch disables the use of informational client-side "Expect: 100-continue" request header which causes issues with the web server embedded in the Philips Hue Bridge. This patch will be later merged to OpenRemote release binaries.

Hardware

To integrate OpenRemote and Philips Hue, we have tested the products listed in the table below.

For a complete setup, you will need:

  1. A Philips Hue bridge with three lamps
  2. OpenRemote Controller installed on your PC, RPi, NAS, etc.
  3. OpenRemote Designer Account
  4. A web browser, Android or iOS device for control
  5. Additional automation controls for lighting, curtains, switches, etc.

Philips Hue - table1

Configuration of System

This describes the configuration in case you have both the Philips Hue bulbs and the Philips LivingColors

1.) Terminate all Philips Hue Apps The Philips Hue app must be terminated on all devices (iPad / iPhone / iPod / etc.).

2.) Reset Bridge and LivingColors remote control Reset the bridge by pressing the reset button on the bottom of the bridge. Reset the LivingColors remote control by simultaneously pressing 0 and * (a small star to darken) for 5 seconds.

3.) Link the LivingColors remote control to the bridge To link the "fresh" LivingColors remote control to the bridge, first press the front button on the bridge. Than press both the ON button (I key) + Scene1 button (the single point) simultaneously on the LivingColors remote control until the button of the bridge no longer lights up blue.

4.) Link the LED lamps with the LivingColors remote control Link the LivingColors remote control one-by-one to all the devices by pressing the I key on the remote while holding it near to the first Hue bulb or LivingColors until the LED-/LivingColors-Lamp blinks 3 times. Repeat it for all Hue bulbs and LivingColors.

5.) Link the LivingColors remote control to the bridge When all lights are linked, bring the LivingColors remote control back to the bridge. Press the front button on the bridge. Press the ON button (I Key) on the remote control, until the blue LED is activated again. If you later want to add new lights you need to repeat steps 4-5.

6.) Now the lights are available .

Installation

You can open the CLIP API Debugger (run on bridge) in your web browser. With this tool you could create a 'new developer' and test the Hue <=> bridge connection (see Philips getting started).

OpenRemote Designer Configuration

Create A Switch

This is how the new on command should look like:

Philips Hue - setHueOn

Name:                setHueOn
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x/state
HTTP Method:         PUT
Workload:            {"on":true}

Copy them to off command to a new one and toggle the on flag to false:

Philips Hue - setHueOff

Name:                setHueOff
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x/state
HTTP Method:         PUT
Workload:            {"on":false}

For the current switch status you will need a new get command:

Philips Hue - getHueSwitch

Name:                getHueSwitch
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x
HTTP Method:         GET
Polling interval:    1s
JSONPath Expression: $.state.on

The get command should link to a new sensor:

Philips Hue - hueSwitchSensor

Name:                hueSwitchSensor
Command:             getHueSwitch
Type:                custom

/* Custom state items */

name | value
------------
off  | false
on   | true

Now you can create a new switch and link all together:

Philips Hue - hueSwitch

name:                hueSwitch
sensor:              hueSwitchSensor
command(on):         setHueOn
command(off):        setHueOff

After all you can link your new switch with your GUI button.

Create A Brightness Slider

You'll need a new set command:

Philips Hue - setHueBrightness!

Name:                setHueBrightness
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x/state
HTTP Method:         PUT
Workload:            {"on":true, "bri":${param}}

And also a new get command:

Philips Hue - getHueBrightness

Name:                getHueBrightness
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x
HTTP Method:         GET
Polling interval:    1s
JSONPath Expression: $.state.bri

Then you've link it to a new sensor:

Philips Hue - hueBrightnessSensor

Name:                hueBrightnessSensor
Command:             getHueBrightness
Type:                range

/* Range properties */

Min: 0
Max: 255

And link it all to your new slider:

Philips Hue - hueBrightnessSlider

name:                hueBrightnessSlider
sensor:              hueBrightnessSensor
setValue:            setHueBrightness

Now you can link it with your GUI slider.

Create A Saturation Slider

First of all we need a new set command:

Philips Hue - setHueSaturation

Name:                setHueSaturation
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x/state
HTTP Method:         PUT
Workload:            {"on":true, "sat":${param}}

And also a new get command:

Philips Hue - getHueSaturation

Name:                getHueSaturation
Protocol:            HTTP

/* HTTP attributes */

URL:                 http://hue_bridge/api/newdeveloper/lights/x
HTTP Method:         GET
Polling interval:    1s
JSONPath Expression: $.state.sat

Now you've link it to a new sensor:

Philips Hue - hueSaturationSensor

Name:                hueSaturationSensor
Command:             getHueSaturation
Type:                range

/* Range properties */

Min: 0
Max: 255

And link it all to your new slider:

Philips Hue - hueSaturationSlider

name:                hueSaturationSlider
sensor:              hueSaturationSensor
setValue:            setHueSaturation

Now you can link it also with your GUI slider.

Create A Color Picker

Create a new setVirtualColor command:

Philips Hue - setVirtualColor

Name:                setVirtualColor
Protocol:            In-memory Virtual Command

/* In-memory Virtual Command attributes */

Command:             on
Address:             color

Then a new getVirtualColor command:

Philips Hue - getVirtualColor

Name:                getVirtualColor
Protocol:            In-memory Virtual Command

/* In-memory Virtual Command attributes */

Command:             status
Address:             color

Now create a new virtualColorSensor and link it with get command:

Philips Hue - virtualColorSensor

Name:                virtualColorSensor
Command:             getVirtualColor
Type:                custom

After all you can link the virtual set command with your GUI color picker.

Check It All

This is what you need:

Philips Hue - sensors

Fancy Rules

To convert the color picker RGB to an HSB value you'll need the mighty rules:

package org.openremote.controller.model.event

import java.awt.Color
global org.openremote.controller.statuscache.CommandFacade execute

/* convert color picker rgb to hue hsb value */
function int[] rgb2hue(Object param)
{
    String value = (String) param;
    int r = Integer.parseInt(value.substring(0, 2), 16);
    int g = Integer.parseInt(value.substring(2, 4), 16);
    int b = Integer.parseInt(value.substring(4, 6), 16);
    float hsb[] = Color.RGBtoHSB(r, g, b, null);
    int[] result = new int[3];

    result[0] = (int)(hsb[0] * 65535);
    result[1] = (int)(hsb[1] * 255);
    result[2] = (int)(hsb[2] * 255);

    return result;
}

rule " process Philips hue command based on color picker value "
when
    CustomState(source == "virtualColorSensor", $rgb:value)
then
    execute.command("setHueColor", rgb2hue($rgb)[0]);
    execute.command("setHueSaturation", rgb2hue($rgb)[1]);
    execute.command("setHueBrightness", rgb2hue($rgb)[2]);
end

Displaying

This picture represent an use case:

Philips Hue - use_case

See also