Http Binding - strange behavior

Hello guys,
I am struggling with my http binding.

As far as i see - and copy/paste with my other things/items - I can not evaluate where my issue is:

thing

http:url:outdoorphoneCall "Gegensprechanlage Anruf" [ baseURL="http://192.168.0.58/api/call/status/", refresh=100] 
{
    Channels:
        Type string : callstatus "Callstatus" [ stateTransformation="JSONPATH:$.data.Status" ]
}

behind the baseURL the output is as follows:

{ “retcode”: 0, “action”: “status”, “message”: “OK”, “data”: { “Status”: “READY” } }

item

String OA_Gateway_CallStatus "Telefonstatus [%s]" (Phone) { channel="http:url:outdoorphoneCall:callstatus"}

status of OA_Gateway_CallStatus is “NULL”.

May someone can give me a hint on this topic.

many thanks in advance

Maybe only copy&paste error, but there is a missing closing curly bracket (Item definition)

JSONPATH seems ok to me (beside wrong quotes, which may be also a copy&paste error).

{
	"retcode": 0,
	"action": "status",
	"message": "OK",
	"data": {
		"Status": "READY"
	}
}

Hello,
thanks for your fast reply.
Unfortunately that wasn’t the issue …
(just a copy/paste error)

What do you mean with “wrong quotes”?

I get this from my device and just want to read the status out of it…

{
	"retcode": 0,
	"action": "status",
	"message": "OK",
	"data": {
		"Status": "READY"
	}
}

thanks for your help

Please take a closer look at your first quote of JSON (first post):

{ “retcode”: 0, “action”: “status”, “message”: “OK”, “data”: { “Status”: “READY” } }
formatted as code.
You’ll see the quotes are different from those in your second quote (last post):

{
	"retcode": 0,
	"action": "status",
	"message": "OK",
	"data": {
		"Status": "READY"
	}
}

It’s not as visible as it should be… But unfortunately this isn’t the issue either…

Just to be sure… You did install JSONPATH Transformation Service?

Hello,

thanks for your answer.
It seems, that I have a general issue with my http binding.
Need some further debug sessions > If i find a solution, i will give an update.

thanks in advance

Hello again,

okay, I am out of ideas:

I have a “http thing” for fetching the cheapest gasprices > works
My device at home (outdoor phone) is online, gives the data above and haven’t a authentification. > doesn’t work

no special settigns or anything else > wrote a short python script and everything is fine > only via OH3 it isn’t possible.

very pleased for any inupts

Guess what, we are out of ideas as well!
Especially when reading your last post.
What is the information about the (working) http thing for gas prices for?
You tell that your “outdoor phone” is online and is giving data. So far all good, but “…haven’t a authentification. > doesn’t work”???
Then you are talking about a working pyton script, which isn’t wotürking via openHAB.
You started off with a problem using the HTTP binding and now you are trying a python script.
I m lost!

Many thanks for your professional input…

a) I just wanted to say, that the http binding is working
b) with the python script i just wanted to mention, that the device is “reachable” from my machine and i get an answer.

So I am open for further questions so that i can evaluate the issue.

Please share the used (working) python script.
Additionally please share any log-entries from the (not working) http thing/item.

Hello,

python script:

import urllib.request, json 
from jsonpath_ng import jsonpath, parse
with urllib.request.urlopen("http://192.168.0.58/api/call/status") as url:
    data = json.loads(url.read().decode())
    print(data)

    Status = data['data']
    print(Status)

output = parse('data.Status')

for match in output.find(data):
    print(f'{match.value}')

oddly enough, there aren’t any specific log-entries due to any errors. This was my first way before i posted something. Unfortunately I have to search, why I don’t have any ERROR or WARN entries.
These are the main entries i got currently:

2022-08-12 19:30:11.138 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:Akuvox’ changed from ONLINE to UNINITIALIZED

==> /var/log/openhab/openhab.log <==

2022-08-12 19:30:11.170 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Stopped refresh task for URL ‘http://192.168.0.58/api/call/status

2022-08-12 19:30:11.172 [TRACE] [.HttpDynamicStateDescriptionProvider] - removing state description for thing http:url:Akuvox

==> /var/log/openhab/events.log <==

2022-08-12 19:30:11.182 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:Akuvox’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2022-08-12 19:30:11.194 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:outdoorphone’ changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab/openhab.log <==

2022-08-12 19:30:11.211 [DEBUG] [nding.http.internal.HttpThingHandler] - No authentication configured for thing ‘http:url:outdoorphone’

2022-08-12 19:30:11.211 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing ‘http:url:outdoorphone’.

2022-08-12 19:30:11.214 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Started refresh task for URL ‘http://192.168.0.58/api/system/info/’ with interval 100s

2022-08-12 19:30:11.214 [TRACE] [.HttpDynamicStateDescriptionProvider] - adding state description for channel http:url:outdoorphone:Status

