diff --git a/Bat_EV_SDL_V4/module.php b/Bat_EV_SDL_V4/module.php index b22c77e..46f981b 100644 --- a/Bat_EV_SDL_V4/module.php +++ b/Bat_EV_SDL_V4/module.php @@ -135,7 +135,8 @@ class Bat_EV_SDL_V4 extends IPSModule "SDL_W" => round((float)GetValue($this->GetIDForIdent("Aktuelle_Leistung_SDL")), 0) ]; - $this->SetIdentValue("CalcJSON", json_encode($calc, JSON_PRETTY_PRINT)); + $calcRounded = $this->RoundArray($calc, 3); + $this->SetIdentValue("CalcJSON", json_encode($calcRounded, JSON_PRETTY_PRINT)); } catch (Throwable $e) { $this->SendDebug("Update ERROR", $e->getMessage() . " @ " . $e->getFile() . ":" . $e->getLine(), 0); @@ -796,6 +797,22 @@ class Bat_EV_SDL_V4 extends IPSModule } } + private function RoundArray($data, int $decimals = 3) + { + if (is_array($data)) { + foreach ($data as $k => $v) { + $data[$k] = $this->RoundArray($v, $decimals); + } + return $data; + } + + if (is_float($data)) { + return round($data, $decimals); + } + + return $data; + } + private function SetIdentValue(string $ident, $value): void { $id = @$this->GetIDForIdent($ident);