Skip to main content

Control color temperature

To control the color temperature of specific luminaire of network you can send a CONTROL message to server over active WebSocket connection (and opened wire). The "targetControls" parameter of the message uses similar format as received with unitChanged event of the related device. The "source" of Colorsource object must be set to "TW" for color temperature functionality to work as expected. The "value" of the ColorTemperature object of the message is the wanted color temperature in Kelvins (number) for the related luminaire.

let wire = 1; // Use same wire ID as was used in the related OPEN message for the targeted network
let unit_id = 1; // Device ID of the related luminaire
let targetControls = {"ColorTemperature": {"value" : 5000}, "Colorsource": {"source": "TW"}}; // ColorTemperature value in Kelvins, anything between Kelvin range of luminaire

if (webSocket.readyState === webSocket.OPEN) {
const data = JSON.stringify({
"wire": wire,
"method": "controlUnit",
"id": unit_id,
"targetControls": targetControls
});

socket.send(decodeURIComponent(escape(data)));
}

When CONTROL luminaire of network message was successful then server will send unitChanged event (with updated state info) of related device to all related clients and color temperature of related luminaire will be updated.