Hello OpenHAB community - This is my first post, as an OpenHAB NooB…So go easy ;-).
I am trying to get my head around a problem I am having, and thought someone out there could probably answer this pretty quickly.
I have successfully automated my garage door using a Fibaro Z-Wave Switch and Sensor. The Garage Motor design is pretty basic…i.e. its not a roller shutter type mechanism, it just responds to a button push.
Press Once -> Open (until fully open) - > Press Again - > Stop -> Press Again - > Close (until fully closed).
the Fibaro switch works excellently and the Sensor tells me if the door is open or closed. Brilliant.
I have created a rule, which closes the garage door at 10pm, every night, if I have left it open (which is a god-send when I am tucked up in bed in my PJ’s at which point my wife sais…“Is the Garage closed?”
I have integrated into HomeKit, and I can ask Siri to Open or Close the door. All works flawlessly.
However, here is the problem.
I want to check the status of the door, before triggering the OPEN (or Close) command. But the way rules are constructed, I can’t work out how to do this.
Basically I want to put an “IF” statement into the “when” block of the rule. to say something like.
when
If (GarageDoorSensor.State == OPEN)
then
Item OpenGarage received Command ON IGNORE.
Does that make sense?
What I am trying to get the logic to perform is “if the door is open, don’t open it again”. (and vice versa).
However, the way the rule logic seems to work is you can only apply the “then” statement after the action has been triggered.
This is what I currently have:
when
Item GarageDoorOpen received command ON // AT which point, the door has been triggered and the Garage door is starting to Close
then
if(Garage_Door_State.state == ON) { //check the status of the door
sendCommand(Garage_Door,ON) // stops the door.
}
end
Which is what I currently have. This works (to an extent), but not before the Garage door has started to close, and I would prefer it to Ignore the command altogether, if the state is OPEN.
This actually brings me on to a sub-problem in that - this code will only executes twice, then stops working altogether, until I edit and re-save the default.rules file. Then it will work twice again…and no more. Weird. I am sure it has something to do with the way I have coded this.
The action I am trying to perform in itself is pretty simple - the logic, is pretty simple - but it seems very tricky to implement.
Any advice greatly appreciated. Its not the end of the world if I can’t get this working - as it just means I need to check the app for the status of the door, before I issue a command. But, it would be a nice feature.
Thanks,
Stallie.