Hallo ich habe ein Script zum Farbwechsel gefunden, möchte mit den Script 3 Shelly Duo RGB steuern weis jemand ob das möglich ist ohne gleich drei scripts zu machen ?
Code
let REMOTE = {
ip: '192.168.178.145',
};
let colorsequence = [
'?turn=on&gain=100&blue=255&red=0&green=0',
'?turn=on&gain=100&blue=0&red=255&green=0',
'?turn=on&gain=100&blue=0&red=0&green=255',
'?turn=on&gain=100&blue=0&red=255&green=255',
];
let dimsequence = [
'50',
'33',
'20',
'5',
'100',
];
let colorposition = 0;
let dimpos = 0;
let colortype = 'white';
Shelly.addEventHandler(
function (event, user_data) {
if (typeof event.info.event !== 'undefined') {
if (event.info.event === 'double_push') {
if (colortype === 'white') {
setMode(REMOTE.ip, 'color');
}
setRGBW(REMOTE.ip, colorposition);
colorposition++;
dimpos = 0;
if (colorsequence.length === colorposition) {
colorposition = 0;
}
} else if (event.info.event === 'single_push'){
print(colortype);
if (colortype === 'color') {
setMode(REMOTE.ip, 'white');
}
toggleRGBW(REMOTE.ip);
} else if (event.info.event === 'long_push') {
if (colortype === 'color') {
dimRGBW(REMOTE.ip, dimpos, 'gain');
} else {
dimRGBW(REMOTE.ip, dimpos, 'brightness');
}
dimpos++;
if (dimsequence.length === dimpos) {
dimpos = 0;
}
} else {
return true;
}
} else {
return true;
}
},
);
function setRGBW(ip, colorposition) {
Shelly.call(
"http.get", {
url: 'http://' + ip + '/light/0' + colorsequence[colorposition]
},
function (r, e, em, ud) {
print(colorsequence[colorposition]);
},
null
);
};
function setMode(ip, ctype) {
colortype = ctype;
print(ctype);
Shelly.call(
"http.get", {
url: 'http://' + ip + '/settings?mode=' + ctype
},
function (r, e, em, ud) {
print(colortype);
},
null
);
};
function dimRGBW(ip, dimpos, colormode) {
Shelly.call(
"http.get", {
url: 'http://' + ip + '/light/0?'+ colormode + '=' + dimsequence[dimpos]
},
function (r, e, em, ud) {
print(dimsequence[dimpos]);
},
null
);
};
function toggleRGBW(ip) {
Shelly.call(
"http.get", {
url: 'http://' + ip + '/light/0?turn=toggle'
},
function (r, e, em, ud) {
},
null
);
}
Alles anzeigen