User Tools

Site Tools


philipshue

Philips Hue Bridge Protocol
This implementation adds support for the Philips Hue protocol using the Philips Hue Bridge Rest API to control Philips Hue bulbs. The protocol polls the status from the Bridge every minute to update the device values in pilight.

Requirements
The Hue Bridge is connected to the same LAN as the machine running the pilight daemon.
Using the Hue Bridge allows smooth integration of pilight into the overall environment. The concept of the Hue Bridge is found here: http://www.developers.meethue.com/documentation/core-concepts. The bridge itself is using the zigbee protocol to communicate with the Hue bulbs. The zigbee interface protocol is currently not supported directly, however this is not considered to be a shortcoming, as bypassing the Hue Bridge is basically not recommended.
Until this protocol stack is integrated into the main pilight release, the updated development version is available at:
https://github.com/wo-rasp/pilight/tree/test_dev

FeatureSupport
Sending
Receiving
Config

To use all available settings for the bulbs you do need to use the CLI interface for the protocol philipshue and pilight-send or pilight-control.

Supported Brands
All Hue Bulbs connected to the Hue Bridge.

Sender Arguments

AbbrCommandRemarks
-i –bridgeip=ipaddressPhilips Hue Bridge IP Address
-l –lightid=lightidlightid (1,2,3,..)
-u –username=usernameusername for bridge api
-o –on=true, falseset light state on to true or false
-b –bri=0..254brightness of a light from 0 to 254, this value is changed by dimlevel
-h –hue=0..65535hue color value red=0, yellow=12750, green=25500, blue=46920, purple=56100, red=65280
-s –sat=0..255saturation from 0 to 255
-e –effect=none, colorloopcollorloop: endless color looping mode until it is stopped by sending none
-x –x=0..0.9999x value in xy color points
-y –y=0..0.9999y value in xy color points
-c –ct=153..500color temperature (warmest color is 500)
-a –alert=none, selectselect makes the light do a blink in its current color
-g –group=0, 1, ..running on group of lights. The group must have been created before (group 0 always includes all lights)
-z –scene=scene-idapply a predefined scene id (use option –resource=scenes to list all scenes on hue bridge)
-r –resource=namenames are: lights, groups, config, schedules, scenes, sensors, rules
-t –onturn light or group on
-f –offturn light or group off
-n –newusercreate and authorize user on Hue Bridge

To create a new user on the Hue Bridge, proof of physical access to the Hue bridge is required.

Config
In the followng example, it is assumed that the IP address of the Hue Bridge is 192.168.0.252.

1. Create a user on the Hue Bridge:

First a username must be created and authorized on the bridge. To do so, you do need to press the button on the Hue Bridge AND execute the following pilight command at the same time:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --newuser

pilight will respond either with an error message:

pilight-send: NOTICE: Create and authorize new user for pilight on Hue Bridge ...
pilight-send: NOTICE: philipshue - post data = {"devicetype":"pilight"} to url http://192.168.0.252/api
pilight-send: NOTICE: response from hue bridge = [{"error":{"type":101,"address":"","description":"link button not pressed"}}]
pilight-send: NOTICE: description = link button not pressed
pilight-send: NOTICE: ----> Press Link button and run again pilight-send -p philipshue --ip=192.168.0.252 --newuser

or will report back the username generated:

$ pilight-send -p philipshue -i 192.168.0.252 --newuser
pilight-send: NOTICE: Create and authorize new user for pilight on Hue Bridge ...
pilight-send: NOTICE: philipshue - post data = {"devicetype":"pilight"} to url http://192.168.0.252/api
pilight-send: NOTICE: response from hue bridge = [{"success":{"username":"29b7e422ee6f973bc97b3e1f3269a3"}}]
pilight-send: NOTICE: ----> Successfully created and authorized username = 29b7e422ee6f973bc97b3e1f3269a3 <--- Use this username

You do need to copy the username to your config.json file.

"devices": {
    "Hue1": {
        "protocol": [ "philipshue" ],
        "id": [{
            "bridgeip": "192.168.0.252",
            "username": "29b7e422ee6f973bc97b3e1f3269a3",
            "lightid": 1
        }],
        "on": "false",
        "bri": 254,
        "hue": 8625,
        "sat": 252,
        "effect": "none",
        "x": 0.5837,
        "y": 0.3879,
        "ct": 500,
        "alert": "select",
        "dimlevel": 15,
        "group": 0,
        "scene": "0",
        "state": "off"
        }
    }
    "rules": {},
    "gui": {
        "Hue1": {
            "name": "Study",
            "group": [ "Lights" ],
            "media": [ "all" ]
        }
    },
    "settings": { .... },
    "hardware": { .... },
    "registry": { .... }
}

The pilight GUI interface supports turning lights ON/OFF and dimming of the device in 15 steps. For all other command sequences, currently the CLI interface (pilight-send, pilight-control) has to be used.

Configuration Steps
Each Hue Bridge has its own username.
For each lampid, you do need to configure a device and assign it to a group.
Configure in the GUI section Dimmer devices if GUI support is required.

Examples
List all bulbs on the bridge:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --resource=lights

List all scenes on the bridge:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --resource=scenes
pilight-send: NOTICE: philipshue - get data http://192.168.0.252/api/29b7e422ee6f973bc97b3e1f3269a3/scenes
pilight-send: NOTICE: 497b50d84-on-0 = {"name":"Sunset on 0","lights":["1","2","3"],"active":true}
pilight-send: NOTICE: ac637e2f0-on-0 = {"name":"Relax on 0","lights":["1","2","3"],"active":true}
...

Apply a scene:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --scene=497b50d84-on-0

Turn all lights on:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --group=0 -t

Turn all lights off:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --group=0 -f

Set full brightness red on light 2:

$ pilight-send -p philipshue --bridgeip=192.168.0.252 --username=29b7e422ee6f973bc97b3e1f3269a3 --lightid=2 --bri=255 --sat=255 --hue=0

Turn light 1 to red:

$ pilight-control -d Hue1 -s on -v hue=65280

Turn all lights on:

$ pilight-control -d Hue1 -s on -v group=0

Turn all lights off:

$ pilight-control -d Hue1 -s off -v group=0

Apply a scene:

$ pilight-control -d Hue1 -s off -v scene=497b50d84-on-0

Hints
When you configure rules, you should limit the number of requests to be below 10 requests per second for an individual device and below 1 per second for a group.

When you configure conflicting parameters, only one parameter is accepted, the priority is:
- xy beats ct, ct beats hue, hue beats sat.

All lights act as a single repeater, if you need to extend your physical range, put a lamp inbetween.

Once a light is ON, it stays ON, do not sent ON commands repetively, as it slows down the bridge.

Known Limitations
The WEBGUI currently supports: ON, OFF, DIM UP/DOWN in 15 steps. Color, Scenes etc. do need to be controlled via the CLI interface.

Literature
More information about the Hue system can be found here:
http://www.developers.meethue.com/documentation/getting-started http://www.developers.meethue.com/documentation/core-concepts

philipshue.txt · Last modified: 2016/09/23 22:10 by wo_rasp