Combining two devices as one single virtual device to control a garage door

Hi everyone!

I have a tilt garage door (i.e. opening vertically), that I can open by momentarily enabling a Z-Wave switch (installed in the motor box) and I have a Z-Wave sensor on the door to detect the inclination (below or above 45 degree basically, which send an event whenever I cross this position).

I’d like a virtual device that act as a combination of the two actual devices.

But the logic seems complex enough that I don’t know if Home Assistant can easily implement it.

I’d like to do the following:

  1. Starting from state = closed
  2. Ask to open the door => this will change the state to “opening”, and this will “press” the switch for 1s, then release it
  3. Wait for the sensor to say that the door reached 45 degree (this means the door is midway, it happens after 10s usually)
  4. Wait a little more before assuming the door is fully open (up to 10s-15s more)
  5. Finally set the state to “open”

And conversely when closing it (“open” => “closing” => “closed”).

If the sensor doesn’t signal anything, then maybe assume that after a longer time, the door finally reached its target state (say, after 30s).

If the switch is momentarily “pressed” while the door is being operated, then it usually stop at its current position. It’s a problem, but this should not happen often. I don’t have any means to detect it currently (unless the states “opening” and “closing” are reliable enough).

Is it possible to implement this logic? (If not, I don’t mind if I need to implement it natively, in whatever language is best for this.)

Fantastic! Should be a good starting point.