The config per channel might be an option. lastReadSuccess is difficult, because it could be that reading one channel is successfull (e.g. with one stateExtension) while another channel (with another stateExtension) always fails. The lastReadSuccess would not help here.
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.