Control XY color (experimental)
To control the XY color 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 "x" and "y" values of the XY object of the message define the wanted color in XY color map for the related luminaire. The "source" of Colorsource object must be set to "XY" for color functionality to work as expected. Note that the specific luminaire must support XY color scheme for this to work and that XY color conversion is experimental.
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 = {"XY": {"x": 0.375, "y": 0.425 }, "Colorsource": {"source": "XY"}}; // XY value where x is converted to range [0..0.750] and y to range [0..0.850]
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 of related luminaire will be updated. Note that color conversions are not fully lossless and thus accuracy can vary a bit.