From be25e0ff28d64778d8f1a5988eee7000df7826f9 Mon Sep 17 00:00:00 2001 From: KevinWieland Date: Fri, 19 Dec 2025 12:58:36 +0100 Subject: [PATCH] getlastliveJson always formatted as json --- simpleAPI/simpleapi.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/simpleAPI/simpleapi.php b/simpleAPI/simpleapi.php index 44002d3f01..1aa678ee0d 100644 --- a/simpleAPI/simpleapi.php +++ b/simpleAPI/simpleapi.php @@ -125,9 +125,14 @@ public function handleRequest() } // Einzelner Parameter: Raw-Output verwenden - echo $this->formatRawOutput($result); + echo $this->formatRawOutput($result, $paramName); } else { - echo json_encode($result); + // Für get_lastlivevaluesjson: JSON direkt ausgeben auch ohne raw=true + if (count($readParams) === 1 && array_keys($readParams)[0] === 'get_lastlivevaluesjson') { + echo $this->formatRawOutput($result, 'get_lastlivevaluesjson'); + } else { + echo json_encode($result); + } } return; } @@ -481,12 +486,17 @@ private function getSuccessMessage($param, $value, $chargepointId) /** * Raw-Ausgabe formatieren */ - private function formatRawOutput($data) + private function formatRawOutput($data, $paramName = null) { if (is_array($data)) { $firstKey = array_keys($data)[0]; $firstValue = $data[$firstKey]; + // Für get_lastlivevaluesjson: JSON direkt zurückgeben + if ($paramName === 'get_lastlivevaluesjson' && is_string($firstValue)) { + return $firstValue; + } + // Für JSON-Strings: direkt den String-Wert zurückgeben if (is_string($firstValue)) { return $firstValue;