Simple Garage door switch

How can I create a switch for an automated gate or garage door that just uses a push (momentary). In my case a single push opens or closes the gate, so its dumb in affect. I’m mainly using Lovelace.
Thanks

Are you using any devices currently? Like zwave, zigbee, esp?

Yes I already have it working through Smartthings _ its actually wired into an alarm system which is then connected to Smartthings, Smartthings to Homeassistant. So question is I want to create a virtual switch that sends one pulse.

what does it show up as in home assistant? What domain specifically?

Without knowing your devices and such, here’s how mine is setup. I use a Mimolite ZWave relay that’s connected SmartThings. This created a binary_sensor.front_gate_contact that’s either ‘on’ or ‘off’ based on if the gate’s open or closed and then a switch.front_gate to trigger the gate to open/close.

- platform: template
  switches:
   front_drive_gate:
     friendly_name: "Front Driveway Gate"
     value_template: "{{ is_state('binary_sensor.front_gate_contact', 'on') }}"
     turn_on:
       service: switch.toggle
       data:
         entity_id: switch.front_gate
     turn_off:
       service: switch.toggle
       data:
         entity_id: switch.front_gate
     icon_template: "mdi:gate"

FWIW, I setup very similar template switches for my garage doors…

1 Like

Thanks, Mine comes through as a Binary Switch ON or Off - I don’t have the secondary switch or sensor that you do . I suspect if I use the On/OFF it may do damage as it will send a constant through and I only want a momentary switch.
I literally only want to blip a bit of current into it to kick it off, if that makes sense?

If it comes through as a switch (I.e. the switch domain), and you only want it on momentarily…

script:
  momentary_front_gate:
    sequence:
     - service: switch.turn_on
       data:
         entity_id: switch.front_gate
     - delay: "00:00:01"
     - service: switch.turn_off
       data:
         entity_id: switch.front_gate

It’ll show up as the word ‘execute’ in the UI and you can configure lovelace button card to turn it into a button.

Or if you want it as a switch that turns on then off…

switch:
- platform: template
  switches:
   front_drive_gate:
     friendly_name: "Front Driveway Gate"
     value_template: "{{ is_state('switch.front_gate', 'on') }}"
     turn_on:
     - service: switch.turn_on
       data:
         entity_id: switch.front_gate
     - delay: "00:00:01"
     - service: switch.turn_off
       data:
         entity_id: switch.front_gate
     turn_off:
     - service: switch.turn_on
       data:
         entity_id: switch.front_gate
     - delay: "00:00:01"
     - service: switch.turn_off
       data:
         entity_id: switch.front_gate
     icon_template: "mdi:gate"

The delay keeps the signal on for 1 second.

if you want less duration use

     - delay:
         milliseconds: 50

Thanks so much for help.
This is very new to me - Not sure if I’ve fully understood.
I took your first example and copied it (replacing the entity word accordingly to match mine) into my blank file script.yaml, did a Restart But cant find anything or where it went to add it.

Post what you configured and tell us the name of the entity_id. Please use the stickied post as a guide on how to properly post and format code.

I put the below in using the Configurator add on for Hassio which (I believe) picks up inaccurate YAML formatting.
I also have an error in “script” and “default-config” reported in Notifications since adding the script.
I do have in the configuration.yaml trhe line:
script: !include scripts.yaml
I have no idea where the number sequences on lines 11 & 17 Came from.

script:
  momentary_front_gate:
    sequence:
    - service: switch.turn_on
      data:
        entity_id: switch.main_gate
    - delay: 00:00:01
    - service: switch.turn_off
      data:
        entity_id: switch.main_gate
'1576923431022':
  alias: Toggle Main Gate
  sequence:
  - data: {}
    entity_id: switch.main_gate
    service: switch.toggle
'1576923477745':
  alias: Main Gate Toggle
  sequence:
  - data: {}
    entity_id: switch.main_gate
    service: switch.toggle

Thanks

Remove the word script inside the script file. If you use:

script: !include scripts.yaml

inside configuration.yaml, then your scripts.yaml file should read:

  momentary_front_gate:
    sequence:
    - service: switch.turn_on
      data:
        entity_id: switch.main_gate
    - delay: 00:00:01
    - service: switch.turn_off
      data:
        entity_id: switch.main_gate
2 Likes

Thank - you so much - That worked a treat. Much appreciated.

Here is my config with Tasmota flashed Shelly1
Detached switch SW on shelly is binary_sensor.switch1
switch.tasmota triggers Shelly relais

switch:
- platform: template
  switches:
   garage:
     friendly_name: "garage"
     value_template: "{{ is_state('binary_sensor.switch1', 'on') }}"
     turn_on:
       service: switch.toggle
       data:
         entity_id: switch.tasmota
     turn_off:
       service: switch.toggle
       data:
         entity_id: switch.tasmota
     icon_template: >-
          {% if is_state('binary_sensor.switch1','on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

I’ve got a similar setup working with an ESPHome device… A switch and a contact.
I’m now trying to figure out how to show this as a single icon in Lovelace that both activates the switch but also shows the open/closed status… Is anyone able to share some card config that does this?

EDIT : Searching outside of the community forums found this which looks to be pretty much my setup :slight_smile: Cheap and Easy Home Assistant Garage Door Control

So I am reading through and trying these yaml configurations… this got me closer… so I have been running an AGS Home garage door opener, it works flawlessly with smart life app, once I have started getting into HA it still works from app but it doesn’t show up through HA under Smart life. INSTEAD it shows up as sensor.local_ip

This is a wifi relay that has a magnet sensor as stated from someone else. so the configuration i have gotten to work is

"cover:

  • platform: template
    covers:
    garage_door:
    device_class: garage
    friendly_name: “Garage Door 1”
    value_template: “{{ is_state(‘sensor.local_ip’, ‘on’) }}”
    open_cover:
    service: switch.turn_on
    entity_id: sensor.local_ip
    close_cover:
    service: switch.turn_on
    entity_id: sensor.local_ip
    stop_cover:
    service: switch.turn_on
    entity_id: sensor.local_ip"

by work I mean I am able to see its state (when toggled through phone) but unable to call for open/close… any input would help New here!

Those service calls should be a paired switch entity, you’re calling the with a sensor entity. What switch should it be turning on/off?

So there should be a second device coming up in system and it’s not … I looked through my router it comes up as an esp device which I’ve seen things posted but have not gotten far enough into HA … So I’m missing something

did you set up esphome & the device?

I made an attempt last night and couldn’t get it loaded from intergration side… Do I have to do anything on front end first? Appreciate the help

I have a door where i have to push twice the shelly to open the door.
My intension is that i want to push the switch ons to on and the door opens.
If i tap the switch again it closes the door

So for every action open/close i have to push the switch twice.
Therefore the status of the door is never clear.

Any idea on that how to solve ? @petro