- Platform information:
- Hardware: Docker Image on Synology latest Version
- OS: what OS is used and which version
- Java Runtime Environment: which java platform is used and what version
- openHAB version: 3.2.
- Issue of the topic: How to split result from json?
Hi all
I want to transfer my existing OH2 into the new OH and want to collect data from my volkszähler.
IN OH2 I have a Item and a rule to collect the data
Example OH2
String Strom_tuples “Tiple Haushalt [%.1f W]” (Current) { http="<[http://192.168.xx.xx/middleware.php/data/.json?from=now&options=raw:60000:JSONPATH($.data.tuples)]" }
Number Strom_Stand “Zaehlerstand Haushalt [%.1f kWh]” (Current, Current_Chart)
and within a rule I extract the value for the Item “Strom_Stand”
rule “Tuples in Teilstring”
when
Item Strom_tuples changed
then
var String strTeil2 = Strom_tuples.toString.split(",").get(2)
Strom_Stand.sendCommand(strTeil2)
//logInfo("Strom", "Tuple getrennt")
end
OH3 Part
What I have created as channel
- id: Strom_tuples
channelTypeUID: http:string
label: Strom_tuples
description: “”
configuration:
mode: READONLY
stateTransformation: JSONPATH:$.data.tuples
But in the logfile I have this:
Could not transform state ‘UNDEF’ with function ‘JSONPATH:$.data.tuples’ and format ‘%s’
As value I receive in OH2
“12912989182,12222.222” (example)
How I have to configure the channel in OH3 that I can extract the second value (12222.222 from the example)
Hope, somebody can help