Flox
2
var lightState = false;
function toggleLights() {
lightState = !lightState;
var devices = [
"wb-mr6c_49", "wb-mr3_13", "wb-mr3_20", "wb-mr3_28", "wb-mr3_12",
"wb-mr6c_14", "wb-mr6c_108", "wb-mr3_82", "wb-mr6c_32",
"wb-mr6cu_102", "wb-mr6cu_121", "wb-mr6c_51", "wb-mr3_81",
"wb-mr6cu_148", "wb-mr6cu_84"
];
var relays = ["K1", "K2", "K3", "K4", "K5", "K6"];
devices.forEach(function(device) {
relays.forEach(function(relay) {
if (dev[device] && dev[device][relay] !== undefined) {
dev[device][relay] = lightState;
}
});
});
}
defineRule("toggle_lights_on_button_press", {
whenChanged: "wb-mr6c_49/Input 2",
then: function (newValue, devName, cellName) {
if (newValue) {
toggleLights();
}
}
});