Garage door status icon

Hi, I saw fee topics about garage door - but could not find any that will explain how to configure HA - to show just an icon of garage that is open and if closed - icon of garage closed. I use Sonoff wifi controller - so I have already the sensor added.

1 Like

Personally I built a template switch for mine. https://www.home-assistant.io/integrations/switch.template/

    garage_door_main:
      friendly_name: "Main Garage Door Switch"
      value_template: "{{ is_state('cover.main_garage_door', 'open') }}"
      turn_on:
        service: cover.open_cover
        data:
          entity_id: cover.main_garage_door
      turn_off:
        service: cover.close_cover
        data:
          entity_id: cover.main_garage_door
      icon_template: >-
        {% if is_state('cover.main_garage_door', 'open') %}
          mdi:garage-open
        {% else %}
          mdi:garage
        {% endif %}
2 Likes

I have been setting this up myself and I have just been using the sensor directly to determine open/closed.

By adding the device_class into the sensor I was able to show the correct icon and status for the garage door. I am using tasmota on an ESP8266 based garage door opener. (not the sonoff)

binary_sensor:
  - platform: "mqtt"
    device_class: "garage_door"
    name: "Garage Door Open Sensor"
    unique_id: "binary_sensor.garage_door_open"
    state_topic: "stat/GarageDoor/DOOR"
    availability_topic: "tele/GarageDoor/LWT"
    payload_on: "OPEN"
    payload_off: "CLOSED"
    payload_available: "Online"
    payload_not_available: "Offline"

i love this about HA, that there are so many different ways to accomplish the same thing. hereā€™s mineā€¦

            type: 'custom:button-card'
            entity: binary_sensor.garage_door
            show_icon: true
            show_name: true
            tap_action:
              action: call-service
              service: switch.turn_on
              service_data:
                entity_id: switch.garage_door_opener_47
            icon: 'hass:garage'
            state:
              - value: 'on'
                icon: 'hass:garage-open'
                color: 'rgb(255,0,0)'
              - value: 'off'
                color: 'rgb(68,115,159)'

itā€™s using the custom button card from here:

if you want it to just be an icon and not do anything when pressed, just remove the tap-action section (or, i believe you can set action: none).

5 Likes

