Issue of the topic: old 2.5 config didn’t work with 3.0
I have a device that returns a json string:
{“Distanz”:68.50,“Heizung_Vorlauf”:37.94,“Heizung_Ruecklauf”:33.81,“Heizungskeller”:17.12}
In v2.5 I configured a http item
[http.cfg]
waterbox.url=http://192.168.168.24/json
waterbox.updateInterval=20000
[http.items]
Number Distanz “Fuellstand [%d %%]” { http="<[waterbox:60000:JSONPATH($.Distanz)]" }
JSONPath Transformation is installed.
Everything worked fine with Version 2.5
I tried the same configuration in version 3.0, installed the JSONPath Transformation and see the item in the List.
But it didn’t return a value. No error message in the logs.
This works and show a value.
But it doesn’t update the values in my persistance db. (other items are updated and saved)
So i will now try to find the update error.
I glad you got it working. You persist items not thing channels so create an item
maybe you missed it, in my last post I wrote: ok I created the Thing, added a channel and linked it to an item.
The item is created in the database with a value, but is not updated anymore.
Hi,
60000 means every minute. Should be possible. Anyway I changed the variable - nothing.
The only update in the db is after save the config (thing).
So for me it’s currently not working. Maybe someone should try a http config and test it.
Now I got two items, actually one should get the “energie” and the other one the “volumen” however second stays UNDEF even if I set it to “energie” just like the other one. Why is that?
Thanks Udo, this didn´t change it though I guess it was wrong anyway. However I found out that I missed the state transformation in the channel configuration and set it to JSONPATH:$.volumen. This works, I guess I´ll never understand the logic at all.
If looking at incomming data, there are some options to setup JSONPATH.
Data is received by a Binding (here http) through a channel. a) use a channel for each bit of information, so e.g. use a number channel and provide JSONPATH to extract one Number to the Channel b) use a string Channel to get the whole JSON Object.
Channel ist linked to an Item a) 1.a): As there is a simple Number, you can’t use JSONPATH anymore. b) 1.b): The String channel provides the whole JSON Object, so now you can extract Data in the link.
This is useful if there are many informations from the same JSON Object to be extracted. You will only need one Channel per JSON Object and just link as many Items to this Channel as you need.
Item Type is not limited to String but to the Type of data which is extracted. c) You can even use a String Item to get the whole JSON Object.
Item state
When not providing the whole JSON Object through a String Item 3.c), you simply can’t use JSONPATH.
If you are using a String Item with the whole JSON Object, you can use JSONPATH within the display Options and/or you can use transformation action within a rule.
So, there are three possible options to use JSONPATH, but you can only use it at one position.
To be honest, it would be nice to exclude transformation Services when it makes no sense to use them (e.g. channel is not of type string, so there can’t be a JSON Object), but it adds a lot more of complexity, so I guess the developers chose not to do so…
Udo, I saw examples for 1.a), but how does an example for 1.b) look like?
What is the syntax to define such a string that contains the whole JSON object?
The examples like the one below always extract just one value from the result.
Channels:
Type string : MyJSONresult "Status" [ stateTransformation="JSONPATH:$.statusInfo.status" ]