Servus,
jetzt funktioniert es.
Vielleicht braucht es ja jemand:
let POWER_LIMIT = 8; // Watt
let TIME_LIMIT = 360; // Sekunden (6 Minuten)
let CHECK_INTERVAL = 10; // Sekunden
let lowPowerSeconds = 0;
Timer.set(CHECK_INTERVAL * 1000, true, function () {
Shelly.call(
"Switch.GetStatus",
{ id: 0 },
function (res) {
let power = res.apower;
if (power < POWER_LIMIT) {
lowPowerSeconds += CHECK_INTERVAL;
print("Leistung niedrig:", power, "W | Zeit:", lowPowerSeconds, "s");
if (lowPowerSeconds >= TIME_LIMIT) {
print("Leistung 6 Minuten unter", POWER_LIMIT, "W → Abschalten");
Shelly.call("Switch.Set", { id: 0, on: false });
lowPowerSeconds = 0; // Reset nach Abschalten
}
} else {
if (lowPowerSeconds > 0) {
print("Leistung wieder über Limit:", power, "W → Timer reset");
}
lowPowerSeconds = 0;
}
}
);
});