node-red-contrib-huemagic
Version:
Philips Hue node to control bridges, lights, groups, scenes, rules, taps, switches, buttons, motion sensors, temperature sensors and Lux sensors using Node-RED.
97 lines (69 loc) • 9.2 kB
HTML
<script type="text/markdown" data-help-name="hue-light">
The "Hue Light" node can control lights connected to the bridge and receive their status messages.
### Setup
Select the pre-configured Hue Bridge and hit the search button to find all the available lights. If you already know the ID of a light, you can also enter it here manually. You can either assign a new name for the light internally or choose the predefined name. Optionally, you can also deactivate all automatic status messages for this node by clicking the setting "Skip events from node". The node will then no longer issue device updates. Alternatively, you can also choose whether the node's initialization message should not be suppressed when Node-RED is started. If you activate this setting, you will receive a status message for the currently selected light after each deployment.
If you activate the setting "Activate color naming", the node will try to describe the currently set light color for each status message. You will then receive an additional parameter with the English description of the currently set color in the output.
If you do not select a light and use the node configuration in this way, the node works in the so-called "universal mode". In this mode, the node receives and outputs all status messages of the same type. You can also apply settings in universal mode to a specific light by transferring the corresponding light ID as a string in `msg.topic` together with your settings.
### Get status
Outputs the current status of the light as soon as a `msg.payload` object with the following content has been passed to the node. Alternatively, you can also press the button in the Node-RED interface without having to pass a message to the node beforehand.
: status (boolean): Returns the current status of the light
### Turn light on / off (simple)
To quickly switch a light on or off in simple mode, pass an object with the following content to the node:
: payload (boolean): `true` switches the light on, `false` switches it off
### Light commands (extended)
In addition to simply switching it on and off, there are also many other options available for controlling the light. All nodes in HueMagic can be controlled with additive commands. This means that you can first pass one setting and then another setting in a later command without discarding the previous setting. Transfer the following parameters to a `msg.payload` object to make more extensive settings on the light:
: on (boolean): `true` switches the light on, `false` switches it off
: toggle (boolean | any): Toggles between switching on and off, depending on the previous status of the light
: brightness (int | string): Percentage value of the light brightness (0-100) or a string with the value `auto` to automatically set the brightness based on the current time
: brightnessLevel (int): Numerical value of the light brightness (0-254)
: incrementBrightness (int | boolean): Specifies by how many percent the light should be made brighter or `true` to make the light brighter in 10% steps
: decrementBrightness (int | boolean): Specifies the percentage by which the light should be made darker or `true` to make the light darker in 10% steps
: color (string): `random` to set a random color or an English color name (e.g. `red`)
: hex (string): Color value in hexadecimal in the form of a string
: rgb (array [0,0,0]): Color value in RGB format in the form of an array
: xyColor (object {x [float], y [float]}): Color value in the XY color format in the form of an object
: gradient (object {hex […]}): An object with a supported color object (e.g. `hex`,` rgb`, ...) and several colors to set a gradient to supported lights
: mixColor (object): A color to be mixed with the current light color. Can accept `color`, `hex`, `rgb` or `xyColor` objects and optionally `amount` (int) to indicate the mixing ratio in percent
: image (string): Path of an image (local or on the web) to set the current color of the light to the average color of the image
: saturation (int): Percentage of the saturation of the current color (beta)
: colorTemp (int | string): Value between 153 and 500 to set the color temperature of the light or the values `cold`, `normal`, `warm`, `hot` and `auto` - where `auto` is the color temperature based on the current time
: incrementColorTemp (int | boolean): Value by how much the color temperature should be warmer or `true` to make the color temperature warmer in steps of 50
: decrementColorTemp (int | boolean): Value by how much the color temperature should be colder or `true` to make the color temperature colder in steps of 50
: transitionTime (float): Transition time of the current setting in seconds. If `0` is entered, the light changes to the desired setting immediately. If `3` is entered, the light changes to the desired setting with a slight transition in the next 3 seconds
: colorloop (float): Plays a "colorloop" animation for the selected duration in seconds and then switches back to the original state of the light
: alert (float): Plays an "alert" animation for the selected duration in seconds and then switches back to the original state of the light
### Status messages from the node
As soon as a change in the light settings has been detected (regardless of whether via Node-RED or externally), the following status message is returned by the node:
#### Status object under `msg.payload`
: on (boolean): State of the light, where `true` stands for on and `false` for off
: brightness (int | boolean): Current brightness in percent or `false`, if the light does not support a brightness setting
: brightnessLevel (int | boolean): Current brightness from 0-254 or `false`, if the light does not support a brightness setting
: reachable (boolean | string): `true` if the light is connected to the bridge, `unknown` if the connection status deviates
: connectionStatus (string): The current connection status with the bridge in the form of a string. Can contain `connected`, `disconnected`, `connectivity_issue` or `unidirectional_incoming` as a value
: rgb (array [int, int, int] | optional): Current light color in the form of an RGB value, if the light can display colors
: hex (string | optional): Current light color in the form of a hexadecimal value if the light can display colors
: xyColor (object {x [float], y [float]} | optional): Current light color in the form of an XY value, if the light can display colors
: color (string | optional): Current light name in English, if the light can display colors and the corresponding setting of the node has been activated
: gradient (object | optional): Current gradient setting with all available color units in the form of an array, if the light supports gradient settings, where `colors` outputs the colors, `numColors` the number of set colors in the gradient and `totalColors` the maximum possible Number of colors the resource can support in the gradient
: colorTemp (int | boolean | optional): Current color temperature of the light, if the light can display color temperatures and a color temperature has been set
: colorTempName (string | optional): Current color temperature of the light in the form of a descriptive string with the values `cold`,`normal`, `warm` or `hot`, if the light can display color temperatures and a color temperature has been set. Otherwise `unknown` is output
: updated (string): Time of the last update of the resource by HueMagic (ISO 8601)
#### Information about the light under `msg.info`
: id (string): Indicates the new ID of the light
: idV1 (string | boolean): Indicates the old ID of the light
: uniqueId (string): The unique ID of the light
: deviceId (string): The unique ID of the device
: name (string): The currently set name of the light
: type (string): The type of light (always `light`)
: softwareVersion (string): The current firmware of the light
: model (object): Contains the model information of the light under `id`, `manufacturer`, `name`, `type`, `certified`, `friendsOfHue`, `colorGamut` and `colorGamutType`
#### Status changes under `msg.updated`
Lists individual parameters in the form of an object that have changed compared to the last state of the light. If no changes have been registered, this object is empty.
#### Last status of the light under `msg.lastState`
Contains the complete status object (see output values above) of the last status before the last change. If the last state of HueMagic has not yet been registered, it will output `false`.
#### Last command under `msg.command` (optional)
If the status of the node has changed via a certain command, the entire command that was executed is also output. Otherwise this object will not be output by the node.
### Examples from HueMagic
HueMagic provides some sample configurations for this node. To import a full featured example into your Node-RED interface, click on the Node-RED menu icon, then select "Import" and navigate to "Examples" in the sidebar of the popup. Then select the HueMagic folder and your desired node to import a sample flow.

</script>