-
Autor
With the kind help of people on this forum I have a great script running on my Plus2PM. I have tested it and am really happy.
Next I need to be notified when the script has been triggered.
I understand that there is no way to send an email, I do however have several "always-on" devices, from Raspberry PI, Linux box to a PC.
From experience could somebody suggest the most reliable way to get a notification?
This is the code into which I need to build the "notification".
Thank you.
Code
let component_name_id = 'input:100';
let component_item = 'percent';
let threshold = 20.0; // component value <= threshold
let pause_time = 0;
let pause_threshold = 0;
function switchontimer() {
print("Switch OFF für 30 secs")
Shelly.call("Switch.Set","{ id:0, on:false }",null,null);
Timer.set(30000,false,switchofftimer);
}
function switchofftimer() { pause_time = 0; }
print("Start and waiting.")
let eventhandle = Shelly.addEventHandler(
function(data) {
if (data["component"] == component_name_id) {
if (pause_time != 1 && pause_threshold != 1 && data["info"][component_item] <= threshold) {
print("Switch ON für 10 secs - " + data["info"][component_item])
Shelly.call("Switch.Set","{ id:0, on:true }",null,null);
pause_time = 1; pause_threshold = 1;
Timer.set(10000,false,switchontimer);
} else {
if (pause_time != 1) {
if (pause_threshold != 1) {
print("-- value changed: " + data["info"][component_item] + " - no action needed");
}
} else {
print("-- value changed: " + data["info"][component_item] + " - switching paused");
}
if (pause_threshold == 1) {
if (data["info"][component_item] > threshold) {
print("Ready and waiting.")
pause_threshold = 0;
} else {
if (pause_time != 1) {
print("-- value changed: " + data["info"][component_item] + " - waiting value to be < threshold");
}
}
}
}
}
}
);
Alles anzeigen