From fcdb1c22a8cd86566af78084cc96f8020795eac1 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Mon, 4 May 2026 19:31:47 +0200 Subject: [PATCH] no message --- Bat_EV_SDL_V4/module.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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);