SunMonitor
Links
- https://github.com/hamatoma/sunmonitor/wiki/Programm-SunMon
- https://suntom.hamatoma.de
- https://sun.hamatoma.de
hm
- curl -s https://ip.hamatoma.de/setip.php?hostname=sunmonitor
- sun.hamatoma.de: proxy_pass http://127.0.0.1:8082;
- sunmonitor.service
- sunserver.service
- /etc/sunmonitor: monitor.sun.conf server.sun.conf
- curl -s https://ip.hamatoma.de/setip.php?hostname=sunmonitor
- Eintrag in /home/www/ip/setip.php
Markus
- masun.hamatoma.de: proxy_pass http://127.0.0.1:8083;
- masunmonitor.service
- masunserver.service
- /etc/sunmonitor: masunmonitor.conf masunserver.conf
- curl -s https://ip.hamatoma.de/setip.php?hostname=masun
- Eintrag in /home/www/ip/setip.php
Script für Shelly
let remoteurl = "http://ip.hamatoma.de/setip.php?hostname=sunmonitor";
let maxfails = 1000;
// checks the internet connection every x minutes, recommended is 5 or more
let interval = 60;
// CONFIG END
// no need to change anything below this line.
let alertTimer = '';
let failcounter = 0;
function setIp(){
print("setIp:");
Shelly.call("HTTP.GET", {
url: remoteurl
},
function (res, error_code, error_msg, ud) {
if (error_code !== 0) {
if (failcounter === maxfails) {
print("Restart");
restartRelay();
failcounter = 0;
} else {
failcounter++;
print("fail: res: ", res, " err: ", error_code, " msg: ",
error_msg, " ud: ", ud, " #: ", failcounter);
}
}
},
null
);
}
function startMonitor() {
alertTimer = Timer.set(interval *60 * 1000,
true,
function () {
print("started by timer");
setIP();
},
null
);
}
function restartRelay() {
Shelly.call(
"switch.set",
{ id: 0, on: false, toggle: 2},
function (result, code, msg, ud) {
},
null
);
}
startMonitor();