Shelly script addEventHandler
gobo-ws opened this issue · 3 comments
gobo-ws commented
Thank you for the examples!
Some parts of it helped me to create the following script:
let CONFIG = {
hostname: '10.50.40.10:9090', // OLA hostname:port
universe: '1', // Universe
dmx: '255,255,255', // DMX values
input1: 0, // Shelly Button ID (not in use yet)
};
Shelly.call(
"http.request", {
method: "POST",
url: 'http://' + CONFIG.hostname + '/set_dmx',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'u=' + CONFIG.universe + '&d=' + CONFIG.dmx
},
);
But I am still struggling how to run the script when a momentary switch is triggered (detached mode)
Can you please help me a little bit with the evenHandler part? Thanks in advance.
eurich commented
Should be like this for a single_push event..
possible events: single_push, double_push, long_push, btn_up, btn_down
Shelly.addEventHandler(
function (event) {
if (typeof event.info.event !== 'undefined') {
if (event.info.event === 'single_push' && event.info.id === CONFIG.input1) {
// Place your Shelly.Call here
}
} else {
return true;
}
},
);
eurich commented
feel free to re-open the issue if you need further assistance.