Garage Door Button Configuration

Tags: #<Tag:0x00007fc40c4556f0>

I have a garage door I am trying to control. It is made up of a binary_sensor and a switch. The sensor is the open/closed state, and the switch acts like pressing the physical button in the garage. When it is “on” the contacts are closed to start the opener, but it has to get back to the “off” state to reset.

All of this is going through an ISY994 and I have a program that will automatically turn the switch off after 1 second of being on.

I am using this switch template in my main configuration.yaml file to join the 2 controls into 1:

switch:
  - platform: template
    switches:
      garage_door_kubota:
        friendly_name: "Garage Door Kubota"
        value_template: "{{ is_state('binary_sensor.garage_door_1_window_alarm', 'Open') }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.garage_door_1_binary_switch
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.garage_door_1_binary_switch
        icon_template: >-
          {% if is_state('binary_sensor.garage_door_1_window_alarm', 'Open') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

I still have the independant switch and sensor displayed so I can make sure the combined switch is doing what I want (which it isn’t yet). I do get an icon of a closed garage door, but when the switch is in the “on” state, the icon stays blue instead of turning yellow. When the sensor displays “Open” the door icon doesn’t change to the open icon.

Any ideas on what I might be missing?

Thanks,
John Vickers

Try replacing the icon_template section with

        state:
          - id: value_on
            value: 'Open'
            icon: 'mdi:garage-open'
            styles:
              card:
                - background-color: gold
              name:
                - color: blue
              icon:
                - color: blue
                - opacity: 1
          - id: value_off
            value: 'Closed'
            icon: 'mdi:garage'
            styles:
              card:
                - background-color: slateGrey
              name:
                - color: white
              icon:
                - color: white
                - opacity: 0.5

I think you’re describing a momentary button, so I think you only ever need to turn it on if something else is turning it off.

Also paste the template code in the template editor under developer tools or check the actual state value under the state tools. I’m fairly sure you should check for 'on' rather than 'Open' in your value_template.


Alternatively, you could consider making a proper cover for this, like so (example):

- platform: template
  covers:
    main_gate:
      friendly_name: "Main Gate"
      device_class: gate
      open_cover:
        service: switch.turn_on
        data:
          entity_id: switch.gate_remote
      close_cover:
        service: switch.turn_on
        data:
          entity_id: switch.gate_remote
      stop_cover:
        service: switch.turn_on
        data:
          entity_id: switch.gate_remote
      value_template: "{{ is_state('binary_sensor.gate_status', 'on') }}"
      icon_template: >-
        {% if is_state('binary_sensor.gate_status', 'on') %}
          mdi:gate-open
        {% else %}
          mdi:gate
        {% endif %}