no message

This commit is contained in:
belevo\mh
2026-01-21 08:08:07 +01:00
parent 63912b3606
commit 1207792810

View File

@@ -25,12 +25,19 @@ class PV_Forecast_plotmemory extends IPSModule
$this->RegisterPropertyString("SnapshotTime", "23:59"); // HH:MM
$this->RegisterPropertyInteger("KeepDays", 30);
// Important: Prevent tile from triggering URL fetch (strict daily behavior)
$this->RegisterPropertyBoolean("AllowTileFetchIfEmpty", false);
// Timer
$this->RegisterTimer("UpdateForecastTimer", 0, 'IPS_RequestAction($_IPS["TARGET"], "UpdateForecast", 0);');
$this->RegisterTimer("SnapshotTimer", 0, 'IPS_RequestAction($_IPS["TARGET"], "SnapshotTick", 0);');
// WebHook endpoint
$this->RegisterHook("/hook/solcastcompare_plotmemory");
// Persisted run markers (survive restarts)
$this->RegisterAttributeInteger("LastDailyRunForecast", 0);
$this->RegisterAttributeInteger("LastDailySnapshotRun", 0);
}
public function ApplyChanges()
@@ -46,7 +53,7 @@ class PV_Forecast_plotmemory extends IPSModule
$mins = max(1, (int)$this->ReadPropertyInteger("RefreshMinutes"));
$this->SetTimerInterval("UpdateForecastTimer", $mins * 60 * 1000);
} else {
// daily check each minute
// daily: check each minute
$this->SetTimerInterval("UpdateForecastTimer", 60 * 1000);
}
@@ -56,8 +63,6 @@ class PV_Forecast_plotmemory extends IPSModule
} else {
$this->SetTimerInterval("SnapshotTimer", 0);
}
$this->RegisterHook("/hook/solcastcompare");
}
public function RequestAction($Ident, $Value)
@@ -98,13 +103,13 @@ class PV_Forecast_plotmemory extends IPSModule
$now = time();
$nowSec = ((int)date("H", $now) * 3600) + ((int)date("i", $now) * 60);
$lastRun = (int)$this->GetBuffer("LastDailyRunForecast");
$lastRun = (int)$this->ReadAttributeInteger("LastDailyRunForecast");
$today0 = strtotime("today");
if ($nowSec >= $targetSec && $lastRun < $today0) {
$this->SendDebug("Scheduler", "Taegliches Forecast-Update (" . $timeStr . ")", 0);
$this->UpdateForecast();
$this->SetBuffer("LastDailyRunForecast", (string)$now);
$this->WriteAttributeInteger("LastDailyRunForecast", $now);
}
}
@@ -126,7 +131,8 @@ class PV_Forecast_plotmemory extends IPSModule
$now = time();
$nowSec = ((int)date("H", $now) * 3600) + ((int)date("i", $now) * 60);
$lastRun = (int)$this->GetBuffer("LastDailySnapshotRun");
// IMPORTANT: use Snapshot marker, not Forecast marker
$lastRun = (int)$this->ReadAttributeInteger("LastDailySnapshotRun");
$today0 = strtotime("today");
if ($nowSec >= $targetSec && $lastRun < $today0) {
@@ -140,7 +146,7 @@ class PV_Forecast_plotmemory extends IPSModule
$this->CreateDailySnapshotForDate(new DateTime('today', new DateTimeZone(date_default_timezone_get())));
$this->CleanupOldSnapshots();
$this->SetBuffer("LastDailySnapshotRun", (string)$now);
$this->WriteAttributeInteger("LastDailySnapshotRun", $now);
}
}
@@ -188,7 +194,9 @@ class PV_Forecast_plotmemory extends IPSModule
public function GetVisualizationTile(): string
{
if ($this->GetBuffer("ForecastRaw") === "") {
// Strict daily mode: do NOT fetch from URL when tile is opened.
// If you really want this fallback, enable AllowTileFetchIfEmpty.
if ($this->GetBuffer("ForecastRaw") === "" && $this->ReadPropertyBoolean("AllowTileFetchIfEmpty")) {
$this->UpdateForecast();
}
@@ -451,7 +459,6 @@ class PV_Forecast_plotmemory extends IPSModule
$forecastJson = json_encode($payload["series"]["forecast"] ?? []);
$actualJson = json_encode($payload["series"]["actual"] ?? []);
// Hinweis: nutzt Highcharts CDN. (Wenn du offline öffnen willst, sag Bescheid, dann liefern wir highcharts.js lokal mit.)
return '<!doctype html>
<html lang="de">
<head>
@@ -554,7 +561,7 @@ class PV_Forecast_plotmemory extends IPSModule
echo "No snapshots found";
return;
}
$kunde = trim($this->ReadPropertyString("kunde"));
$kunde = trim($this->ReadPropertyString("kunde"));
if ($kunde === "") {
$kunde = "unbekannt";