HTTP binding - openHAB 3 issue

Hello everyone,
In the progress of migrating from 2.5 to 3.0.2 and I have some challenges with the new HTTP binding.
I hope someone is able to spot what I’m doing wrong.
Configuration in 3.0.2:

UID: http:url:d4e4229902
label: BH_ZWay
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://UN:PW@192.168.110.203:8083/ZAutomation/api/v1/devices/
password: PW
refresh: 30
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
username: UN
location: xxxx
channels:

  • id: xxx_Temp
    channelTypeUID: http:number
    label: xxx_Temp
    description: β€œβ€
    configuration:
    mode: READONLY
    stateExtension: ZWayVDev_zway_4-3-49-1
    stateTransformation: JSONPATH:$.data.metrics.level

Returns a 404 unknown device whereas any other means of issuing:
http://UN:PW@192.168.110.203:8083/ZAutomation/api/v1/devices/ZWayVDev_zway_4-3-49-1

Returns the correct json?

I have tried differnt settings in the UI and even textual configuration of the thing and channels without success.

Thanks

Which auth-type is required? If Basic Auth, do not use un:pw in the url.

Hi Jan,

problem is not Auth as I do not get a 403 but 404.
I learned earlier with this gateway API that one could also trix it by having logged into it in parallel via a webbrowser.
This does not make a difference here, so the problem is elsewhere.

You can enable trace logging for the binding. This logs exactly which URL is requested. Maybe that gives a hint on what is going wrong.

Ok, now I changed back to the same API as used on 2.5.
This is the trace output:
2021-05-25 23:05:47.933 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending to β€˜http://192.168.110.203:8083/ZWaveAPI/Run/devices[4].instances[3].SensorMultilevel.data[1].val.value’: Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.20.v20190813}, Content = {null}
2021-05-25 23:05:47.970 [TRACE] [p.internal.http.HttpResponseListener] - Received from β€˜http://192.168.110.203:8083/ZWaveAPI/Run/devices[4].instances[3].SensorMultilevel.data[1].val.value’: Code = {401}, Headers = {Server: Mongoose/6.4, Access-Control-Allow-Origin: *, Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS, Access-Control-Allow-Headers: Authorization, Accept-Ranges, Content-Encoding, Content-Length, Content-Range, Content-Type, ETag, X-API-VERSION, Date, Cache-Control, If-None-Match, Content-Language, Accept-Language, X-ZBW-SESSID, ZWAYSession, Access-Control-Expose-Headers: Authorization, Accept-Ranges, Content-Encoding, Content-Length, Content-Range, Content-Type, ETag, X-API-VERSION, Date, Cache-Control, If-None-Match, Content-Language, Accept-Language, X-ZBW-SESSID, ZWAYSession, Connection: keep-alive, Date: Tue, 25 May 2021 21:05:47 GMT, Content-Type: text/plain, Content-Length: 13}, Content = {Not logged in}
2021-05-25 23:05:47.972 [WARN ] [p.internal.http.HttpResponseListener] - Requesting β€˜http://192.168.110.203:8083/ZWaveAPI/Run/devices[4].instances[3].SensorMultilevel.data[1].val.value’ (method=β€˜GET’, content=β€˜null’) failed: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

Config in 3:
UID: http:url:7e5ba49f4a
label: HTTP URL Thing
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.110.203:8083/ZWaveAPI/Run/
password: PW
refresh: 30
commandMethod: GET
contentType: text/plain
timeout: 3000
bufferSize: 2048
username: UN
channels:

  • id: BH_Temp
    channelTypeUID: http:number
    label: BH_Temp
    description: β€œβ€
    configuration:
    stateExtension: devices%%5B4%%5D.instances%%5B3%%5D.SensorMultilevel.data%%5B1%%5D.val.value

format in 2.5:
{http="<[http://UN:PW@192.168.110.203:8083/ZWaveAPI/Run/devices%[4%].instances%[3%].SensorMultilevel.data%[1%].val.value:30000:REGEX((.*))]" }

Update;
Moved the HTTP polling into a rule:
val String BH_json = sendHttpGetRequest(β€œhttp://UN:PW@192.168.110.203:8083/ZAutomation/api/v1/devices”)
and here it works as expected.

Could someone please elaborate on the difference between HTTP thing / channel and sendHttpGetRequest

Uh, well you’re now using a completely different URL, for a start?

1 Like

Sorry for confusion, I move back to the original URL
Configuration in 3.0.2:

UID: http:url:d4e4229902
label: BH_ZWay
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://UN:PW@192.168.110.203:8083/ZAutomation/api/v1/devices/
password: PW
refresh: 30
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
username: UN
location: xxxx
channels:

  • id: xxx_Temp
    channelTypeUID: http:number
    label: xxx_Temp
    description: β€œβ€
    configuration:
    mode: READONLY
    stateExtension: ZWayVDev_zway_4-3-49-1
    stateTransformation: JSONPATH:$.data.metrics.level

Returns a 404 unknown device whereas sendHttpGetRequest(β€œhttp://UN:PW@192.168.110.203:8083/ZAutomation/api/v1/devices/ZWayVDev_zway_4-3-49-1”) returns the correct json