HTTP Binding and JSON

Tags: #<Tag:0x00007f6182c0c458> #<Tag:0x00007f6182c0c390> #<Tag:0x00007f6182c0c2c8>

Hi Guys!
I’m in trouble with HTTP Binding and JSON…

My http.cfg has

configuration of the first cache item
PGcache.url=http://…
PGcache.updateInterval=30000

It retrieve this JSON text:

{“info”:{“satid”:25544,“satname”:“SPACE STATION”,“transactionscount”:2,“passescount”:7},“passes”:[{“startAz”:303.81,“startAzCompass”:“NW”,“startEl”:17.12,“startUTC”:1583894535,“maxAz”:15.1,“maxAzCompass”:“NNE”,“maxEl”:25.3,“maxUTC”:1583894845,“endAz”:88.01,“endAzCompass”:“E”,“endEl”:0,“endUTC”:1583895150,“mag”:-0.2,“duration”:200},{“startAz”:301.89,“startAzCompass”:“NW”,“startEl”:17.31,“startUTC”:1583900345,“maxAz”:226.52,“maxAzCompass”:“SW”,“maxEl”:78.22,“maxUTC”:1583900670,“endAz”:127.72,“endAzCompass”:“SE”,“endEl”:0,“endUTC”:1583900990,“mag”:-2.3,“duration”:465},{“startAz”:303.76,“startAzCompass”:“NW”,“startEl”:63.28,“startUTC”:1583983885,“maxAz”:25.02,“maxAzCompass”:“NNE”,“maxEl”:65.51,“maxUTC”:1583984210,“endAz”:116.81,“endAzCompass”:“ESE”,“endEl”:0,“endUTC”:1583984530,“mag”:-2.2,“duration”:330},{“startAz”:290.21,“startAzCompass”:“WNW”,“startEl”:4.22,“startUTC”:1583989710,“maxAz”:227.46,“maxAzCompass”:“SW”,“maxEl”:17.16,“maxUTC”:1583990000,“endAz”:164.24,“endAzCompass”:“SSE”,“endEl”:0,“endUTC”:1583990285,“mag”:-0.2,“duration”:505},{“startAz”:295.27,“startAzCompass”:“WNW”,“startEl”:19.65,“startUTC”:1584073240,“maxAz”:223.51,“maxAzCompass”:“SW”,“maxEl”:27.87,“maxUTC”:1584073550,“endAz”:151.1,“endAzCompass”:“SSE”,“endEl”:0,“endUTC”:1584073855,“mag”:-0.9,“duration”:395},{“startAz”:299.12,“startAzCompass”:“WNW”,“startEl”:34.54,“startUTC”:1584156775,“maxAz”:221.06,“maxAzCompass”:“SW”,“maxEl”:46.56,“maxUTC”:1584157095,“endAz”:139.02,“endAzCompass”:“SE”,“endEl”:0,“endUTC”:1584157410,“mag”:-1.3,“duration”:255},{“startAz”:283.14,“startAzCompass”:“W”,“startEl”:10,“startUTC”:1584246160,“maxAz”:230.88,“maxAzCompass”:“SW”,“maxEl”:10.23,“maxUTC”:1584246415,“endAz”:178.82,“endAzCompass”:“S”,“endEl”:0,“endUTC”:1584246665,“mag”:0.4,“duration”:220}]}

My Item file:

String NextPass “Prossimo Passaggio” { http="<[PGcache:10000:JSONPATH($.passes[:1])]" }

My sitemap produces nothing…

Text item=NextPass label=“ISS Next Pass [%s]” icon=“iss1”

Each time I refresh the sitemap I get this error in events.log:

… [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.sitemap.Text

Thanks for any help!!
Alex

Do you see any errors in the log when loading your .item file? That error means that as far as OH is concerned, NextPass doesn’t exist as an Item.

Try restarting OH if you’ve recently cleared the cache or upgraded OH.

Hi Rich!
Thanks for your reply!
I have no errors when i save my .item file!
But it’s always null!!

{“link”:“http://192.168.1.30:8080/rest/items/NextPass",“state”:"NULL”,…

:roll_eyes: :roll_eyes:

Do you have a “loading model xxx.items” message, or “refreshing model …” ?
Note that it must be named like xxx.items , not xxx.item

File extension IS .items ! :tired_face: :tired_face:

2020-03-10 19:00:41.415 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘iss.items’

2020-03-10 19:00:42.456 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘iss.items’

That’s good. We cannot see and can only go on what you tell us.

You could create a temporary String Item without the JSONPATH to see if you’re getting the raw data.

I’m a bit suspicious of that colon

On it’s own? There’s usually an associated error identifying the offending Item by name.

I have restarted it a lot of times before creating this topic with no success!
Finally I did it: This time it started working!!

2020-03-10 19:12:00.582 [INFO ] [b.core.service.AbstractActiveService] - HTTP Refresh Service has been started

2020-03-10 19:12:04.807 [vent.ItemStateChangedEvent] - NextPass changed from NULL to {startAz=303.81, startAzCompass=NW, startEl=17.12, startUTC=1583894535, maxAz=15.1, maxAzCompass=NNE, maxEl=25.3, maxUTC=1583894845, endAz=88.01, endAzCompass=E, endEl=0, endUTC=1583895150, mag=-0.2, duration=200}

I really can’t imagine what was wrong…

Thank you guys and sorry…

Now it’s time to study how to read and store the different values…

If only there was a way to create a two-dimensional array…

I thank you for any suggestions!!!