no message
This commit is contained in:
@@ -110,9 +110,12 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->BuildBatteryPlan(true);
|
$this->BuildBatteryPlan(false);
|
||||||
|
|
||||||
$plan = json_decode($this->GetBufferSafe("BatPlanJSON"), true);
|
$plan = json_decode($this->GetBufferSafe("BatPlanJSON"), true);
|
||||||
|
|
||||||
|
$plan = $this->RefreshDynamicPlanValues($plan);
|
||||||
|
|
||||||
if (!is_array($plan) || empty($plan["bats"])) {
|
if (!is_array($plan) || empty($plan["bats"])) {
|
||||||
$this->WriteAllZero("plan empty/invalid");
|
$this->WriteAllZero("plan empty/invalid");
|
||||||
return;
|
return;
|
||||||
@@ -885,6 +888,58 @@ class Bat_EV_SDL_V4 extends IPSModule
|
|||||||
return $current + (($target > $current) ? $maxStep : -$maxStep);
|
return $current + (($target > $current) ? $maxStep : -$maxStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function RefreshDynamicPlanValues(array $plan): array
|
||||||
|
{
|
||||||
|
foreach ($plan["bats"] as &$bat) {
|
||||||
|
$socVarId = (int)($bat["socVarId"] ?? 0);
|
||||||
|
$capKWh = (float)($bat["capKWh"] ?? 0.0);
|
||||||
|
|
||||||
|
$realSocPct = $this->ReadSocPercent($socVarId);
|
||||||
|
$realKWh = $capKWh * $realSocPct / 100.0;
|
||||||
|
|
||||||
|
$minPhysicalKWh = (float)($bat["minPhysicalKWh"] ?? 0.0);
|
||||||
|
$underKWh = (float)($bat["underKWh"] ?? 0.0);
|
||||||
|
$upKWh = (float)($bat["upKWh"] ?? 0.0);
|
||||||
|
|
||||||
|
$bat["real_SOC_pct"] = round($realSocPct, 3);
|
||||||
|
$bat["real_kWh"] = round($realKWh, 3);
|
||||||
|
|
||||||
|
$bat["SDL_Discharge_kW"] =
|
||||||
|
($realKWh >= $minPhysicalKWh)
|
||||||
|
? (float)$bat["sdlShareKW_entladen"]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
$bat["EV_Discharge_kW"] =
|
||||||
|
($realKWh > $underKWh)
|
||||||
|
? (float)$bat["evShareKW_entladen"]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
$bat["EV_Charge_kW"] =
|
||||||
|
($realKWh < $upKWh)
|
||||||
|
? (float)$bat["evShareKW_laden"]
|
||||||
|
: 0.0;
|
||||||
|
|
||||||
|
$bat["SDL_Charge_kW"] =
|
||||||
|
(float)$bat["sdlShareKW_laden"];
|
||||||
|
}
|
||||||
|
unset($bat);
|
||||||
|
|
||||||
|
$plan["total"]["SDL_Charge_kW"] = 0.0;
|
||||||
|
$plan["total"]["SDL_Discharge_kW"] = 0.0;
|
||||||
|
$plan["total"]["EV_Charge_kW"] = 0.0;
|
||||||
|
$plan["total"]["EV_Discharge_kW"] = 0.0;
|
||||||
|
|
||||||
|
foreach ($plan["bats"] as $bat) {
|
||||||
|
$plan["total"]["SDL_Charge_kW"] += (float)$bat["SDL_Charge_kW"];
|
||||||
|
$plan["total"]["SDL_Discharge_kW"] += (float)$bat["SDL_Discharge_kW"];
|
||||||
|
$plan["total"]["EV_Charge_kW"] += (float)$bat["EV_Charge_kW"];
|
||||||
|
$plan["total"]["EV_Discharge_kW"] += (float)$bat["EV_Discharge_kW"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $plan;
|
||||||
|
}
|
||||||
|
|
||||||
private function SetIdentValue(string $ident, $value): void
|
private function SetIdentValue(string $ident, $value): void
|
||||||
{
|
{
|
||||||
$id = @$this->GetIDForIdent($ident);
|
$id = @$this->GetIDForIdent($ident);
|
||||||
|
|||||||
Reference in New Issue
Block a user