Really I was thinking this would be a built-in channel exposing something about the Thing. It’s the Thing doing the HTTP work from the user viewpoint.
I see this binding does both read and write - so I suppose a better name might be more like lastCommSuccess lastCommError
or something if it covers both uses.
Maybe it is less useful these days where Thing status is more accessible from rules, if this Thing reflects its comms problems in its own status…
But no matter what I try all I always get is a server response </CGI_Result>-2</CGI_Result>
The debug output is mostly useless as it does not show the URL or headers going out, not even info like SSL or user auth, or responses coming back.
All debug level log shows is
2020-07-10 17:09:30.119 [DEBUG] [.transform.SingleValueTransformation] - Transformation ChannelStateTransformation{pattern='.*?<motionDetectAlarm>(.*?)</motionDetectAlarm>.*', serviceName='REGEX'} returned empty result when applied to <CGI_Result>
<result>-2</result>
</CGI_Result>
.
I was able to confirm this is what the server returns using wireshark, but for sure I need to be able to see that in the OH log to be able to make good use of it.
I have updated the link above. If you set org.openhab.binding.http.internal.http to TRACE you’ll see the URL when requesting and the responses received.
Dowloaded it but did that change anything about http logging ?
That’s not really useful yet. Would need to see Headers, body and reponse code of the request
2020-07-10 20:24:04.590 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending 'http://foscam:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState' to 'HttpRequest[GET /cgi-bin/CGIProxy.fcgi HTTP/1.1]@13442bb'
2020-07-10 20:24:04.639 [TRACE] [ttp.internal.http.RefreshingUrlCache] - RefreshingUrlCache for 'http://foscam:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState' received 'org.openhab.binding.http.internal.http.Content@66d12b'
It does, thanks.
It helped me find my own error now that I see the 200 response.
Turned out it was the request I didn’t copy properly. That device needs to have http://host/yaddayadda&usr=username&pwd=password rather than basic auth.
What’s left is that apparently I must be having another HTTP thing active (resulting from first tests yesterday ?) as I keep seeing both URLs below (the difference is the additional ‘/’). I don’t find that 2nd one in the list of smarthome:things though - is it something your binding does ? (although I don’t think so as it has a different request interval).
But that reminds me of this: if I’m not mistaken, you add State and Command URL Extension to Base URL but insert a fixed ‘/’, correct?
Then please remove that fixed ‘/’ insertion as the requirement could as well be to continue the URL with ? or & like in my test case.
I have the changed the concatenation logic. It now first checks if either the last character of the baseURL or the first character of the extension is ?, / or & and adds the / only if nothing is present. jar updated
What seems not to be working yet is updating the item.
I’ve filled State Transformation with a REGEX to extract a value from one of the lines in the HTTP reponse body above: REGEX:.*?<motionDetectAlarm>(.*?)</motionDetectAlarm>.*
… but I don’t see the linked item update and no hint in the internal.http trace.
I enabled debug logging on org.openhab.transform.regex and it says it is to execute the transformation, but the output isn’t shown in log and the item isn’t updated.
I have been using that with the v1 binding and my log above (“about to transform”) shows it’s applied, doesn’t it.
Do I need to use a Number or a String item ?
Alright, it was my own silly fault. It has been working all the time but the value didn’t change so the item didn’t.
Everything alright with your binding - thanks.