Turn set of luminaires on/off/dim
To control the dim level of a set of luminaires 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 any unitChanged event of the related device. The "ids" parameter of the message is a list of targeted device ID's (number).
let wire = 1; // Use same wire ID as was used in the related OPEN message for the targeted network
let targetControls = {"Dimmer": {"value": 0.5}}; // Dim value can be anything from 0 to 1
let units = [10, 77] // Array of target device ID's
if (webSocket.readyState === webSocket.OPEN) {
const data = JSON.stringify({
"wire": wire,
"method": "controlUnits",
"targetControls": targetControls,
"ids": units
});
socket.send(decodeURIComponent(escape(data)));
}
When CONTROL set of luminaires 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.