Virtual device that combines lock and contact sensor?

I have seen things like the Auto Lock app but am looking for something at the device level. Is there a way to create a virtual door that combines a lock and a contact sensor? If the contact sensor is open then the lock cannot be activated. Many smart deadbolts have this feature (August for example) and I would like to add that functionality from the Hub side. I could then expose this device to dashboards or rules and it would prevent the lock from deploying in the door open state.

Why not create a rule to unlock the door if the contact sensor is open and the door state is locked.

This is what I do when someone lock the door (manually by mistake as it get triggered when someone touches the screen) when it is open and it gets unlock on its own.

There are rule ways to solve this issue but wrapping it all into a single device makes that device easy to use in any other app or rule without needing to consider if the door is open or closed as well.

This might do.... Just modify the events to include lock

metadata {
definition (name: "Virtual contact with Switch", namespace: "cwilson08", author: "cwwilson08") {
capability "Sensor"
capability "Contact Sensor"
capability "Switch"
capability "lock"
}
}

def on() {
sendEvent(name: "contact", value: "closed")
sendEvent(name: "switch", value: "on")
}

def off() {
sendEvent(name: "contact", value: "open")
sendEvent(name: "switch", value: "off")
}

def installed() {
}

You’d want to add sendEvent’s for lock:locked and lock:unlocked

2 Likes

I have not done any dev work here yet but I am not totally opposed to learning. I am not seeing how this would prevent a lock command if the contact is open.

Thinking about it more it might be an app that creates the virtual device. Select the lock device and the contact device in the app that then creates the virtual device. That device could be added to a rule or a dashboard and would report the contact open or closed as well as the lock locked or unlocked. In the dashboard example, when tapped on it would unlock the locked lock or if the contact was closed could lock the unlocked lock. If the contact was open then the lock would not get a lock command.

1 Like

Have you looked at:

1 Like

That is VERY close to what I am thinking and will probably work. Rather than use the door jamb protection option to unlock the open door, I was looking to prevent it from even locking in the first place and have that built into the single device.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.