I am working on build a garage door opening/closing app and running into a slight issue. I am using the DHT simulated garage door opener which is working. However, when I run the script it doesn’t align with animation. I press the virtual switch to open, the switch changes to opening, and then open. Once it says open the garage door is activate and opens. How can I make the action of the garage door opening line up with the actual physical action? Any help is greatly appreciated.
preferences {
section("Choose the switch/relay that opens the garage?"){
input "mSwitch", "capability.momentary", title: "Physical Garage Opener?", required: true
}
section("Choose the sensor that senses if the garage is closed? "){
input "closeSensor", "capability.contactSensor", title: "Physical Garage Door Closed Sensor?", required: true
}
section("Choose the sensor that senses if the garage is open?"){
input "openSensor", "capability.contactSensor", title: "Physical Garage Door Open Sensor?", required: true
}
section("Choose the Virtual Garage Door Device? "){
input "vSwitch", "capability.doorControl", title: "Virtual Garage Door?", required: true
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize()
{
subscribe(vSwitch, "contact.open", openHandler)
subscribe(vSwitch, "contact.close", closeHandler)
}
// Garage door opening process ------------------------------
def openHandler(evt) {
log.debug "openHandler called: $evt"
if(closeSensor.latestValue("contact").contains("closed") && openSensor.latestValue("contact").contains("open")){
mSwitch.push()
runIn(2000, openHandlerClose)
}
}
def openHandlerClose(evt) {
log.debug "openHandlerOpen called: $evt"
if(closeSensor.latestValue("contact").contains("open") && openSensor.latestValue("contact").contains("open")){
vSwitch.open()
runIn(1000, openHandlerClose)
} else if(closeSensor.latestValue("contact").contains("closed") && openSensor.latestValue("contact").contains("open")){
vSwitch.finishOpening()
}
}
The script works it is just the alignment of the switch action that I am hoping to fix. Thanks!