-
Autor
Hi, i had found a script on the internet which sends values to my emoncms.org account. Then I have multiplied the Timer.set() objects so I could read more temperatures with one script.
It works, but sometimes the script stops and I dont know why. What can cause this behavior? Is it possible to read all of the three temps in one Timer and uplad it with one url_send value? Emoncms can recieve many values, but how to read them and join them in a single Timer.
Here's my current code (without passkey):
Code
// Shelly GEN2 script: HTTP GET - Send energy meter watts to emoncms
// Settings
let user_apikey = "MY_APIKEY"; // Copy from emoncms.org > my account > Read & Write API Key
let name = "shelly"; // set a custom name for your shelly
let url = "https://emoncms.org/input/post?node=";
// Define timespan: sec * 1000 milliseconds
let interval = 10 * 1000;
// Set timer which send the HTTP GET
//temp 100
Timer.set(
interval,
true,
function () {
let status = Shelly.getComponentStatus("temperature", 100);
let url_send = url + name + "&json={Temp_DS:" + JSON.stringify(status.tC) + "}&apikey=" + user_apikey;
Shelly.call("HTTP.GET", {"url": url_send});
}
);
//temp 101
Timer.set(
interval,
true,
function () {let status = Shelly.getComponentStatus("temperature", 101);
let url_send = url + name + "&json={Temp_vystup:" + JSON.stringify(status.tC) + "}&apikey=" + user_apikey;
Shelly.call("HTTP.GET", {"url": url_send});;
}
);
//temp 102
Timer.set(
interval,
true,
function () {let status = Shelly.getComponentStatus("temperature", 102);
let url_send = url + name + "&json={Temp_patronaFVE:" + JSON.stringify(status.tC) + "}&apikey=" + user_apikey;
Shelly.call("HTTP.GET", {"url": url_send});
}
);
//relay_status
Timer.set(
interval,
true,
function () {let status = Shelly.getComponentStatus("switch", 0);
let url_send = url + name + "&json={Sit_vykon:" + JSON.stringify(status.apower) + ",Sit_proud:" + JSON.stringify(status.current) + ",Sit_stav:" + JSON.stringify(status.output) + "}&apikey=" + user_apikey;
Shelly.call("HTTP.GET", {"url": url_send});
}
);
Alles anzeigen