HTML binding with json

I’m trying to get json data from a http server with this item:

String  Weer    "Temperature [%s]" {http="<[]"}

And this javascript:


This is the json data:

  "temp": "11"

Hoping that the string would turn up 11 in my sitemap, but I only get a ‘-’.
Nothing to see in the logs :frowning:
I must be doing something wrong but I can’t figure out what

cli indicates that http & javascript bindings are enabled:

openhab> bundle:list | grep JavaScript
213 │ Active   │  75 │ 0.10.0.oh240           │ Eclipse SmartHome JavaScript Transformation Service
openhab> bundle:list | grep HTTP
115 │ Active   │  80 │ 0.10.0.oh240           │ Eclipse SmartHome HTTP Interface Bundle

Somebody there that can figure this out?
PS opening the link in a browser gives me the Json. Tried first with JsonPath, same results.

What did you try in the JSONPATH transform, because that is a more appropriate transform to use in this case.

Your JS file is malformed. As documented it should look something like

(function(i) {
    return SON.parse(input).temp;

The JSONPATH should look something like

1 Like

Thanks @rlkoshak for your reply :slight_smile:

I’m using JSONPATH again like this:

String  Weer    "Temperature [%s]" {http="<['$.temp')]"}

using double quotes gave me an error so I replaced with single quotes.
Think JSONPATH is fine now I think, but I don’t see a connection coming in on my web server.
PS I’m using other ip adress cause I’m on other network now :wink:
Any ideas ??

I’m pretty sure you don’t put the path in quotes, not that I look at the docs.

1 Like

Hmm, even without the quotes I get the same result. In my sitemap I only get the string Temperature, the result is not displayed.
No errors or warnings in the logs and no connection to my http server.
Strange, according to the manual and some tutorials I went through it should work.

Found a strange error in the logs:

2019-03-04 20:55:06.400 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-http1': Permission denied

Any ideas?

How have you put this Item on your sitemap? Did you override the label?

How did you install OH? If you log into the Karaf console and run bundle:list, do you see http1 installed and active?

If not try Clear the Cache.

1 Like

Wow man, you are great! I thing openhab is still booting up (I only have Rest API, Home Builder and HAB panel) But I’m getting a response on my web server now :slight_smile: the thing is refreshing every 3 sec like I told it to! I will put that time much longer though. :wink:
What I did: I first cleared the cache and then I got an error that I had no rights to delete the folders, so I deleted them manually. Then I restarted OH and had a lot of errors in the logs like can’t find files. Restarted again and now everything looks OK.
I don’t know how to thank you if everything turns up all right :slight_smile:

Strange thing, PaperUI and the others never showed up.
I took a backup of all the things etc en did a remove and reinstall of openhab, still not working.
I guess I played around too much and now its time for a new image on my RPi. Probably deleted too much, I don’t know. But learned now how to clear the cache :wink:
Hope I never need it again.

Well, I’ll say that I’ve never needed to do it myself. But I know some users who have had to manually clear the cache after every upgrade. So keep your fingers crossed but don’t lose that link. :wink:

1 Like

Glad to hear you never needed it. I’ve been testing around a lot the last couple of days, I’m sure I made a mistake somewhere and messed up the whole system. But hey, that’s the pain you get when learning a new system. Glad I backed up all my files and have a second sd card prepared for cases like this.
Looking forward to start again with a blank image. I’ll press a reset button in my mind and start over again.
Thanks for being there for me. Really enjoyed this conversation.