I recently upgraded to OH3 and am porting everything I can to the more modern methodology. One of these things is my garage door opener, which has a very simple HTTP protocol:
GET http://address/?status
returns “Open” or “Closed” as the body.
GET http://address/?open
opens the door.
GET http://address/?close
closes the door.
There is no authentication.
In OH2 I bound the controls like this:
rule "Forward garage door commands"
when
Item LF_Garage_Door received command
then
switch(receivedCommand) {
case UP :
{
logInfo("Garage door", "Requesting open")
sendHttpGetRequest("http://address?open")
}
case DOWN :
{
logInfo("Garage door", "Requesting close")
sendHttpGetRequest("http://address?close")
}
}
end
The receiver was set up in the item definition, calling a JS transformation to translate the response into valid values for the item type.
I’m trying to refactor this into an HTTP Binding thing with read and write channels. The new definition looks like this:
UID: http:url:GarageDoor
label: Garage door
thingTypeUID: http:url
configuration:
ignoreSSLErrors: false
baseURL: http://10.183.50.80/?
refresh: 5
commandMethod: GET
contentType: text/plain
timeout: 1000
bufferSize: 2048
location: Garage
channels:
- id: OpenClose
channelTypeUID: http:rollershutter
label: Open close
description: ""
configuration:
mode: WRITEONLY
downValue: close
upValue: open
- id: ReadState
channelTypeUID: http:contact
label: Read state
description: ""
configuration:
onValue: Open
mode: READONLY
offValue: Closed
openValue: Open
stateExtension: status
closedValue: Closed
The documentation is not very explicit about how the GET string is built and how the values are incorporated, so this was my best guess.
After some experimentation, I left with two problems:
- According to the log, every request ever sent results in:
[WARN ] [tp.internal.http.HttpResponseListener] - Requesting 'http://address/?status' (method='GET', content='null') failed: Total timeout 1000 ms elapsed
- When I a message is sent to the writeable channel, I see messages saying that that status of the channel is changed, but it never seems to send anything by HTTP. I don’t see any INFO or WARN messages in the log. I also looked in the DEBUG version, but it’s obviously quite hard to find a needle in that haystack.
Any troubleshooting or usage information would be welcome. Of course, typing any of these strings into my desktop browser works perfectly!