Mit diesem Script funktioniert der i4 aktuell wie ein dual button switch bei mir:
Code
// Quelle: https://shelly-forum.com/forum/thread/12453-shellyscript-dimmer-taster-auf-einem-shelly-plus-zu-100-emulieren/?pageNo=2
let REMOTE = {
ip: '192.168.178.xx', //dimmer
btn_dim_up: 0, //i4 input
btn_dim_down: 2, //i4 input
};
let dim = false;
// CONFIG END
Shelly.addEventHandler(
function (event, user_data) {
if (typeof event.info.event !== 'undefined') {
if (event.info.id === REMOTE.btn_dim_up) {
if (dim === true && event.info.event === 'btn_up') {
dim = false;
controlDimmer('/light/0?dim=stop');
}
if (event.info.event === 'single_push') {
controlDimmer('/light/0?turn=on');
} else if (event.info.event === 'double_push') {
controlDimmer('/light/0?turn=on&brightness=100');
} else if (event.info.event === 'long_push') {
dim = true;
controlDimmer('/light/0?dim=up&step=100');
} else {
return true;
}
}
if (event.info.id === REMOTE.btn_dim_down) {
if (dim === true && event.info.event === 'btn_up') {
dim = false;
controlDimmer('/light/0?dim=stop');
}
if (event.info.event === 'single_push') {
controlDimmer('/light/0?turn=off');
} else if (event.info.event === 'double_push') {
controlDimmer('/light/0?turn=on&brightness=5');
} else if (event.info.event === 'long_push') {
dim = true;
controlDimmer('/light/0?dim=down&step=100');
} else {
return true;
}
}
} else {
return true;
}
},
);
function controlDimmer(str) {
Shelly.call(
"http.get", {
url: 'http://' + REMOTE.ip + str
},
function (r, ec, em, ud) { },
null
);
}
Alles anzeigen
ich habe es leider nicht geschafft zu implementieren:
der Dimmer ist an (<100%) -> single push up -> set 100%