Turn scene on/off/dim
To control the dim level of all luminaires of a scene in a network you can send a CONTROL message to server over active WebSocket connection (and opened wire). The "id" parameter of the message is the ID (number) of the related scene of the network related to the current wire. The "level" parameter of the message is the wanted dim level (number) for the related luminaires.
let wire = 1; // Use same wire ID as was used in the related OPEN message
let scene_id = 1; // Scene ID of the network related to the current wire
let value = 0.5; // Dim value can be anything from 0 to 1
if (webSocket.readyState === webSocket.OPEN) {
const data = JSON.stringify({
"wire": wire,
"method": "controlScene",
"id": scene_id,
"level": value
});
socket.send(decodeURIComponent(escape(data)));
}
When CONTROL luminaires of scene message was successful then server will send unitChanged events (with updated state info) of all related devices to all related clients and related luminaires will be on/off/dimmed.