Overview
The Philips Hue integration provides a set of ready-made functions you can call when building mappings. They build the flashing or alert light state a Philips Hue light should show, and convert a color from RGB or hex into the XY color coordinates Philips Hue uses, so you don't have to write that logic yourself.
These functions come from version 1.1 of the integration, where a collection mapped a custom field named after a light to a function such as FlashRed(). Version 2.0 still accepts them and sends each light state as a Signal. For new collections, map the Target, Command, Color and DurationSeconds fields directly instead: they reach rooms, zones and several lights at once, and offer more commands. The Philips Hue Light Command From iPaaS.com Mapping Documentation describes those fields.
Where you can use these functions
These functions are available anywhere you write a formula for the Philips Hue integration:
Dynamic Formula mappings: where a destination field's value is produced by a formula rather than mapped directly from a source field.
Mapping collection filters: where a formula decides whether a record should be processed.
Error filters: a mapping collection's error filter, which sits alongside its collection filter. When the error filter's formula resolves to true, the transfer raises an error that is held in the Error Logs for review and is not retried automatically.
Translation collections: where a translation entry uses a formula as its source value.
How to use them
Call a function by name and pass the values it needs in parentheses, for example:
RGB(255, 0, 0).Each function's signature shows its name, the parameters it accepts (with their types), and the type of value it returns. Use it as the reference for exactly how to call the function.
Function names and formula syntax are case-sensitive, so type each name exactly as shown. Whether the values a function matches are treated as case-sensitive varies by function, and is called out in the relevant parameter's description.
These functions are synchronous, so you call them directly (no
awaitis required).Some functions provide more than one form (overloads): the same function name with different parameter combinations. Pick the form whose inputs you have; each function's Signatures list shows the available forms.
Each function is a conversion: it builds a value from the inputs you pass and does not read anything from your Philips Hue account.
The functions are grouped below by the area of the integration they support.
Light Alerts
Use these to build the light state a Philips Hue light should show as an alert. Each returns a LightState, which you use in one of two ways:
Custom field named after a light: add a custom field to the collection, name it exactly as the light is named in your Hue app, and set its value to the function, for example
FlashRed(). The custom field's name is searched among lights only, not rooms or zones. When several such custom fields are mapped, only the last one's light is signalled.LightState field: map the function to the LightState field with a Dynamic Formula and name the light, room or zone in Target. Validate this form in a staging subscription before relying on it in production.
Version 2.0 sends every light state from these functions as a Signal:
Color: a light state with a color (
FlashRed(),FlashGreen(),FlashBlue(), orAlertwith XY coordinates) flashes that color. A light state without a color (Flash(), or the short form ofAlert), or a light that shows only white, blinks.Duration: the Signal lasts the light state's delay, at most 10 seconds. A delay of 0 or less uses 10 seconds.
Brightness: a Signal does not use brightness. The light state's brightness is applied, as a percentage, only when the collection's Command is
OnorScene.Not applied: the light state's saturation, hue, effect, alert and off settings.
Mapped fields win: a mapped Target, Color, Brightness or DurationSeconds takes priority over the custom field's light and the function's color, brightness or delay. With a function custom field the search stays on lights only, so a mapped Target that names a room or zone fails with
PHUE-NFND-1001unless TargetType is also mapped.Other commands: a mapped Command other than
Signalsends that command instead. The function's color is still used with CommandOnandEffect, on lights that support color.
Flash
What it does: Builds a Philips Hue light state that flashes at full brightness for 10 seconds. Version 2.0 sends it as a Signal that blinks the light for 10 seconds.
Signature: LightState Flash()
How to call it: Flash()
Parameters: none.
Returns: LightState. A light state set to flash, with brightness 254 (full) and a 10-second delay.
Example: Flash() returns a flashing light state; as a custom field named after a light, it blinks that light for 10 seconds.
When to use it: When a light should blink as a plain alert, with no color of its own.
FlashRed
What it does: Builds a Philips Hue light state that flashes red for 10 seconds. Version 2.0 sends it as a red Signal for 10 seconds.
Signature: LightState FlashRed()
How to call it: FlashRed()
Parameters: none.
Returns: LightState. A light state set to flash red, with brightness 254 (full) and a 10-second delay.
Example: FlashRed() returns a red flashing light state; as a custom field named after a light, it flashes that light red for 10 seconds.
When to use it: When a light should flash red as an alert.
FlashGreen
What it does: Builds a Philips Hue light state that flashes green for 10 seconds. Version 2.0 sends it as a green Signal for 10 seconds.
Signature: LightState FlashGreen()
How to call it: FlashGreen()
Parameters: none.
Returns: LightState. A light state set to flash green, with brightness 254 (full) and a 10-second delay.
Example: FlashGreen() returns a green flashing light state; as a custom field named after a light, it flashes that light green for 10 seconds.
When to use it: When a light should flash green as an alert.
FlashBlue
What it does: Builds a Philips Hue light state that flashes blue for 10 seconds. Version 2.0 sends it as a blue Signal for 10 seconds.
Signature: LightState FlashBlue()
How to call it: FlashBlue()
Parameters: none.
Returns: LightState. A light state set to flash blue, with brightness 254 (full) and a 10-second delay.
Example: FlashBlue() returns a blue flashing light state; as a custom field named after a light, it flashes that light blue for 10 seconds.
When to use it: When a light should flash blue as an alert.
Alert
What it does: Builds a custom Philips Hue alert light state. The short form sets the brightness and delay; the full form also sets the color (as XY coordinates), saturation and effect. Version 2.0 sends it as a Signal for the delay, in the color when the full form gives one.
Signatures (pick the form with the inputs you need):
LightState Alert(object brightness, int delayOffSeconds)LightState Alert(int brightness, List<Double> xy, int saturation, string effect, int delayOffSeconds)
How to call it: Alert(brightness, delayOffSeconds)
Parameter | Type | Required | Default | Description |
brightness |
| Yes | N/A | The Philips Hue brightness, from 0 to 254 (254 is full brightness). The short form accepts a number or text such as |
delayOffSeconds |
| Yes | N/A | How long the alert lasts, in seconds. Values above 10 are capped at 10. Version 2.0 uses it as the Signal's duration; 0 or less uses 10 seconds. |
xy |
| No | N/A | The color as Philips Hue XY coordinates. Use |
saturation |
| No | N/A | The Philips Hue color saturation. Version 2.0 does not apply it. Full form only. |
effect |
| No | N/A | A version 1.1 effect name, for example |
Returns: LightState. An alert light state set from the values you pass.
Example: Alert(230, 10) returns an alert light state at brightness 230 with a 10-second delay; version 2.0 blinks the light for 10 seconds. Alert(230, Hex("#0000FF"), 249, "none", 10) returns a blue alert light state; version 2.0 flashes the light blue for 10 seconds.
When to use it: When a version 1.1 style alert needs its own color or a delay shorter than 10 seconds. For durations longer than 10 seconds, map DurationSeconds instead.
Color Conversion
Use these to convert a color into the XY coordinates Philips Hue uses, to pass as the xy value of the full form of Alert. The Color field does not take XY coordinates: give it a color name, a hex value or R,G,B text directly, as the Philips Hue Light Command From iPaaS.com Mapping Documentation describes.
RGB
What it does: Converts an RGB color to the XY color coordinates Philips Hue uses.
Signature: List<Double> RGB(float R, float G, float B)
How to call it: RGB(R, G, B)
Parameter | Type | Required | Default | Description |
R |
| Yes | N/A | The red component of the color, from 0 to 255. |
G |
| Yes | N/A | The green component of the color, from 0 to 255. |
B |
| Yes | N/A | The blue component of the color, from 0 to 255. |
Returns: List<Double>. The color as Philips Hue XY coordinates (two numbers).
Example: RGB(255, 0, 0) returns about [0.735, 0.265], the XY coordinates for red. Black, RGB(0, 0, 0), has no color of its own, so it returns the XY coordinates of white.
When to use it: When you have a color as RGB values and pass it to the full form of Alert.
Hex
What it does: Converts a hex color string to the XY color coordinates Philips Hue uses.
Signature: List<Double> Hex(string hexString)
How to call it: Hex(hexString)
Parameter | Type | Required | Default | Description |
hexString |
| Yes | N/A | The color as a hex value, for example |
Returns: List<Double>. The color as Philips Hue XY coordinates (two numbers).
Example: Hex("#0000FF") returns about [0.157, 0.018], the XY coordinates for blue.
When to use it: When you have a color as a hex value and pass it to the full form of Alert.