==> /var/log/openhab/events.log <==

2022-08-12 19:30:11.216 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:outdoorphone’ changed from INITIALIZING to ONLINE

2022-08-12 19:30:11.219 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:outdoorphoneCall’ changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab/openhab.log <==

2022-08-12 19:30:11.225 [DEBUG] [nding.http.internal.HttpThingHandler] - No authentication configured for thing ‘http:url:outdoorphoneCall’

2022-08-12 19:30:11.226 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing ‘http:url:outdoorphoneCall’.

2022-08-12 19:30:11.227 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Started refresh task for URL ‘http://192.168.0.58/api/call/status/’ with interval 100s

2022-08-12 19:30:11.228 [TRACE] [.HttpDynamicStateDescriptionProvider] - adding state description for channel http:url:outdoorphoneCall:callstatus

==> /var/log/openhab/events.log <==

2022-08-12 19:30:11.229 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:outdoorphoneCall’ changed from INITIALIZING to ONLINE

2022-08-12 19:30:11.232 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘http:url:outdoorphoneInput’ changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab/openhab.log <==

2022-08-12 19:30:11.237 [DEBUG] [nding.http.internal.HttpThingHandler] - No authentication configured for thing ‘http:url:outdoorphoneInput’

2022-08-12 19:30:11.239 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing ‘http:url:outdoorphoneInput’.

2022-08-12 19:30:11.249 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Started refresh task for URL ‘http://192.168.0.58/api/input/status/’ with interval 20s

2022-08-12 19:30:11.250 [TRACE] [.HttpDynamicStateDescriptionProvider] - adding state description for channel http:url:outdoorphoneInput:DoorInputA

2022-08-12 19:30:11.252 [TRACE] [.HttpDynamicStateDescriptionProvider] - adding state description for channel http:url:outdoorphoneInput:DoorInputB

thx

Could you post the thing configuration as MainUI shows it on the code tab?

UID: http:url:outdoorphoneCall
label: Gegensprechanlage Anruf
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: http://192.168.0.58/api/call/status/
  refresh: 100
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: callstatus
    channelTypeUID: http:string
    label: Callstatus
    description: null
    configuration:
      mode: READWRITE
      stateTransformation: JSONPATH:$.data.Status

My used http thing has this code:

UID: http:url:TasmotaVersion
label: Tasmota Version
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.github.com/repos/arendst/Tasmota/tags
  delay: 0
  stateMethod: GET
  refresh: 43000
  commandMethod: GET
  contentType: application/json
  timeout: 5000
  bufferSize: 2048
channels:
  - id: Version
    channelTypeUID: http:string
    label: Version
    description: ""
    configuration:
      stateTransformation: JSONPATH:$[0].name

Note the used setting for statedescription. Can’t say if that does the trick, however…

One slash …

baseURL="http://192.168.0.58/api/call/status/"

vs.

urlopen("http://192.168.0.58/api/call/status")
1 Like

I did several tries in order to receive the return message (“NULL”). None did show your result ( included adding a slash at the end of the URL). I am out of ideas.

Puting my binding into TRACE logging is showing following messages:

2022-08-13 08:14:21.481 [TRACE] [.HttpDynamicStateDescriptionProvider] - removing state description for thing http:url:TasmotaVersion

2022-08-13 08:14:21.488 [INFO ] [nding.http.internal.HttpThingHandler] - Using the secure client for thing 'http:url:TasmotaVersion'.

2022-08-13 08:14:21.490 [DEBUG] [nding.http.internal.HttpThingHandler] - No authentication configured for thing 'http:url:TasmotaVersion'

2022-08-13 08:14:21.494 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Started refresh task for URL 'https://api.github.com/repos/arendst/Tasmota/tags' with interval 600s

2022-08-13 08:14:21.496 [TRACE] [.HttpDynamicStateDescriptionProvider] - adding state description for channel http:url:TasmotaVersion:Version

2022-08-13 08:14:22.495 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Requesting refresh (retry=false) from 'https://api.github.com/repos/arendst/Tasmota/tags' with timeout 5000ms

2022-08-13 08:14:22.498 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending to 'https://api.github.com/repos/arendst/Tasmota/tags': Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.46.v20220331}, Content = {null}

2022-08-13 08:14:22.534 [TRACE] [p.internal.http.HttpResponseListener] - Received from 'https://api.github.com/repos/arendst/Tasmota/tags': Code = ......( ommitted the full print of the return)

Your log sems to be missing the last three reports.
Are you using three different things (outdoorphone, outdoorphoneCall and outdoorphoneInput)?

Hello guys,

tell you what:
its working (right now)

Made a complete restart of OH3 and not only a “http Binding” restart, and now i get log entries and answer from my device.

sorry and big thanks to you…

1 Like