diff --git a/Bat_EV_SDL_V4/module.php b/Bat_EV_SDL_V4/module.php index f297cdf..4230d2b 100644 --- a/Bat_EV_SDL_V4/module.php +++ b/Bat_EV_SDL_V4/module.php @@ -689,7 +689,7 @@ class Bat_EV_SDL_V4 extends IPSModule private function WriteBatteryPowerSetpoints(array $distribution): void { - IPS_LogMessage(__FUNCTION__, "distribution=" . json_encode($distribution, JSON_PRETTY_PRINT)); + //IPS_LogMessage(__FUNCTION__, "distribution=" . json_encode($distribution, JSON_PRETTY_PRINT)); $batteriesCfg = json_decode($this->ReadPropertyString("Batteries"), true); if (!is_array($batteriesCfg) || empty($batteriesCfg)) { @@ -727,6 +727,7 @@ class Bat_EV_SDL_V4 extends IPSModule $varPowerDisch = (int)($cfg["powerbat_entladen"] ?? 0); $varMode = (int)($cfg["register_ladenentladen_modus"] ?? 0); + /* $setInt = function (int $varId, int $value): void { if ($varId > 0 && IPS_VariableExists($varId)) { RequestAction($varId, $value); @@ -738,6 +739,28 @@ class Bat_EV_SDL_V4 extends IPSModule RequestAction($varId, (int)round(max(0.0, $w), 0)); } }; + */ + + $setInt = function (int $varId, int $value): void { + if ($varId > 0 && IPS_VariableExists($varId)) { + $old = (int)GetValue($varId); + + if ($old !== $value) { + RequestAction($varId, $value); + } + } + }; + + $setW = function (int $varId, float $w): void { + if ($varId > 0 && IPS_VariableExists($varId)) { + $new = (int)round(max(0.0, $w), 0); + $old = (int)GetValue($varId); + + if (abs($old - $new) > 50) { + RequestAction($varId, $new); + } + } + }; $modeCharge = 1; $modeDisch = 2;