no message
This commit is contained in:
@@ -208,35 +208,38 @@ class PV_Forecast extends IPSModule
|
|||||||
private function GetForecastSeriesFilteredUtc(int $startUtcTs, int $endUtcTs): array
|
private function GetForecastSeriesFilteredUtc(int $startUtcTs, int $endUtcTs): array
|
||||||
{
|
{
|
||||||
$raw = $this->GetBuffer("ForecastRaw");
|
$raw = $this->GetBuffer("ForecastRaw");
|
||||||
if ($raw === "") {
|
if ($raw === "") return [];
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = json_decode($raw, true);
|
$data = json_decode($raw, true);
|
||||||
if (!is_array($data) || !isset($data["estimated_actuals"]) || !is_array($data["estimated_actuals"])) {
|
if (!is_array($data)) return [];
|
||||||
|
|
||||||
|
// forecast endpoint: "forecasts"
|
||||||
|
if (isset($data["forecasts"]) && is_array($data["forecasts"])) {
|
||||||
|
$rows = $data["forecasts"];
|
||||||
|
} elseif (isset($data["estimated_actuals"]) && is_array($data["estimated_actuals"])) {
|
||||||
|
// fallback live endpoint
|
||||||
|
$rows = $data["estimated_actuals"];
|
||||||
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$series = [];
|
$series = [];
|
||||||
foreach ($data["estimated_actuals"] as $row) {
|
foreach ($rows as $row) {
|
||||||
if (!isset($row["period_end"], $row["pv_power_rooftop"])) continue;
|
if (!isset($row["period_end"], $row["pv_power_rooftop"])) continue;
|
||||||
|
|
||||||
// period_end ist UTC ("Z")
|
$ts = strtotime($row["period_end"]); // UTC wegen Z
|
||||||
$ts = strtotime($row["period_end"]);
|
|
||||||
if ($ts === false) continue;
|
if ($ts === false) continue;
|
||||||
|
|
||||||
// Filter: "heute lokal" als UTC-Grenzen
|
|
||||||
if ($ts < $startUtcTs || $ts >= $endUtcTs) continue;
|
if ($ts < $startUtcTs || $ts >= $endUtcTs) continue;
|
||||||
|
|
||||||
// Solcast: kW
|
$series[] = [$ts * 1000, (float)$row["pv_power_rooftop"]];
|
||||||
$val = (float)$row["pv_power_rooftop"];
|
|
||||||
$series[] = [$ts * 1000, $val];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($series, fn($a, $b) => $a[0] <=> $b[0]);
|
usort($series, fn($a, $b) => $a[0] <=> $b[0]);
|
||||||
return $series;
|
return $series;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------- Series: Actual (Archive) -----------------
|
// ----------------- Series: Actual (Archive) -----------------
|
||||||
|
|
||||||
private function GetActualSeriesFromArchive(int $startTs, int $endTs, int $bucketSeconds, int $nowTs): array
|
private function GetActualSeriesFromArchive(int $startTs, int $endTs, int $bucketSeconds, int $nowTs): array
|
||||||
|
|||||||
Reference in New Issue
Block a user