If I run the following script, everything works fine. (basically pulled from https://github.com/shelly-tools/s…_consumption.js)
But if I enable the switching of the device(Shelly.call), it will not respond anymore.
I found a couple of advices, but I guess I don't interpret them correctly.
i am running the code on a "pro 3" with Version: 0.10.2-beta2
Code
let mycount = 0;
let alertTimer = null;
function startMonitor() {
alertTimer = Timer.set(2 * 1000,
true,
function () {
Shelly.call("HTTP.GET", {
url: 'http://192.168.178.64/strom/'
},
function (res, error_code, error_msg, ud) {
if (error_code !== 0)
{
// Not read response if there is an error, to avoid that the script stops
}
else if (res.code === 200) {
let st = JSON.parse(res.body);
let current = st.psaldo;
mycount = mycount + 1;
print("mycount" + JSON.stringify(mycount));
if(mycount % 2 === 0) {
print("even");
//Shelly.call("Switch.Set", {"id": 1, "on": false});
}
else {
print("odd");
//Shelly.call("Switch.Set", {"id": 1, "on": true});
}
};
},
null
);
},
null
);
}
startMonitor();
Alles anzeigen
can someone point me to where I should have a look?