diff --git a/ajax/watering.php b/ajax/watering.php index 0320c49..f4c21ba 100644 --- a/ajax/watering.php +++ b/ajax/watering.php @@ -129,7 +129,8 @@ foreach ($zonen as $zone) {
- Zuletzt -- · -- + Zuletzt -- · --
+ Heute -- · Vortag --
diff --git a/js/solar/solarMQTT.js b/js/solar/solarMQTT.js index 9d5ac47..b2a33a2 100644 --- a/js/solar/solarMQTT.js +++ b/js/solar/solarMQTT.js @@ -31,9 +31,13 @@ const solarMQTT = { client.subscribe("Gartenwasser/vorn/status"); client.subscribe("Gartenwasser/vorn/Timers"); client.subscribe("Gartenwasser/vorn/LastWatering"); + client.subscribe("Gartenwasser/vorn/WateringToday"); + client.subscribe("Gartenwasser/vorn/LastWateringDay"); client.subscribe("Gartenwasser/hinten/status"); client.subscribe("Gartenwasser/hinten/Timers"); client.subscribe("Gartenwasser/hinten/LastWatering"); + client.subscribe("Gartenwasser/hinten/WateringToday"); + client.subscribe("Gartenwasser/hinten/LastWateringDay"); client.subscribe("Gartenwasser/AutoWatering/#"); }); client.on("error", function (error) { @@ -65,7 +69,8 @@ const solarMQTT = { if (topic === "Gartenwasser/vorn/Timers" || topic === "Gartenwasser/hinten/Timers") { wateringTimersLastSeen[topic] = Date.now(); } - if (topic.startsWith("Gartenwasser/") && (topic.endsWith("/status") || topic.endsWith("/Timers") || topic.endsWith("/LastWatering") || topic.endsWith("/RainStatus"))) { + if (topic.startsWith("Gartenwasser/") && (topic.endsWith("/status") || topic.endsWith("/Timers") || topic.endsWith("/LastWatering") || topic.endsWith("/RainStatus") + || topic.endsWith("/WateringToday") || topic.endsWith("/LastWateringDay"))) { updateWateringStatus(); } if (topic == "solarManager/P_Load") { @@ -818,6 +823,28 @@ var chartSettings = { }; } + // Tagesdatum im Format der Ventilsteuerung ("29.08.26"). + function wateringDayStamp(date) { + const zwei = (zahl) => String(zahl).padStart(2, "0"); + return zwei(date.getDate()) + "." + zwei(date.getMonth() + 1) + "." + zwei(date.getFullYear() % 100); + } + + // Tagessummen der Ventilsteuerung: WateringToday fuer den laufenden Tag, + // LastWateringDay fuer den letzten Tag, an dem ueberhaupt bewaessert wurde. + // Beide Nutzlasten tragen den zugehoerigen Tag als "wateringDay" mit. Bei + // WateringToday wird der geprueft - die Nachricht ist retained, nach einem + // Tageswechsel ohne Bewaesserung stuende sonst die Summe von gestern als + // "heute" in der Karte. + function wateringDayTotal(topic, subTopic, feld, valve, mussHeuteSein) { + const data = wateringJson(topic + "/" + subTopic); + if (!data) return { label: "--", day: "" }; + const tag = data.wateringDay || ""; + const sekunden = data[feld + valve]; + if (sekunden === undefined) return { label: "--", day: tag }; + if (mussHeuteSein && tag !== wateringDayStamp(new Date())) return { label: "--", day: tag }; + return { label: wateringTimeLabel(Number(sekunden)), day: tag }; + } + function wateringAutoActive(topic, mode) { const timers = wateringJson(topic + "/Timers"); return !!(timers && timers.auto === mode); @@ -973,6 +1000,10 @@ var chartSettings = { const history = wateringHistory(zone.topic, zone.valve); setzeZelle(`[data-watering-last='${key}']`, history.dateTime); setzeZelle(`[data-watering-duration='${key}']`, history.duration); + const heute = wateringDayTotal(zone.topic, "WateringToday", "wateringDurationTodaySecs", zone.valve, true); + const vortag = wateringDayTotal(zone.topic, "LastWateringDay", "wateringDurationDaySecs", zone.valve, false); + setzeZelle(`[data-watering-today='${key}']`, heute.label, heute.day && "Stand: " + heute.day); + setzeZelle(`[data-watering-prevday='${key}']`, vortag.label, vortag.day && "Bewässerungstag: " + vortag.day); const plan = wateringPlanText(zone.auto); setzeZelle(`[data-watering-plan='${key}']`, plan.text, plan.titel); });