OpenHAB3 http binding + jsonpath

  • Platform information:
    • Hardware: VM, 2 core CPU, 2 GB RAM
    • OS: Debian 10.7
    • Java Runtime Environment:11.0.9.1
    • openHAB version: 3.0.0
  • 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
grafik

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.

any hints ?

greetings,
Juergen

You are using the V1 HTTP binding configuration, but the V1 binding does not work and is not shipped with openHAB 3.

See here for the new binding information:

Hi,
thanks, but can you help me with this item ?
maybe an example.

regards
Jürgen

Unfortunately I cannot, as I don’t use the binding. Here is the forum thread for development of the binding. It’s long, but has some examples:

However, you will be encouraged to use the new MainUI to configure your Thing, as this should be less error prone.

1 Like

Please try in the Main UI

After installing the binding goto thing
Add new thing (blue + bottom right corner)
HTTP Url Thing

Then you will have to create a channel and item.

Hi and thank you,
ok I created the Thing, added a channel and linked it to an item.

UID: http:url:e7b04a55b1
label: Waterbox URL Thing
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.168.24/json
refresh: 60000
commandMethod: GET
timeout: 3000
bufferSize: 512
location: Keller
channels:

  • id: pegel001
    channelTypeUID: http:string
    label: waterlevel
    description: “”
    configuration:
    mode: READONLY
    stateTransformation: JSONPATH:$.Distanz

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.

Regards
Juergen

I glad you got it working. You persist items not thing channels so create an item

Hello,

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.

regards
Juergen

Yep I missed it was late. your channel refresh is 60000 so It should update a couple of times a day. Try setting it lower

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.

update:
The value refresh (Item -> Refresh time) is given in seconds not ms
the value 600 = 10 minutes

UID: http:url:e7b04a55b1
label: Waterbox URL Thing
thingTypeUID: http:url

refresh: 600
commandMethod: GET
timeout: 3000
bufferSize: 512

HAB_Thing

now I’ve got an update every 10 minutes:
HAB_db

regards
Juergen

1 Like

I just tried something similar but sadly my value stays NULL :-/

The thing:

The channel:

UID: http:url:PoolTemp
label: PoolTemp
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: true
baseURL: http://www.myurl.net/data/report/temperatur.json
refresh: 30
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
channels:

  • id: PoolTemp
    channelTypeUID: http:string
    label: PoolTemp
    description: “”
    configuration:
    mode: READONLY
    stateTransformation: JSONPATH:$.pooltemp

The json content:

{“pooltemp”:“24.8”}

Of course myurl is my url :wink:
Where is my mistake?

Did you already install JSONPATH Transformation?

3 Likes

Thanks! That indeed was my mistake.