Help with single button garage door

Hi all… I have a garage door (well, and also a gate :smiley: ) that is controlled by a single button, with an inverting logic, so press the button and the door start moving, press and stop, press and start moving in the opposite direction. Is there any way to implement this logic… Was looking also to an addon like the various cover time based, but didn’t find anything… Anything to suggest?

Thanks!

You can add a tilt sensor if it is vertically moving door and then track the changing angle to see what is happening … build logic. if it is horizonal then add a sensor to detect if open of not and build logic around that.

Putting sensors and so on is not so easy, so I would prefer a software solution… I’m not able on making integrations unfortunately… :frowning:

Hi, I’m wondering if the garage door is at it’s end (fully closed or open) how does the system know that?
I would think that there are sensors, no?

You could create an automation that remembers the previous movement to simulate what you have but if you have no state with fully closed or open, how would you be able to control that?

Also, where/how will you be connecting to the current system?

My domotic system is integrated on HA via the comelit integration… Actually the source system does not know the state of the door, so it just goes up and down pressing the button… Having a state in HA, as in the optimistic state for cover templave, would be a plus WRT the actual system… :slight_smile:

Which entities do you get from that in HA?

So if you bypass that button that you are using now, you should be able to do the same…

I guess, if you don’t use any sensors, you will never know the current state.

Just a switch

So that switch has the same behavior as the physical button?

Yep, that’s right!

You got me confused…

I’m referring here to a virtual switch/card in HA.

If it’s about having a state that represents the physical situation, the only way to achieve this is by using (wireless) contact sensors.

