Pumpenschutz sichtbar gemacht (Shelly v1.2.1)
Der wöchentliche Pumpenschutz lief praktisch unsichtbar: 60 s Laufzeit, und reason=kick wurde nur gemeldet, wenn ein Abruf (alle 10 Min.) zufällig genau in diese 60 s fiel. Auf der Statusseite stand dann "nach Kalender", und im Langzeit-Gedächtnis blieb keine Spur des Laufs. shelly/heizung.js (1.2.0 -> 1.2.1): - kickSeconds 60 -> 180 (toggle_after zählt Sekunden, 60 war technisch korrekt; 3 Min. sind für Heizungspumpen üblich) - kickPending: der nächste Abruf meldet einmalig reason=kick, unabhängig vom Timing - Meldung 2 s nach Start und 3 s nach Laufende, damit die Laufzeit-Zählung des Apps Script die wirklichen Minuten bekommt - Datum des Laufs in KVS heizung_lastkick (beim Start geladen, überlebt Neustart) und in jeder Meldung als &kick=JJJJ-MM-TT - evaluate() setzt kickUntil/kickPending zurück, wenn der Kalender während des Laufs übernimmt apps-script/Code.gs: - STATUS.kick speichert das gemeldete Datum (ein leerer Wert überschreibt nicht) - Statusseite Abschnitt Technik: "Letzter Pumpenschutz: Mo 26.10.2026" - Grundtext für kick ohne "1 Min." shelly/test/simulation.js (neu): lädt heizung.js unverändert unter Node, stellt die Shelly-API nach und prüft 52 Fälle - Datum/Sommerzeit/Jahreswechsel, Kalender, manuell, KVS, Zeitfenster, Wochentag, Wiederholsperre, Meldung während und nach dem Lauf, Fallback ohne passendes Timing, Neustart mit KVS, Vorrang des Kalenders. Alle 52 OK. Doku: README.md und CLAUDE.md aktualisiert (3 Min., Sichtbarkeit, Rollout). Deployment von Hand, da der Updater auf dem Gerät pausiert ist: - Apps Script: Code.gs ersetzen -> Bereitstellungen verwalten -> Neue Version - Shelly: v1.2.1 einspielen (Updater starten oder Skript von Hand kopieren)
This commit is contained in:
1 parent
de55e20abd
commit
2df3df94ec
5 files changed
+388
-21
No files matched your search
+28
-5
@@ -8,8 +8,10 @@
|
||||
// - Uhrzeit unbekannt (Neustart ohne Internet): Relais AN (Frostschutz)
|
||||
// - Manuelles Schalten (Shelly-App, Taster) bleibt bestehen, bis der Kalender das
|
||||
// nächste Mal wechselt (z. B. um Mitternacht)
|
||||
// - Pumpenschutz: einmal pro Woche (Standard Montag 10:00) läuft die Pumpe 1 Minute,
|
||||
// - Pumpenschutz: einmal pro Woche (Standard Montag 10:00) läuft die Pumpe 3 Minuten,
|
||||
// falls sie gerade aus ist – damit sie im Sommer nicht festsitzt. Klappt auch offline.
|
||||
// Der Lauf wird sofort und danach noch einmal gemeldet; sein Datum bleibt im
|
||||
// Gerätespeicher (KVS "heizung_lastkick") und ist so auf der Statusseite sichtbar.
|
||||
//
|
||||
// Einrichtung: siehe README.md, Abschnitt "Shelly".
|
||||
|
||||
@@ -20,16 +22,19 @@ let CONFIG = {
|
||||
switchId: 0,
|
||||
kickWeekday: 0, // Pumpenschutz-Lauf: 0 = Montag ... 6 = Sonntag
|
||||
kickMinute: 10 * 60, // Uhrzeit in Minuten nach Mitternacht (10:00)
|
||||
kickSeconds: 60, // Laufzeit
|
||||
version: "1.2.0",
|
||||
kickSeconds: 180, // Laufzeit
|
||||
version: "1.2.1",
|
||||
};
|
||||
|
||||
let KVS_KEY = "heizung_days";
|
||||
let KVS_KICK = "heizung_lastkick";
|
||||
|
||||
let days = []; // freigeschaltete Tage "JJJJ-MM-TT"
|
||||
let lastDesired = null; // zuletzt vom Skript gesetzter Zustand
|
||||
let kickDay = -1; // Tag (seit 1970) des letzten Pumpenschutz-Laufs
|
||||
let kickUntil = 0; // Uptime-Sekunden, bis zu denen der Lauf dauert
|
||||
let kickPending = false; // Kick gelaufen: beim nächsten Abruf einmal als "kick" melden
|
||||
let lastKick = ""; // Datum "JJJJ-MM-TT" des letzten Laufs (aus KVS, überlebt Neustart)
|
||||
|
||||
function pad(n) {
|
||||
return n < 10 ? "0" + n : "" + n;
|
||||
@@ -84,8 +89,15 @@ function checkKick() {
|
||||
kickDay = now.day;
|
||||
if (Shelly.getComponentStatus("switch:" + CONFIG.switchId).output) return; // läuft ohnehin
|
||||
kickUntil = uptime() + CONFIG.kickSeconds;
|
||||
kickPending = true;
|
||||
lastKick = now.date;
|
||||
Shelly.call("KVS.Set", { key: KVS_KICK, value: now.date });
|
||||
Shelly.call("Switch.Set", { id: CONFIG.switchId, on: true, toggle_after: CONFIG.kickSeconds });
|
||||
print("Pumpenschutz-Lauf für " + CONFIG.kickSeconds + " s");
|
||||
// Gleich melden („Pumpe läuft, Pumpenschutz“) und noch einmal nach dem Lauf: So wird der
|
||||
// Lauf auf der Statusseite sichtbar und die Laufzeit zählt nur die wirklichen Minuten.
|
||||
Timer.set(2000, false, poll);
|
||||
Timer.set((CONFIG.kickSeconds + 3) * 1000, false, poll);
|
||||
}
|
||||
|
||||
// Schaltet nur, wenn sich der Sollzustand ändert – so bleibt manuelles Schalten bestehen
|
||||
@@ -94,6 +106,7 @@ function evaluate() {
|
||||
if (want.on !== lastDesired) {
|
||||
lastDesired = want.on;
|
||||
kickUntil = 0;
|
||||
kickPending = false;
|
||||
Shelly.call("Switch.Set", { id: CONFIG.switchId, on: want.on });
|
||||
print("Pumpe " + (want.on ? "AN" : "AUS") + " (" + want.reason + ", " + want.today + ")");
|
||||
}
|
||||
@@ -104,12 +117,17 @@ function poll() {
|
||||
evaluate(); // erst schalten, dann den aktuellen Zustand melden
|
||||
let out = Shelly.getComponentStatus("switch:" + CONFIG.switchId).output;
|
||||
let want = desiredState();
|
||||
let reason = out === want.on ? want.reason : (uptime() < kickUntil ? "kick" : "manual");
|
||||
// Grund: Der Pumpenschutz-Lauf hat Vorrang – und wird auch dann einmal als „kick“
|
||||
// gemeldet, wenn kein Abruf genau in seine Laufzeit fällt
|
||||
let reason;
|
||||
if (uptime() < kickUntil) reason = "kick"; // läuft gerade
|
||||
else if (kickPending) { reason = "kick"; kickPending = false; } // lief, Meldung stand aus
|
||||
else reason = out === want.on ? want.reason : "manual";
|
||||
let wifi = Shelly.getComponentStatus("wifi");
|
||||
let rssi = wifi && wifi.rssi ? wifi.rssi : "";
|
||||
|
||||
let url = CONFIG.url + "?key=" + CONFIG.key + "&relay=" + (out ? 1 : 0) + "&mode=auto&reason=" + reason +
|
||||
"&fw=shelly-" + CONFIG.version + "&rssi=" + rssi;
|
||||
"&fw=shelly-" + CONFIG.version + "&rssi=" + rssi + "&kick=" + lastKick;
|
||||
|
||||
Shelly.call("HTTP.GET", { url: url, timeout: 30 }, function (res, errCode, errMsg) {
|
||||
if (errCode !== 0 || !res) {
|
||||
@@ -144,6 +162,11 @@ function poll() {
|
||||
});
|
||||
}
|
||||
|
||||
// Datum des letzten Pumpenschutz-Laufs laden (überlebt einen Neustart)
|
||||
Shelly.call("KVS.Get", { key: KVS_KICK }, function (res, errCode) {
|
||||
if (errCode === 0 && res && res.value) lastKick = res.value;
|
||||
});
|
||||
|
||||
// Start: Schlüssel und gespeicherte Tage laden, dann schalten und abrufen
|
||||
Shelly.call("KVS.Get", { key: "heizung_key" }, function (res, errCode) {
|
||||
if (!CONFIG.key && errCode === 0 && res && res.value) CONFIG.key = res.value;
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
// Simulation des Shelly-Heizungsskripts unter Node.
|
||||
//
|
||||
// Lädt shelly/heizung.js UNVERÄNDERT, stellt die Shelly-API nach (Shelly.call,
|
||||
// Shelly.getComponentStatus, Timer, print) und prüft Datum/Uhrzeit, Kalenderlogik,
|
||||
// Pumpenschutz und die Meldungen an das Apps Script.
|
||||
//
|
||||
// Ausführen: node shelly/test/simulation.js
|
||||
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const vm = require("vm");
|
||||
|
||||
const SRC = path.join(__dirname, "..", "heizung.js");
|
||||
|
||||
// Macht die internen Zustände des Skripts für die Prüfung lesbar, ohne es zu ändern
|
||||
const HOOK = `
|
||||
;globalThis.__t = {
|
||||
CONFIG: CONFIG,
|
||||
days: function () { return days; },
|
||||
lastDesired: function () { return lastDesired; },
|
||||
kickUntil: function () { return kickUntil; },
|
||||
kickPending: function () { return kickPending; },
|
||||
lastKick: function () { return lastKick; },
|
||||
localNow: localNow,
|
||||
desiredState: desiredState,
|
||||
evaluate: evaluate,
|
||||
poll: poll
|
||||
};
|
||||
`;
|
||||
|
||||
function pad(n) { return n < 10 ? "0" + n : "" + n; }
|
||||
|
||||
// Ortszeit -> Shelly-Uhr: {unixtime (UTC-Sekunden), time "HH:MM"}
|
||||
// offsetMin = UTC-Versatz (60 = MEZ, 120 = MESZ); das Skript errechnet ihn selbst
|
||||
function clock(iso, hh, mm, offsetMin) {
|
||||
const midnight = Date.parse(iso + "T00:00:00Z") / 1000;
|
||||
return { unixtime: midnight + (hh * 60 + mm - offsetMin) * 60, time: pad(hh) + ":" + pad(mm) };
|
||||
}
|
||||
|
||||
// ---- Shelly-Stub: merkt sich alle Aufrufe und beantwortet sie sofort ----
|
||||
function makeShelly(state) {
|
||||
const calls = [];
|
||||
const kvs = state.kvs;
|
||||
return {
|
||||
calls: calls,
|
||||
getComponentStatus: function (name) {
|
||||
if (name === "sys") return { unixtime: state.unixtime, time: state.time, uptime: state.uptime };
|
||||
if (name === "wifi") return { rssi: state.rssi };
|
||||
if (name.indexOf("switch:") === 0) return { output: state.output };
|
||||
return {};
|
||||
},
|
||||
call: function (method, params, cb) {
|
||||
calls.push({ method: method, params: params });
|
||||
let res = {}, err = 0;
|
||||
if (method === "KVS.Get") {
|
||||
if (Object.prototype.hasOwnProperty.call(kvs, params.key)) res = { value: kvs[params.key] };
|
||||
else err = -104; // KEY_NOT_FOUND
|
||||
} else if (method === "KVS.Set") {
|
||||
kvs[params.key] = params.value;
|
||||
} else if (method === "Switch.Set") {
|
||||
state.output = !!params.on;
|
||||
if (params.toggle_after) state.flipBack = state.uptime + params.toggle_after;
|
||||
} else if (method === "HTTP.GET") {
|
||||
res = { code: 200, body: JSON.stringify({ ok: true, today: state.today, days: state.serverDays }) };
|
||||
}
|
||||
if (cb) cb(err === 0 ? res : null, err, err === 0 ? "" : "Fehler");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ---- Timer-Stub: Timer sammeln und gezielt auslösen ----
|
||||
function makeTimer() {
|
||||
const list = [];
|
||||
return {
|
||||
list: list,
|
||||
set: function (ms, repeat, fn) { list.push({ ms: ms, repeat: repeat, fn: fn }); return list.length; },
|
||||
fire: function (ms) {
|
||||
const run = list.filter(function (t) { return t.ms === ms; });
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
if (list[i].ms === ms && !list[i].repeat) list.splice(i, 1);
|
||||
}
|
||||
run.forEach(function (t) { t.fn(); });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Gerät starten: opts = {at: clock(...), uptime, rssi, today, serverDays, kvs}
|
||||
function boot(opts) {
|
||||
opts = opts || {};
|
||||
const at = opts.at || { unixtime: 0, time: "" };
|
||||
const state = {
|
||||
unixtime: at.unixtime,
|
||||
time: at.time,
|
||||
uptime: opts.uptime === undefined ? 100 : opts.uptime,
|
||||
output: false,
|
||||
rssi: opts.rssi === undefined ? -49 : opts.rssi,
|
||||
today: opts.today || "2026-10-26",
|
||||
serverDays: opts.serverDays || [],
|
||||
kvs: Object.assign({ heizung_key: "testkey" }, opts.kvs || {}),
|
||||
flipBack: 0
|
||||
};
|
||||
const shelly = makeShelly(state);
|
||||
const timer = makeTimer();
|
||||
const logs = [];
|
||||
const sandbox = {
|
||||
Shelly: shelly,
|
||||
Timer: timer,
|
||||
print: function (s) { logs.push(String(s)); }
|
||||
};
|
||||
vm.runInNewContext(fs.readFileSync(SRC, "utf8") + HOOK, sandbox, { filename: "heizung.js" });
|
||||
return { state: state, shelly: shelly, timer: timer, logs: logs, t: sandbox.__t };
|
||||
}
|
||||
|
||||
// ---- Prüfhelfer ----
|
||||
let pass = 0, fail = 0;
|
||||
function check(name, cond, info) {
|
||||
if (cond) { pass++; console.log(" OK " + name); }
|
||||
else { fail++; console.log(" FEHL " + name + (info === undefined ? "" : " -> " + info)); }
|
||||
}
|
||||
function callsOf(env, method) {
|
||||
return env.shelly.calls.filter(function (c) { return c.method === method; });
|
||||
}
|
||||
function kickCalls(env) {
|
||||
return callsOf(env, "Switch.Set").filter(function (c) { return c.params.toggle_after; });
|
||||
}
|
||||
function lastUrl(env) {
|
||||
const g = callsOf(env, "HTTP.GET");
|
||||
return g.length ? g[g.length - 1].params.url : "";
|
||||
}
|
||||
function param(url, name) {
|
||||
const m = url.match(new RegExp("[&?]" + name + "=([^&]*)"));
|
||||
return m ? m[1] : null;
|
||||
}
|
||||
function atClock(env, iso, hh, mm, offsetMin, uptime) {
|
||||
const c = clock(iso, hh, mm, offsetMin);
|
||||
env.state.unixtime = c.unixtime;
|
||||
env.state.time = c.time;
|
||||
if (uptime !== undefined) env.state.uptime = uptime;
|
||||
}
|
||||
|
||||
const MEZ = 60, MESZ = 120;
|
||||
const MO = "2026-10-26"; // ein Montag (Winterzeit)
|
||||
const DI = "2026-10-27";
|
||||
|
||||
console.log("Datum und Uhrzeit");
|
||||
{
|
||||
const e = boot({ at: clock(MO, 10, 0, MEZ) });
|
||||
const now = e.t.localNow();
|
||||
check("Montag 10:00 MEZ: Datum", now.date === MO, now.date);
|
||||
check("Montag: weekday 0", now.weekday === 0, now.weekday);
|
||||
check("10:00: minute 600", now.minute === 600, now.minute);
|
||||
}
|
||||
{
|
||||
const e = boot({ at: clock("2026-07-27", 10, 0, MESZ) });
|
||||
const now = e.t.localNow();
|
||||
check("Sommerzeit: Datum stimmt", now.date === "2026-07-27", now.date);
|
||||
check("Sommerzeit: minute 600", now.minute === 600, now.minute);
|
||||
check("Sommerzeit: Montag erkannt", now.weekday === 0, now.weekday);
|
||||
}
|
||||
{
|
||||
const e = boot({ at: clock("2026-12-31", 23, 59, MEZ) });
|
||||
check("Silvester 23:59", e.t.localNow().date === "2026-12-31", e.t.localNow().date);
|
||||
atClock(e, "2027-01-01", 0, 1, MEZ);
|
||||
check("Neujahr 00:01", e.t.localNow().date === "2027-01-01", e.t.localNow().date);
|
||||
}
|
||||
{
|
||||
const e = boot({}); // Neustart ohne Uhrzeit
|
||||
check("ohne Uhrzeit: localNow null", e.t.localNow() === null);
|
||||
check("ohne Uhrzeit: Failsafe AN", e.t.desiredState().reason === "failsafe" && e.state.output === true);
|
||||
check("ohne Uhrzeit: kein Pumpenschutz", kickCalls(e).length === 0);
|
||||
}
|
||||
|
||||
console.log("Kalender");
|
||||
{
|
||||
const e = boot({ at: clock(MO, 9, 0, MEZ), kvs: { heizung_days: MO } });
|
||||
check("freigeschalteter Tag: Relais AN", e.state.output === true && e.t.lastDesired() === true);
|
||||
}
|
||||
{
|
||||
const e = boot({ at: clock(MO, 9, 0, MEZ) });
|
||||
check("kein Termin: Relais AUS", e.state.output === false && e.t.lastDesired() === false);
|
||||
e.state.output = true; // von Hand (App/Taster) eingeschaltet
|
||||
e.t.evaluate();
|
||||
check("manuelles Schalten bleibt", e.state.output === true);
|
||||
e.t.poll();
|
||||
check("manuell wird als manual gemeldet", param(lastUrl(e), "reason") === "manual", lastUrl(e));
|
||||
}
|
||||
{
|
||||
const e = boot({ at: clock(MO, 9, 0, MEZ), serverDays: ["2026-10-30"] });
|
||||
e.t.poll();
|
||||
check("neue Tage vom Server übernommen", e.t.days().join(",") === "2026-10-30", e.t.days().join(","));
|
||||
const kvs = callsOf(e, "KVS.Set").filter(function (c) { return c.params.key === "heizung_days"; });
|
||||
check("neue Tage im KVS gesichert", kvs.length === 1 && kvs[0].params.value === "2026-10-30");
|
||||
}
|
||||
|
||||
console.log("Pumpenschutz");
|
||||
|
||||
// ganzer Ablauf an einem Montag: auslösen, melden, Lauf endet, weitermelden
|
||||
const e = boot({ at: clock(MO, 9, 59, MEZ) });
|
||||
check("09:59: noch kein Lauf", kickCalls(e).length === 0);
|
||||
|
||||
atClock(e, MO, 10, 0, MEZ);
|
||||
e.t.evaluate();
|
||||
const ks = kickCalls(e);
|
||||
check("10:00: Lauf gestartet", ks.length === 1, ks.length);
|
||||
check("Laufzeit 180 s (toggle_after)", ks.length === 1 && ks[0].params.toggle_after === 180,
|
||||
ks.length ? ks[0].params.toggle_after : "-");
|
||||
check("Relais während des Laufs AN", e.state.output === true);
|
||||
check("Datum im KVS gesichert", e.state.kvs.heizung_lastkick === MO, e.state.kvs.heizung_lastkick);
|
||||
check("Log-Zeile geschrieben", e.logs.some(function (s) { return s.indexOf("Pumpenschutz-Lauf") >= 0; }),
|
||||
e.logs.join(" | "));
|
||||
check("zwei Nachmeldungen geplant",
|
||||
e.timer.list.some(function (t) { return t.ms === 2000; }) &&
|
||||
e.timer.list.some(function (t) { return t.ms === 183000; }));
|
||||
|
||||
e.timer.fire(2000); // Meldung während des Laufs
|
||||
check("Meldung im Lauf: relay=1", param(lastUrl(e), "relay") === "1", lastUrl(e));
|
||||
check("Meldung im Lauf: reason=kick", param(lastUrl(e), "reason") === "kick", lastUrl(e));
|
||||
check("Meldung im Lauf: kick-Datum dabei", param(lastUrl(e), "kick") === MO, lastUrl(e));
|
||||
|
||||
e.state.uptime += 183; // Lauf ist vorbei, das Gerät hat wieder ausgeschaltet
|
||||
e.state.output = false;
|
||||
e.timer.fire(183000);
|
||||
check("Meldung nach dem Lauf: relay=0", param(lastUrl(e), "relay") === "0", lastUrl(e));
|
||||
check("Meldung nach dem Lauf: reason=kick", param(lastUrl(e), "reason") === "kick", lastUrl(e));
|
||||
check("Flag danach verbraucht", e.t.kickPending() === false);
|
||||
|
||||
e.t.poll();
|
||||
check("danach wieder reason=calendar", param(lastUrl(e), "reason") === "calendar", lastUrl(e));
|
||||
check("kick-Datum bleibt in jeder Meldung", param(lastUrl(e), "kick") === MO, lastUrl(e));
|
||||
|
||||
// kein Lauf, wenn die Pumpe ohnehin läuft
|
||||
{
|
||||
const x = boot({ at: clock(MO, 10, 0, MEZ), kvs: { heizung_days: MO } });
|
||||
check("Kalendertag: Relais AN", x.state.output === true);
|
||||
check("Kalendertag: kein zusätzlicher Lauf", kickCalls(x).length === 0);
|
||||
}
|
||||
// Zeitfenster 10:00 bis 10:09
|
||||
{
|
||||
const x = boot({ at: clock(MO, 9, 59, MEZ) });
|
||||
atClock(x, MO, 9, 59, MEZ); x.t.evaluate();
|
||||
check("09:59: kein Lauf", kickCalls(x).length === 0);
|
||||
atClock(x, MO, 10, 9, MEZ); x.t.evaluate();
|
||||
check("10:09: Lauf noch im Fenster", kickCalls(x).length === 1, kickCalls(x).length);
|
||||
}
|
||||
{
|
||||
const x = boot({ at: clock(MO, 10, 10, MEZ) });
|
||||
check("10:10: Fenster vorbei", kickCalls(x).length === 0);
|
||||
}
|
||||
{
|
||||
const x = boot({ at: clock(DI, 10, 0, MEZ) });
|
||||
check("Dienstag: kein Lauf", kickCalls(x).length === 0);
|
||||
}
|
||||
{
|
||||
const x = boot({ at: clock(MO, 10, 0, MEZ) });
|
||||
atClock(x, MO, 10, 1, MEZ); x.t.evaluate();
|
||||
atClock(x, MO, 10, 2, MEZ); x.t.evaluate();
|
||||
check("nur ein Lauf pro Tag", kickCalls(x).length === 1, kickCalls(x).length);
|
||||
}
|
||||
// Fallback: kein Abruf fällt zufällig in die 180 Laufsekunden
|
||||
{
|
||||
const x = boot({ at: clock(MO, 10, 0, MEZ) });
|
||||
check("Fallback: Lauf gestartet", kickCalls(x).length === 1);
|
||||
x.state.uptime += 600; // erst 10 Minuten später meldet das Skript
|
||||
x.state.output = false;
|
||||
x.t.poll();
|
||||
check("Fallback: trotzdem einmal kick", param(lastUrl(x), "reason") === "kick", lastUrl(x));
|
||||
x.t.poll();
|
||||
check("Fallback: danach calendar", param(lastUrl(x), "reason") === "calendar", lastUrl(x));
|
||||
}
|
||||
// Neustart: das Datum des letzten Laufs kommt aus dem Gerätespeicher
|
||||
{
|
||||
const x = boot({ at: clock(MO, 12, 0, MEZ), kvs: { heizung_lastkick: "2026-10-19" } });
|
||||
check("Neustart: letzter Lauf geladen", x.t.lastKick() === "2026-10-19", x.t.lastKick());
|
||||
x.t.poll();
|
||||
check("Neustart: Datum wird gemeldet", param(lastUrl(x), "kick") === "2026-10-19", lastUrl(x));
|
||||
}
|
||||
// Kalender übernimmt während des Laufs -> kein falscher Grund
|
||||
{
|
||||
const x = boot({ at: clock(MO, 10, 0, MEZ), serverDays: [MO] });
|
||||
check("Wechsel: Lauf gestartet", kickCalls(x).length === 1);
|
||||
x.t.poll(); // holt den freigeschalteten Tag und schaltet AN
|
||||
check("Wechsel: Pumpe AN", x.state.output === true);
|
||||
check("Wechsel: Flag zurückgesetzt", x.t.kickPending() === false);
|
||||
x.timer.fire(3000); // Nachmeldung nach dem Zustandswechsel
|
||||
check("Wechsel: reason=calendar", param(lastUrl(x), "reason") === "calendar", lastUrl(x));
|
||||
}
|
||||
|
||||
console.log("Version und Updater");
|
||||
{
|
||||
const x = boot({ at: clock(MO, 9, 0, MEZ) });
|
||||
check("Version 1.2.1", x.t.CONFIG.version === "1.2.1", x.t.CONFIG.version);
|
||||
check("Laufzeit 180 s eingestellt", x.t.CONFIG.kickSeconds === 180, x.t.CONFIG.kickSeconds);
|
||||
check("Endmarke für den Updater vorhanden",
|
||||
fs.readFileSync(SRC, "utf8").indexOf("// ENDE heizung.js") >= 0);
|
||||
const v = fs.readFileSync(SRC, "utf8").match(/version: "([^"]+)"/);
|
||||
check("Updater findet die Versionsnummer", v && v[1] === "1.2.1", v && v[1]);
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log(pass + " OK, " + fail + " fehlgeschlagen");
|
||||
process.exit(fail === 0 ? 0 : 1);
|
||||
Reference in new issue
Block a user