Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including node-red-contrib-node-hue with all npm packages installed. Try it out:

var nodeRedContribNodeHue = require("node-red-contrib-node-hue")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-red-contrib-node-hue v0.9.5

Control Philips HUE lights using Node-RED.

Philips Hue nodes for Node-Red

An solution to control Philips Hue lights using Node-Red, uses node-hue-api library for communicating with the lights.

This module provides input and output nodes for communicating with Philips Hue lights, the input node accepts multiple color format and automatically converts the values to the right format.


  • Control both groups and individual lights.
  • Handles automatic conversion of rgb/hsv/hex/xy/.. color space to light specific color space
  • Trigger events for light changes
  • Self syncing, uses background polling to detect external changes to light
  • Displays current state for light in the Node-Red ui


  • The HSV to XY (and back) color conversion is not 100% correct, modifying single color channel at a time can produce strange results.


Dashboard example config:

This is an example of how to control the light using the node-red-dashboard The split node is used to get the on and bri payload from the light status message, and the join is used to combine the topic and value to an JSON object.

UI example

Wakeup example config:

Simple example of using an inject node to trigger an wakeup light behavior every workday, the light transitions from off to on with 75% brightness over an duration of 30s.

Wakeup example

Hub Configuration

Hub config

Light Configuration

Light config

Input node

The light is controlled by sending message with an payload containing the new state

Simplified control by sending the following values as payload

'on' or trueTurn light on
'off'or falseTurn light off
numeric valueTurn light on and set brightness (0-100%)

More advanced way to control the light is to send an object payload with one or more of the following properties set

onSet light state (true/false)
red, green and/or blueSet one or more color channel for light (0-255)
hexSet color (#f49242)
hueSet color hue (0-360)
xySet XY color (array with 0.0-1.0 values)
x and/or ySet XY color (0.0-1.0)
sat or saturationSet color saturation (0-100)
bri or brightnessSet light brightness (0-100%)
ct, mired or mirekSet Mired color temperature (153 - 500)
kelvinSet kelvin color temperature (2200-6500)
durationTransition time (ms)
alertAlert effect ('none', 'select' or 'lselect')
effectDynamic effect ('none' or 'colorloop')

Example: Sending the following to the light will turn it on and dim it upp to 77% over 10 seconds

  "payload": {
    "on": true, 
    "bri": 77,
    "duration": 10000

Output node

Example output from change event

  "id": "light3",
  "info": {
    "id": "3",
    "name": "Bedroom 1",
    "capability": [ "bri", "ct" ],
    "group": false,
    "type": "Color temperature light",
    "uniqueid": "00:17:88:01:02:06:ef:5c-0b",
    "modelid": "LTW001"
  "payload": {
    "on": true,
    "reachable": true,
    "bri": 12,
    "xy": [ 0.3244, 0.3373 ],
    "hsv": [ 27, 10, 12 ],
    "rgb": [ 31, 29, 28 ],
    "hex": "1F1D1C",
    "color": "black",
    "mired": 189,
    "kelvin": 5291
  "state": {
    "on": true,
    "bri": 31,
    "ct": 189,
    "colormode": "ct"
  "event": "change"

Using withouth Node-RED

This library can be used independent from Node-RED, the example/mqtt.js file contains an simple example using MQTT.js to enable control an lights on/off status and brightness over MQTT.

The MQTT topic lights will contain an list of all currently detected lights. Specific light can be controlled by sending an message to the topics lights/<id>/on (boolean) or lights/<id>/brightness (number) with the new state.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free