File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -276,7 +276,9 @@ private function getReadParameters($params)
276276 'get_pv_monthly_exported ' ,
277277 'get_pv_yearly_exported ' ,
278278 'get_pv_fault_str ' ,
279- 'get_pv_fault_state '
279+ 'get_pv_fault_state ' ,
280+ // System - Werte
281+ 'get_lastlivevaluesjson '
280282 ];
281283
282284 foreach ($ readableKeys as $ key ) {
@@ -485,9 +487,17 @@ private function formatRawOutput($data)
485487 $ firstKey = array_keys ($ data )[0 ];
486488 $ firstValue = $ data [$ firstKey ];
487489
490+ // Für JSON-Strings: direkt den String-Wert zurückgeben
491+ if (is_string ($ firstValue )) {
492+ return $ firstValue ;
493+ }
494+
488495 if (is_array ($ firstValue ) && count ($ firstValue ) === 1 ) {
489496 return array_values ($ firstValue )[0 ];
490497 }
498+
499+ // Für andere Array-Strukturen: ersten Wert zurückgeben
500+ return $ firstValue ;
491501 }
492502
493503 return $ data ;
Original file line number Diff line number Diff line change @@ -200,6 +200,9 @@ public function readParameter($param, $id)
200200 case 'get_pv_fault_state ' :
201201 return $ this ->getPvFaultState ($ id );
202202
203+ case 'get_lastlivevaluesjson ' :
204+ return $ this ->getLastLiveValuesJson ();
205+
203206 default :
204207 return null ;
205208 }
@@ -1531,4 +1534,24 @@ private function setBatMode($value)
15311534 return ['success ' => false , 'message ' => 'Error setting bat mode: ' . $ e ->getMessage ()];
15321535 }
15331536 }
1537+
1538+ /**
1539+ * Lese openWB/system/lastlivevaluesJson Topic 1:1 aus
1540+ */
1541+ private function getLastLiveValuesJson ()
1542+ {
1543+ $ topic = "openWB/graph/lastlivevaluesJson " ;
1544+ $ jsonValue = $ this ->mqttClient ->getValue ($ topic );
1545+
1546+ if ($ jsonValue === null ) {
1547+ return [
1548+ 'get_lastlivevaluesjson ' => null
1549+ ];
1550+ }
1551+
1552+ // JSON-String 1:1 zurückgeben
1553+ return [
1554+ 'get_lastlivevaluesjson ' => $ jsonValue
1555+ ];
1556+ }
15341557}
You can’t perform that action at this time.
0 commit comments