Force a contact sensor closed

@nayelyz
Sometimes this devices fails to send the close information. Meaning, we close the door and the sensor remains Open. The current DTH has a function that overrides this and the sensor changes from open to close, when calling the function using webcore:

Is this possible with the New API?

def resetClosed() {
    sendEvent(name: "contact", value: "closed", descriptionText: "${device.displayName} was manually reset to closed")
}

Here’s a link to the Xiaomi/xiaomi-aqara-door-window-sensor.groovy at master · bspranger/Xiaomi · GitHub 1

It seems it is a custom command defined in the DTH. Can you let me know which DTH is the device using, please?

It is something that can be done by defining the command in a custom capability and including that capability in a driver. Virtual devices use the same idea.

My personal preference when devices are prone to misbehaving (meaning all my presence sensors) is to use them to set a virtual device and then use that virtual device as a proxy for them in automations. That way I can override them without losing track of what they are really saying. However each to their own and the possibility exists. It isn’t something you’d see in a stock driver (I hope) but community developers seem to be more relaxed about this sort of thing.

2 Likes

I supplied a link to the DTH in the first post.

I was thinking the same thing.

You can accomplish something pretty close by creating a virtual contact sensor using this driver and setting up an automation with your physical contact sensor. [ST Edge] Virtual Hub Kit [BETA]

The virtual sensor has the ability to close it via an automation. Not via the UI

1 Like

Thank you for the suggestions, @blueyetisoftware and @orangebucket!

Yeah, @Jake_Mohl, this command is not accessible from the API because it is only part of the DTH’s metadata, and not a custom capability.
That’s why you don’t have a button for this in the app either. So, the workarounds provided should work.

Note: Remember that this is a custom DTH, so, you need to find (and install) a replacement (Edge driver) if you want it to be migrated.

1 Like

Thank you so much, I will pass this information along.