In my previous setup to OH had a plugin that handled what I think you are asking for. I was determined to create it in OH. I wrote a pair of rules to handle what I think you are talking about.
My setup has a number item that is 0 or 1 but on the sitemap shows as closed or open via mappings. The item will highlight the current state of closed or open. You can still push either direction. The rule will actually verify against the door sensor that the current state is correct. If not it will send a command to push the door opener button (standard one button chamberlain opener that I have a relay connected via my DSC PGM outputs).
Once the rule pushes a garage button, it will wait for a few seconds and then check the status and update the state of the Number on the sitemap. That way you have real feedback of success/failure.
I have a second rule that monitors the door sensor separately. This will update the number item if the garage door is opened manually via button in the garage or a car etc.
It’s mostly standard. The unique piece is a local variable for “lockout” The point of the lockout is to keep the two rules from interfering with each other. I spent a good afternoon trying to think up the smoothest logic. I’m sure there are other/better methods but it has been reliable for several months now.
Hopefully it is relevant to your question.
ITEMS:
Number NUM_garageDoor
Contact Garage_garage_Door_GENERAL_STATUS "garage's Garage Door" <garagedoor> (DSCAlarmZones, Garage) {dscalarm="stuff"}
SITEMAP:
Switch item=NUM_garageDoor label="garage's Door Status" icon="garagedoor" mappings=[0="Closed", 1="Open"]
RULES:
var Number garageGarageLockout = 0
var Timer garageGarageTimer //timer for garage's garage door
rule "garage Door toggle"
when
Item NUM_garageDoor received command
then
logInfo("garage Door toggle", "Rule Triggered")
if (garageGarageLockout==0) {
if (receivedCommand==0) {//close door
if (Garage_garage_Door_GENERAL_STATUS.state == OPEN) {
//close door
garageGarageLockout = 1
sendDSCAlarmCommand() //toggle pgm
logInfo("garage Door Toggle", "Door closing")
} else {
logInfo("garage Door Toggle", "Door already closed")
}
} else if (receivedCommand==1) { //open door
if (Garage_garage_Door_GENERAL_STATUS.state == CLOSED) {
//open door
garageGarageLockout = 1
sendDSCAlarmCommand()
logInfo("garage Door Toggle", "Door opening")
} else {
logInfo("garage Door Toggle", "Door already open")
}
}
if(garageGarageTimer!=null) {
garageGarageTimer.cancel() //cancel timer if it is already running
}
logInfo("garage Door toggle", "Starting Timer")
garageGarageTimer = createTimer(now.plusSeconds(18)) [| //give door 18 seconds to close
if ((Garage_garage_Door_GENERAL_STATUS.state == OPEN) && (NUM_garageDoor.state == 0)) {
logWarn("garage Door toggle", "Door failed to close or was overridden")
postUpdate(NUM_garageDoor, 1)
} else if ((Garage_garage_Door_GENERAL_STATUS.state == CLOSED) && (NUM_garageDoor.state == 1)) {
logWarn("garage Door toggle", "Door failed to open or was overridden")
postUpdate(NUM_garageDoor, 0)
} else logInfo("garage Door Toggle", "Timer ended, all is well")
garageGarageLockout = 0
]
} else logInfo("garage Door toggle", "garageGarageLocout!=0")
end
rule "Update garage Garage Door State"
when
Item Garage_garage_Door_GENERAL_STATUS changed
then
if (garageGarageLockout==0) {
if ((Garage_garage_Door_GENERAL_STATUS.state == OPEN) && (NUM_garageDoor.state == 0)) {
logInfo("Update garage Garage Door State", "Door has opened")
postUpdate(NUM_garageDoor, 1)
} else if ((Garage_garage_Door_GENERAL_STATUS.state == CLOSED) && (NUM_garageDoor.state == 1)) {
logInfo("Update garage Garage Door State", "Door has closed")
postUpdate(NUM_garageDoor, 0)
} else logInfo("Update garage Garage Door State", "Nothing changed")
}
end