Hi all,
I have put a Raspberry Pi out in my garage, to serve as a wifi repeater for my new office (which otherwise wouldn't have been in range of wifi) and a means of controlling my garage door. I have a relay to open/close the garage door, and a reed switch to tell if the garage door is open or not. Everything is working quite well, but I am falling over at the OpenHAB stage.
The way things are implemented, I have built a small http server that is running on the pi, and it has a few rest urls for things like testing if the garage door is open, and for instructing it to do things like open, close and toggle from the current state into the opposite state. This all works fine outside of openhab - I'm seeing the data and results I expect.
There are two problems I have when bringing this into OpenHAB, and I really hope the community may have some ideas on how best to tackle this.
Problem 1: No matter what I do, I just can't seem to get the OpenHAB http binding to trigger an http call to the server. I assumed I could have an item like this:
Switch Garage_Door_Button "Garage Door" <garagedoor> { http=">[CHANGED:POST:
http://192.168.1.104:8080/garagePi/garageDoor/toggle]" }
And a sitemap statement like this:
Switch item=Garage_Door_Button
and that when the button is pressed I would see the server receive a request and return a response - but from the openHAB log all I see is that the switch state has been toggled - the http url is never called. What am I doing wrong here?
Problem 2: This is a higher level issue: ideally I would have a single switch in my UI that reflects the current state of the garage door, and if I press it I would expect it to toggle state. Therefore, what I would like to do is define an item like this:
Switch Garage_Door_Open "Garage Door" <garagedoor> { http=">[ON:POST:
http://192.168.1.104:8080/garagePi/garageDoor/open] >[OFF:POST:
http://192.168.1.104:8080/garagePi/garageDoor/close] <[
http://192.168.1.104:8080/garagePi/garageDoor/isOpen:3600000:REGEX((.*?))]" }
Because I'm stuck on problem 1 I don't know if this approach works, but assuming it doesn't - is there a recommended approach? The other (obvious) requirement is that I don't want to get into a feedback loop where the garage door state alternates based on the isOpen call being called (obviously the 3600000 is not the desired refresh rate and it would be much more frequently checked than that once everything is working).
I wonder if I am being too direct in my approach, and should separate out booleans that represent the current state from the desired state, and to then write a rule that triggers the change?
I hope I've clarified my two issues, and I do appreciate any help the community may offer.
Thanks,
-- Jonathan