Prevent modification of a lock entity while the door is moving

I have a garage door I can control via zigbee2mqtt but I am having some issues to make it work smoothly.
TLDR after a button press I need to prevent any further button press while the door is moving, I can only use a timer after a button press to know if it’s moving.
Best option would actually be while the door is moving, toggling the lock entity should trigger the push button twice with 1sec interval, first will stop the movement second will reverse the movement.

I did see the Lock Template entity and using it without the optimistic setting I do have a reliable on/off status, but still, any attempt to mistakenly open it twice results in the garage door stopping.

I’m not fixed on one or the other, but for me stopping the garage door mid-way is useless, so I would really like to either prevent any press of the button while the door is moving, or double any press with 0.5 sec interval inbetween to allow the motor to stop then reverse…

My garage exposes a single contact as a binary sensor (closed is closed, but “open” might be opening or fully open) as well as a trigger exposed as a switch, but this switch is let’s say… complex in it’s behaviour, it remains on or of and depending on what the door is doing it triggers either a stop or a close or an open of the door.

I found a reliable way to sue the switch regardless of it’s position on or off : doing 2 toggles in quick sucession will always make the door register an action, and it will either ropen or close or stop depending on the position.

So what I’m now trying to achieve is to prevent stopping the door mid-way…
I tried relying on the on/off state of the trigger button but no luck here, I’m still able to stop the door in the middle…

I’m imagining many ways of doing this, with mqtt I could create a fake position, and automations to increment/decrement the position, I could create a simple input_boolean “door is moving” instead and try to set/unset it in the template lock/unlock actions and in automations with complex conditions depending on the actual contact of the door and when the movement has started and such…

I see many complicated solution but I can’t wrap my head around anything simple that would make the actual lock entity just “work” with no stopping in the middle…

I thought it’s not so hard :

  • any action on the door means switch.toggle+wait0.5s+switch.toggle again
  • if door is in movement, the first action will only stop the door, so double the action.

This is because on the template lock entity if it directly manipulates the switch entity, you can end up, by mistake, with the door stuck in the middle while given the number of lock/unlock I thought the door should be closing…

As of today my only solution is to have my CCTV camera pointed at my garage door on the same dashboard as the lock button, this way I can see that I’m waiting for something to happen while the door is simply stopped in the middle unmoving… This happens to me regularly… Trying to solve that frustration, I saw many people offering many templates and stuff none of them would seem to solve my current gripe.

I’m also taking other advices f you have, I mean if buying a vibration sensor to stick on my garage motor is the best way to get a “door is moving” thing that I can actually rely upon then this is what I’d do…

Add a door sensor to, so you know if it is moving or not.
Or better yet add two, one for when it is open and one for when it is closed.

1 Like

I can vouch for smarthings multisensor. It has contact sensor, vibration sensor, temperature sensor and returns X,Y,Z coordinates.

I have this sensor on all my external doors and has been solid for over 4 years.

Edit: Also has a ‘Moving’ attribute in HA

~B

Thanks for the feedback!
I do already have a contact sensor included in the ZigBee garage door opener, but the one you show from Samsung seems magic yes, so I’ll definitely be giving it a try if it works with z2m it will simplify my life to determine if the door is moving.

Still I am not sure to see how I can alter the behavior of the lock/unlock depending if it’s moving or not, especially because the user can most probably input maybe more lock/unlock/lock/… as what is actually achievable given I need some delays and double-trigger of the garage door switch.

Is there some kind of enabled or disabled attribute I could set on the lock template to prevent or disregard lock/unlock requests from the user when it’s pressed too fast for example?

So, to clarify, Are you using an automation triggered by the garage door button to control the garage door or does the button directly control the garage door?

I’m considering all options, today, automations are triggered by pressing my zigbee remote and they manipulate the garage switch directly, which results in making it stop mid-way if it was moving…

Hello Brian, just gor my sensor today, I’m using Z2M and it’s showing up properly but I get no accelerometer data, no movement indication, it remains “unknown”.


Do you happen to remember if you had to do something to get it working ?

looking at your previous posts I surmise you are using it yourselv with Z2M, so may I inquire about the version that you are running and if you recall doing anything particular to link them or set them up in any way ?
I see in the code there are several vlavors of the same sensor released in various years, so maybe I’m just unlucky and got a recent one that isn’t working :cry:

I’m running v1.40.1-1 of Z2M. If you’ve read my previous posts you’ll probably have seen I run 3 separate instances of Z2M running on 3 Rpi3B+ as I have many zigbee devices and I found above ~90 devices the zigbee network becomes unstable.

I haven’t upgraded to v2.x of Z2M because I have read a few posts saying people had issues.

This is how the device shows for me


and exposes …

It was about 2 years ago when I last bought some so I’m not sure if they have changed the hardware since then.

I don’t have any smart locks but if you can trigger an automation via the button we should be able to work out some logic to do what you want once you know if the door is moving and in what direction.

~B

Z2M 2.0.0 had a LOT of breaking changes and people did not read the release notes and just upgraded.
I do not know if the changes affected your sensor, but here is the release notes.

Yeah, seems I’m just out of luck with this sensor. Nevermind, I believe I can achieve what I want without it, starting to understand trigger based templates hopefully.
I believe I could make a “garage door is moving” sensor that return true/false and keeps"moving" for 20s or until the actual sensor detects the door is closed.
Because I’m an idiot I only have a sensor true/false for the fully closed position, it “opens” when the door starts moving and remains open until it’s fully closed again.
I will maybe reposition my smartthings sensor to detect the fully open position.
But meanwhile 20s after the sensor went from closed to open is a good guess.
Still scratching my head as how to best manipulate/define the lock entity based on those.

With my wife I agreed on a target behavior:

  • while it’s opening
    • if one tries to open again, ignore this and do nothing
    • if one tries to close, then double the action to stop then closed the door
  • while closing
    • if one tries to close then ignore
    • if one tries to open double it to stop then open the door

My goal is to make an actual lock entity using the template that does exactly that, the template does offer opening or closing states so I’ll try to make use of it. I just have to find a way to template all this :sweat_smile:

Well I managed to get a satisfactory solution, but it’s quite involved…
I have created an input_select that tracks what the door is doing, 2 timers for the opening and closing duration, one template binary_sensor mimicking a contact sensor for “door fully open”, 1 automation that manipulate the input_select when contact sensor triggers, and finally a template lock entity…
Ouch.
I wished I could do that without automations, and I wish I could have those other helper entities bundled into a cover entity but I couldn’t find a way so far to do it. One must also remember the door can be manipulated outside home Assistant and should reflect what it’s doing there…
Tricky.
I’ll post my yml here as soon as I get a keyboard (on my phone right now) to hopefully get ideas of improvement or alternative solutions.
Having the Samsung multipurpose sensor reporting mouvement would have been great I probably could have done a cover template with this and gone away with the input select.