Ok, so, I try to explain my idea better…
All start from this and other similar extensions available in hacs: GitHub - kotborealis/home-assistant-custom-components-cover-time-based-synced: ⌛ Time-based cover. Install it via HACS.
Here you have a cover, controlled by 2 or 3 buttons, with no state known.
The state is internally derived from the time you choose for the cover movements.
My idea is similar. The main problem is if ha and real state goes out of sync for some reasons… With two button if the cover is open and ha say it is closed, if you press the open button in ha then the cover does not move but the state got synced again.
With a single button this would never true, so there must be a sort of manual reset to resync the states. For me this is not a problem, on 95% of time those states will be the same…
Maybe this would be doable with a/some script(s) and some helpers to keep track of the statuses, but I’m not sure how to have a counter on the time moving… All the trick would be to count seconds moving up or down… If seconds are 0 then the door is closed, if 0 less than secs less then max time is almost open l, if equals to max time, is fully opened (just two states are needed, open and close, but you can extimate also the percent of opening with the traveled time…

What would be really hard to make would be the move to position, since if you open to 50, than before going to open to 75 you have to start closing, stopping and then start opening again…

Not sure if the idea it’s more clear now…

Hi! Maybe I missed a point… Do the integration of your domotic system in ha provide a two way communication? I mean… If you press the phisical button of your remote, do HA receive a feedback? If the answer is positive, we can start thingnk about something, with an number helper and an automation that tracks the state of the door.

Yes, sure… Both ha or the original domotic system are aware of the event on entities. The problem is that the original system is not aware of the state of this kind of door!

my garage doors also have a one button system, I installed a reed switch to check the position, connected to an ESP board powered by the internal power supply of the garage door motor.

Ok, we can work on it… The idea is to create an helper of type input numbers, which values are from zero to 100. Zero means closed and 100 means open. We also need an additional couple of helpers to track the current direction of the door (up or down) and the transitioning state (opening, closing, idle). The hard part is to track the pressure of the button in the middle of the motion… This introduces a lot complication to the logic. I’m working on ad automation, mostly because it’s a tricky task and I would like to check my skills on HA complex automation :innocent:

for me the tricky part would be to track seconds in movement… if i’m able to do that, then on press of the button those seconds should go up or down as per direction… and all would work good… :smiley:

Did you already know the time of transition from open to close an vice versa? Could you please tell me that time? Another question: did the door has a delay from the pressure of the button (phisical or in ha) to the moment it start effectively moving?

My idea is to have an helper to track the “next direction of movement” the door. In this way if you stop it “mid air”, HA is able to know if the next direction is up or down. I am thinking about two distinct automation, one of the up and one for the dowm. Both will be triggered by the “toggle” of the switch, and have a condition (“and if”) tied to the helper cited before, the “next direction”. Both automation will have the same logic to run. This is a preview, bit is not yet complete. I’ll keep you updated :grinning:

Total time of opening and closing is about 32 seconds. No other delays involved :sweat_smile:

Maybe I found a solution… Any comment is welcome! :slight_smile:

So first of all I created 2 helpers:

  • input_text.garage_state
  • input_number.garage_moving_time

Then I define this automation:

Automation
alias: Garage Automation - Button
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_button.test
    to: null
  - trigger: state
    entity_id:
      - input_text.garage_state
    to:
      - Opening
      - Closing
    for:
      seconds: 30
actions:
  - variables:
      actualState: "{{ states( 'input_text.garage_state' )  }}"
      movingTime: >-
        {%- if actualState in ('Opening','Closing') %} {{ (as_timestamp(now()) -
        as_timestamp(states.input_text.garage_state.last_changed) | int) }}
        {%- else %} 0
        {%- endif %}
  - action: input_number.set_value
    target:
      entity_id: input_number.garage_moving_time
    data:
      value: >-
        {%- if actualState == 'Opening' %} {{ min((movingTime + (states( 'input_number.garage_moving_time' ) | int) | int), 30) }}
        {%- elif actualState == 'Closing' %}
        {{ max(((states( 'input_number.garage_moving_time' ) | int) - movingTime | int), 0) }}
        {%- else %} {{ states( 'input_number.garage_moving_time' ) }} 
        {%- endif %}
  - action: input_text.set_value
    target:
      entity_id: input_text.garage_state
    data:
      value: >-
        {%- if actualState == 'Closed' %} Opening
        {%- elif actualState == 'Open' %} Closing
        {%- elif actualState == 'Opening' %} Open
        {%- elif actualState == 'Closing' %} Closed
        {%- else %} {{ states('input_text.garage_state' ) }}
        {%- endif %}
mode: single

Finally, a cover template:

Cover
  - platform: template
    covers:
      garage_door:
        friendly_name: Garage
        unique_id: garage_door
        open_cover:
          service: input_button.press
          data:
            entity_id: input_button.test
        close_cover:
          service: input_button.press
          data:
            entity_id: input_button.test
        availability_template: >
          {%- if not is_state("input_button.press", "unavailable") %}
            true
          {%- endif %}
        value_template: >
          {%- if states("input_text.garage_state") in ('Opening', 'Closing') %}
            {{ states("input_text.garage_state") }}
          {%- elif states("input_number.garage_moving_time") | int > 1 %}
            open
          {%- else %}
            {{ states("input_text.garage_state") }}
          {%- endif %}
        position_template: >
          {{ ((states("input_number.garage_moving_time") | int) / 30 * 100) | int }}

Maybe a reset button to bring back state to close and time to 0 in case something goes out of sync could be a good idea…!

Also, actually the time of 30 seconds max move is fixed, maybe it could become another helper too…

I have exactly the same type of garage door remote control. One button which opens/closes/stops. That remote control is a radio frequency (RF) remote control. Luckily I have one of these which is on my Tuya system and hence also on my HA system. I have been able to learn the single push from this so now I can control my garage door from my HA system. I faced the same problem in that there is no way of knowing the current state of the door. Therefore I purchased a proximity sensor (which is the simplest thing I could think of) which senses if the door is closed. So with that knowledge, I can now automate opening the door but only do that if it is closed already; or conversely closing the door but only if it is not closed already.

I’m in my early days of making this useful to me because ultimately I want it to open only when I return from a bike ride so I can ride straight into the garage. Also it will close the garage door when I am on my bike starting a bike ride. To be honest, it is a bit hit and miss so far! This is because it relies on the Focus state of my iPhone which activates a focus when I start my cycling app on my phone… I still need some way to alert me if the door didn’t close when I left :slight_smile: