HTTP binding - openHAB 3 version

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.

Hi Jan,
I see no feedback from anyone.
Are you still working on this binding?
Will this be the binding to be integrated into OH3?
I think of testing the binding to be prepared for OH3.

Thanks Joerg

I think Itā€˜s mostly ready. Some documentation is missing.

Hi Jan,
I now installed the binding and added a thing and a channel.
But I allways get an authentication error.
Old HTTP binding:

name.url=http://<username>:<password>@<IP>/sc2_val.xml
name.updateInterval=30000

No matter how I tried to enter the URL into the the thing, I get an authentication error:
- Full URL: http://<username>:<password>@<IP>/sc2_val.xml
or
- URL: http://<IP>/sc2_val.xml and username/password in the separate fields
or
- The same but just http://<IP>/ and the XML extension entered in the channel definitiont

Regards Joerg

BTW: I added 3 other HTTP things/channels without authentication without any issues