Thanks All for the input! Really appreciate! I am trying to go with the option from @Markus99 with switch template. I have gone through step by step instructions how to setup a switch template. All is setup - but I could not find (sorry - I am very beginner:) how to link my sonoff entity (already existing on the list (switch.sonoff_1000dsdd4fs) to the cover.main_garage_door ?

'configuration.yaml

cover: !include covers.yaml
switch:

  • platform: template
    switches:
    garage:
    value_template: ā€œ{{ is_state(ā€˜cover.garage_doorā€™, ā€˜onā€™) }}ā€
    turn_on:
    service: cover.open_cover
    data:
    entity_id: cover.garage_door
    turn_off:
    service: cover.close_cover
    data:
    entity_id: cover.garage_door
    icon_template: >-
    {% if is_state(ā€˜cover.garage_doorā€™, ā€˜openā€™) %}
    mdi:garage-open
    {% else %}
    mdi:garage
    {% endif %}

covers.yaml

  • platform: template
    covers:
    garage_door:
    device_class: garage
    friendly_name: ā€œGarage Doorā€
    position_template: ā€œ{{ states(ā€˜sensor.garage_doorā€™) }}ā€
    open_cover:
    service: switch.turn_on
    data:
    entity_id: switch.garage_door
    close_cover:
    service: switch.turn_off
    data:
    entity_id: switch.garage_door
    stop_cover:
    service: switch.turn_on
    data:
    entity_id: switch.garage_door
    icon_template: >-
    {% if states(ā€˜sensor.garage_doorā€™)|float > 0 %}
    mdi:garage-open
    {% else %}
    mdi:garage
    {% endif %}
    ā€™
    thanks!

Iā€™m using the custom button card. Works great. Setup with the color changing from green if it is closed to orange if it open. Showing the door in the open and closed state.

image

2 Likes

yes - but you need to be in Lovelace UI - to use itā€¦

Hey, great, can you explain to me how you did please change the icon status?
Thank you in advance.

Iā€™m using the horizontal stack card for what I posted above. You can just use the manual card with the code below to shown just one button.
Here is the code for just the garage door button. One tap will close the garage door and double tap will open it. Just change the ā€œentity_idā€ to yours and play around with the sizing to suit.

card:
  - height: 10px
  - width: 60px
double_tap_action:
  action: call-service
  service: cover.open_cover
  service_data:
    entity_id: cover.garage_door
entity: cover.garage_door
show_state: true
size: 40%
state:
  - color: green
    icon: 'mdi:garage'
    value: closed
  - color: orange
    icon: 'mdi:garage-open'
    value: open
styles: null
tap_action:
  action: call-service
  service: cover.close_cover
  service_data:
    entity_id: cover.garage_door
type: 'custom:button-card'
1 Like

Yes OK great, thank you very much, but how do you change the background color of the card? Thanks to you

I use the google dark theme.

All right, all right, thank you very much.

But it is not possible to change the background colour directly in the map?

Hi Matt, thanks for this. It is working for me almost well. I have setup everything but I cannot close the door. So - when I tap on the button door - the door is opening + changing the icon. Which is fine. But when I click for the second time - it doesnā€™t close the door - there is just no reactionā€¦

My binary sensor is configured as:

binary_sensor:

  • platform: template
    sensors:
    sonoff_dfdffdgfd:
    device_class: garage_door
    value_template: ā€œ{{ is_state(ā€˜switch.sonoff_dfdffdgfdā€™, ā€˜onā€™) }}ā€

you might have to adapt it to fit your setup.

my garage door is just controlled via a z-wave outlet that is attached to a relay thatā€™s wired into the bell wire on the opener, which when turned on is effectively like iā€™m standing in the garage pressing the wall button. i have a HA automation that always turns that outlet off 2 sec after itā€™s turned onā€¦so when i turn that outlet on, itā€™s basically the same thing as if i were standing there holding the wall button down for 2 sec.

the catch here is that you canā€™t (at least i donā€™t think you can) change the action on that card based on the state of the door. it works for me because no matter whether iā€™m opening or closing, itā€™s always the same action (just turn on the garage door opener outlet).

if you have separate actions for open and close, you can use a state-switch to change the card based on the state of the door (which will allow you to set up two different cards with different actions).

something like thisā€¦

            type: 'custom:state-switch'
            entity: garage_door_sensor
            states:
              'off':
                type: 'custom:button-card'
                entity: garage_door_sensor
                show_icon: true
                show_name: true
                tap_action:
                  action: action.do_garage_door_open
                icon: 'hass:garage'
                state:
                  - value: 'off'
                    color: 'rgb(68,115,159)'
              'on':
                type: 'custom:button-card'
                entity: garage_door_sensor
                show_icon: true
                show_name: true
                tap_action:
                  action: action.do_garage_door_close
                icon: 'hass:garage-open'
                state:
                  - value: 'on'
                    color: 'rgb(255,0,0)'

that may be even easier if you have just one sensor that controls both the door status and the open/close, youā€™d be able to change the entity on the on/off cards to match that entity and run whatever service calls you need on that. in my case, i have a sensor on the door that tells me if itā€™s open (on) or closed (off), so i would use that entity to determine the status of the door and what icon to show.

i hope that makes senseā€¦let me know if anything is confusing and iā€™ll do my best to help (of course anyone else feel free to jump in too if i missed something obvious).

2 Likes

Very niceā€“I think this is my favourite way to surface a garage door opener. Status and action from a single icon wins the WAF award too. I changed the door opener to a hold_action as Iā€™ve accidentally swiped it on my phone. A tap calls more_info.

1 Like

thatā€™s actually a really good idea (changing the actual open action to hold rather than tap). iā€™m always paranoid that iā€™m going to randomly open the door when i donā€™t want to.

i also have mine set up to not allow for opening the door at night - if my alarm is turned on in night mode, the button changes to only be more info (no way to actually open the door via the button). itā€™s also conditional so that if the door is open, i can close it from the buttonā€¦just wonā€™t allow me to open from the button.

if i want to open it, i can always go into the device itself and turn it onā€¦itā€™s just my own failsafe so i donā€™t bump the button in the middle of the night and randomly open the garage door without realizing it.

Sadly, on iOS at least, the hold action is extremely unreliable. Iā€™ve changed to double tap which seems good so far.

What is it about tech demos to the wife that means they always seem to fail? :slight_smile:

i am thinking about trying to work up a confirmation popup so that i can safely use single tap without worry about bumping it accidentallyā€¦

Did you ever incorporate a confirmation?

no, but I have added a smart switch that the opener is plugged into that is turned off except when I need to open the doorā€¦which is effectively like a garage door lock (with no power to the opener thereā€™s no way to open the door).