let CONFIG = {
Paivitystaajuus: 2 * 60000,
};
function Ohjaus(){
Shelly.call("HTTP.GET", { url: "
https://api.spot-hinta.fi/JustNow"},
function (res, error_code, error_msg, ud)
{
if (res.code === 200){
let resobj = JSON.parse(res.body);
print("Rank: ", resobj.Rank);
if (resobj.Rank <= 3) { //Montako halvinta tuntia
Shelly.call("Switch.Set","{ id:0, on:true}", null,null); //Rele päälle
}
else {
Shelly.call("Switch.Set","{ id:0, on:false}", null,null); //Rele pois
}
}
else {
Shelly.call("Switch.Set","{ id:0, on:false}", null,null); //Mitä tehdään jos ei toimi
}
;
},
null); }
Timer.set(
CONFIG.Paivitystaajuus,
true,
function (ud) {
Ohjaus();
},
null
);