HTTP binding - openHAB 3 version

Up to now I’ve only added bindings through PaperUI, all things, items and sitemaps have been files.
I’ll try creating the thing in PaperUi.

You also could create a .things file. Configuration is explained here. But first you should try it with PaperUI to get confident with the new http2 binding.

An example of a thing file you can find here.

I’ve created a thing and channels in PaperUI but get the following error.

Executing transformation ChannelStateTransformation{pattern='($.(0).NWATT)', serviceName='JSONPATH'} failed: An error occurred while transforming JSON expression.

The pattern extracts the data I want on jsonpath.com

Please try: $.(0).NWATT (without the brackets)

See also here.

.
.
Btw. Did you read anything here in this topic?
.
.
EDIT: As I read here, it also could be: JSONPATH:$[0].NWATT

I’ve tried JSONPATH:($.(0).NWATT), JSONPATH:$.(0).NWATT and $.(0).NWATT in the StateTransformation of the channel and get exactly the same error.

I have ready through the thread, some is not relevant and some goes over my head.
I haven’t tried REGEX because I’m not familiar with it and it would be another thing I would have to learn. The JSONPATH transformation seemed the simplest way of extracting the data.
This is the data returned by the URL. ecostatus.txt (1.8 KB)

You also could try:

 JSONPATH:$[0].NWATT   (in PaperUI)

or in .things file

  [ stateTransformation="JSONPATH:$[0].NWATT" ]

No matter what variation I put in I get pattern=’($.(0).NWATT)’ in the error.
The last one was with no dot between $ and (0).

Potentially openHAB isn’t picking up changes in the things file? In this case, I usually corrupt the things file (just add some nonsense, or remove a "), then save. openHAB will complain and unload all the things from that file. Then restore the file (add the " back, or remove the nonsense) and save again - all the things will be reloaded.

@lesterb

Did you also try this?

I’m not using things or items files I’m doing everything in PaperUI until I get it working. I tried the square brackets but still got the same error. Why does the error contain pattern=’($.(0).WATT)’ no matter what syntax I use? Maybe that’s the clue.

this is my Thing in PaperUI

and this is one of the channels

image

No, you have to write the following under Configure channel:

I showed that in the list of variations above. I’ve put the JSONPATH: back in each of the channels but it makes no difference I still have exactly the same error.

Of course your data might not be what you expect.
Make a string channel/Item that shows you the whoile message, and share with us?

@rossko57

According to this page (https://jsonpath.herokuapp.com/), the following values are valid for JSONPATH:

$.[0].NWATT

or

 $[0].NWATT

I pasted the content of @lesterb s ecostatus.txt there. Then filled in a line below $[0].NWATT and then pressed Go!

And got the result: 2540.969

If that’s wrong, please enlighten me.

Hi Alex,

You are correct. I thought I had tried JSONPATH:$[0].NWATT before but I couldn’t have because that syntax stops the error.
However, it turns out I have a second error. I’m not reading the data.
When I run ecostatus.json I get the following error on the webpage.

SyntaxError: JSON.parse: unexpected character at line 105 column 28 of the JSON data

When I examine the page source the correct data is shown. If I login to the Ecomon I don’t get the error.
I’ve added the username and password in my thing but I still don’t see any data in the string channel I created. Thanks for the suggestion rossko.

Thanks Alex and Rossko for your help.
I have it working. Here is the info displayed in HABPanel.

1 Like

Is there an easy way to round the extracted number to zero decimal points using the JSONPATH command?

This really isn’t about the new HTML binding.

No, it extracts what is there.
You can use state presentation on your Item.

Thanks Rossko.
I’ll start a new thread on this topic.
Hope you can help me there…again.