Garage Door Dynamic Icon

Interesting, I didn’t know there was built-in icon switching functionality based on the device class. Thanks for the update.

@cjlee89 please could I ask you for your configuration.yaml config for your garage door.
Mine is this below

GARAGE DOOR

cover:

  • platform: mqtt
    name: “GARAGE DOOR”
    state_topic: “cmnd/2/POWER2”
    command_topic: “cmnd/GARAGE_DOOR/POWER”
    payload_open: “ON”
    payload_close: “ON”
    payload_stop: “ON”
    state_open: “ON”
    state_closed: “OFF”
    optomistic: false
    retain: false
    my customize.yaml I did as you did. What happens with me is that the door opens and closes but does not show up or down state. thanks Mark

Sure! Mine is coming over from Wink though since HA does not like my controller - http://www.gocontrol.com/detail.php?productId=4

https://github.com/cjlee89/Home-Assistant

1 Like

I seem to have the same problem after updating HA
What do I need to change in the Card Configuration

Also I have this under customize but it has no affect

  customize:
    # Add an entry for each entity that you want to overwrite.
    cover.sonoff_sv_garage:
      device_class: garage
      homebridge_cover_type: garage_door
      friendly_name: Garageport

Also I just took my first step into doing these Card configuration and thought that would generate a lovelaceui.yaml file? but I don’t seem to have one?

I had the same issue. And I see you’re also using a Sonoff SV. I don’t know if you’ve experience this, but when I “open” the door twice in a row, it basically just toggled it twice, and ended up closing it. I wrapped the MQTT garage door cover with a template cover that prevents this. And the template cover also has a custom dynamic icon that works :slight_smile:

cover:
  - platform: mqtt
    name: garagedoor_mqtt
    command_topic: cmnd/GarageDoor/POWER
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_topic: cmnd/GarageDoor/POWER2
    state_open: "ON"
    state_closed: "OFF"
    optimistic: false
    retain: false

  - platform: template
    covers:
      garagedoor:
        friendly_name: Garage Door
        value_template: '{{ is_state("cover.garagedoor_mqtt", "open") }}'
        icon_template: '{% if is_state("cover.garagedoor_mqtt", "open") %}mdi:garage-open{% else %}mdi:garage{% endif %}'
        open_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'closed'
          - service: cover.open_cover
            entity_id: cover.garagedoor_mqtt
        close_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'open'
          - service: cover.close_cover
            entity_id: cover.garagedoor_mqtt

I basically ignore cover.garagedoor_mqtt in favour of cover.garagedoor in all cases.

Hi @SteveDinn

This sounds really promising!
Could explain how to do this? is all this coded directly in the new configure UI or is this for the configuration.yaml (Sorry I am still old school)

cover:
  - platform: mqtt
    name: "sonoff sv garage"
    state_topic: "cmnd/garagestate/POWER2"
    command_topic: "cmnd/Sonoff_SV_Garage/POWER"
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
#    optomistic: false
#    retain:false

Would then be:

cover:
  - platform: mqtt
    name: garagedoor_mqtt
    command_topic: cmnd/Sonoff_SV_Garage/POWER
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_topic: cmnd/garagestate/POWER2
    state_open: "ON"
    state_closed: "OFF"
    optimistic: false
    retain: false

  - platform: template
    covers:
      garagedoor:
        friendly_name: Garage Door
        value_template: '{{ is_state("cover.garagedoor_mqtt", "open") }}'
        icon_template: '{% if is_state("cover.garagedoor_mqtt", "open") %}mdi:garage-open{% else %}mdi:garage{% endif %}'
        open_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'closed'
          - service: cover.open_cover
            entity_id: cover.garagedoor_mqtt
        close_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'open'
          - service: cover.close_cover

Where to put this? and what about the Raw config editor do I need to create something under cards?
Sorry still trying to wreck my head around the new cards :slight_smile:

Best regards
Casperse

1 Like

I haven’t touched the configure UI at all. I’m editing everything in Visual Studio Code. Everything I posted is for configuration.yaml.

From what I posted here, you only have to add “cover.garagedoor” to your cards, and you can keep “cover.garagedoor_mqtt” completely hidden.

Thanks!

I tried adding it and comment the old code out like this:

cover:
#  - platform: mqtt
#    name: "sonoff sv garage"
#    state_topic: "cmnd/garagestate/POWER2"
#    command_topic: "cmnd/Sonoff_SV_Garage/POWER"
#    payload_open: "ON"
#    payload_close: "ON"
#    payload_stop: "ON"
#    state_open: "ON"
#    state_closed: "OFF"
#    optomistic: false
#    retain:false

  - platform: mqtt
    name: garagedoor_mqtt
    command_topic: cmnd/Sonoff_SV_Garage/POWER
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_topic: cmnd/garagestate/POWER2
    state_open: "ON"
    state_closed: "OFF"
    optimistic: false
    retain: false

  - platform: template
    covers:
      garagedoor:
        friendly_name: Garage Door
        value_template: '{{ is_state("cover.garagedoor_mqtt", "open") }}'
        icon_template: '{% if is_state("cover.garagedoor_mqtt", "open") %}mdi:garage-open{% else %}mdi:garage{% endif %}'
        open_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'closed'
          - service: cover.open_cover
            entity_id: cover.garagedoor_mqtt
        close_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'open'
          - service: cover.close_cover

And I selected the new: cover.garagedoor

For some reason its not working correctly?
Pressing the up arrow opens the garagedoor but it looks like this

image

I then have to wait and press the Up arrow again to close the garagedoor?
I have a magnet that should tell HA that the door is open and switch to the Down Arrow?
I also noticed that the old square “stop button” is gone?

What have I not changed correctly?
Again thanks for your help, its much appreciated

BTW: I even made it as a switch because the notification gave me problems: :thinking:

##########################
###  Garage Switch     ###
##########################
switch:
  - platform: template
    switches:
      garagen:
        value_template: "{{ is_state('cover.sonoff_sv_garage', 'open') }}"
        turn_on:
          service: cover.close_cover
          data:
            entity_id: cover.sonoff_sv_garage
        turn_off:
          service: cover.open_cover
          data:
            entity_id: cover.sonoff_sv_garage
        icon_template: >-
          {% if is_state('cover.sonoff_sv_garage', 'open') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

If you look at the documentation for the template cover entity, I just left out the “stop_cover:” section, but you could add:

stop_cover:
  service: cover.stop_cover
  entity_id: cover.garagedoor_mqtt

I left it out because there was no good condition to prevent it from just opening or closing the door if it wasn’t moving, since they’re all the same commands.

If you watch your MQTT broker’s topics, do you see the garage door’s state topic get published when the reed switch is opened or closed?

Hmm yes the same signal toogles the 3 different states: Up, stop, Down

Hmm this is what I see in the log

1552939960: |-- data=username=casperse&password=&topic=&acc=-1&clientid= 1552939960: |-- aclcheck(casperse, stat/Sonoff_S20_3/RESULT, 2) SUPERUSER=Y by http 1552939960: |-- Cached [1C3017049859B695686D5DE3BAA81E313193CC3D] for (client id not available,casperse,2) 1552939960: |-- mosquitto_auth_acl_check(..., client id not available, casperse, stat/Sonoff_S20_3/POWER, MOSQ_ACL_WRITE) 1552939960: |-- url=http://127.0.0.1:8080/superuser 1552939960: |-- data=username=casperse&password=&topic=&acc=-1&clientid= 1552939960: |-- aclcheck(casperse, stat/Sonoff_S20_3/POWER, 2) SUPERUSER=Y by http 1552939960: |-- Cached [BAA579721889F040F8ED090BAB381155AD7F738A] for (client id not available,casperse,2) 1552939960: |-- mosquitto_auth_acl_check(..., client id not available, casperse, stat/Sonoff_S20_3/POWER, MOSQ_ACL_READ) 1552939960: |-- aclcheck(casperse, stat/Sonoff_S20_3/POWER, 1) CACHEDAUTH: 0 1552939977: |-- mosquitto_auth_acl_check(..., client id not available, casperse, cmnd/Sonoff_SV_Garage/POWER, MOSQ_ACL_WRITE) 1552939977: |-- aclcheck(casperse, cmnd/Sonoff_SV_Garage/POWER, 2) CACHEDAUTH: 0 1552939977: |-- mosquitto_auth_acl_check(..., client id not available, casperse, cmnd/Sonoff_SV_Garage/POWER, MOSQ_ACL_READ) 1552939977: |-- aclcheck(casperse, cmnd/Sonoff_SV_Garage/POWER, 1) CACHEDAUTH: 0

BTW
Did you also run these special command on the Sonoff_SV when setting it up?
I found some update to them for the web console

Tasmota updates have changed some necessary settings!
Here’s what you need now: (Thanks Chris Norton)
Switchretain 1
Powerretain 1
switchtopic2 garagestate
switchmode1 0
switchmode2 2

GPIO 14 to 10 Switch2
GPIO 4 to 22 Relay2
pulsetime1 1

Hrm…I’m going to say, “probably”. It’s been a while since I did it, but I followed DrZzzs’ video on it.

Are you using mosquitto as your MQTT broker? You can watch the published topics using this command:

mosquitto_sub -v -h localhost -p 1883 -u [username] -P [password] -t '#'

As for your reed switch, I didn’t see any ‘garagestate’ topics in that log.

Yes I am using the Mosquitto broker
Would that command be used when logged in through putty to HA? (Sorry I haven’t looked at MQTT before, I would love a UI :slight_smile: for that)

I just removed the code for the switch.garagedoor and that have made the arrow switch state (So the it might just be working now!)

one more thing I made a notification on the state change of my switch.garagedoor
How are you triggering a notification when somebody opens the door?
My setup before this change was like this (I even had IOS notification working with a live video feed, none of this works after the many updates sigh…)

UPDATE: I changed the trigger to garage.door and that works ok

# Automations notification (2) for garageport ALWAY (Disabled open if Nobodys home) 
  - alias: 'Notification: Garageport open'
    hide_entity: false
    initial_state: 'on'

trigger:
  - platform: state
    entity_id: cover.garagedoor
    from: 'closed'
    to: 'open'

    action:
      - service: notify.ios_group_caspersen_home
        data:
          message: "Garageporten er åben? {{ states('sensor.time') }}"
          title: "Home Assistant"

UPDATE: Its really not so reliable anymore I pressed the up arrow and it opens the garage door
I then tried to close it and nothing happened I then pressed it again and it sent multiple “push” to the garage door which made it go a little crazy (light on and off signals that the door is going down, so I had alittle lightshow for whole minute and then it closed the door?

Trying to see the commands through putty I get:
Connection Refused: not authorised.
I am using the Mosquitto user and password

Just noticed that you’re missing the conditions in the template cover. In my example, there is a condition to only execute the open script when HA thinks it is closed, and the same but opposite for the close script. That was the entire purpose of the template cover for me. Having a dynamic icon was just a bonus.

For notifications, I was using PushBullet, but I recently moved everything to Telegram. I have an automation that lets me know if the garage door opens when there’s nobody home, or if the garage door is open when we leave.

automation:

This one sends me a notification when I’ve left the door open, and everybody leaves the house, or it’s after 9pm.

  - alias: Garage door left open
    initial_state: 'ON'
    trigger:
      - platform: state
        entity_id: group.device_trackers
        to: 'off'
      - platform: time
        at: '21:00:00'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: cover.garagedoor
          state: 'open'
    action:
      - service: notify.telegram_steve
        data_template:
          title: Garage door opened
          message: >
            Garage door has been left open
            {%- if is_state('group.device_trackers', 'off') %} and nobody is home.
            {% elif ((now().hour >= 21) or (now().hour < 7)) %} and it's a strange time.
            {% else %} but everything seems cool.
            {%- endif %}

This one will notify me if the door opens and nobody is home or it’s late. They’re pretty much the same, just with the triggers and conditions swapped. I could probably combine them into one, but they work, so I haven’t bothered.

  - alias: Garage door opened
    initial_state: 'ON'
    trigger:
      - platform: state
        entity_id: cover.garagedoor
        to: 'open'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: cover.garagedoor
          state: 'open'
        - condition: or
          conditions:
            - condition: state
              entity_id: group.device_trackers
              state: 'off'
            - condition: time
              after: '21:00:00'
              before: '07:00:00'
    action:
      - service: notify.telegram_steve
        data_template:
          title: Garage door opened
          message: >
            Garage door has been opened
            {%- if is_state('group.device_trackers', 'off') %} but nobody is home.
            {% elif ((now().hour >= 21) or (now().hour < 7)) %} and it's a strange time.
            {% else %} but everything seems cool.
            {%- endif %}

Hi @SteveDinn thanks for sharing this! - This has been on my todo for a very long time.

Would you mind sharing your conditions? that I seem to be missing?
Might improve my stability issues :slight_smile:

I am using the HA App and get notification through that works really well

They were in the template cover that I originally posted:

There is a condition in both the “open_cover” and “close_cover” scripts. It’ll only run “open_cover” if the state of the MQTT cover is “closed” and it’ll only run “close_cover” of the state of the MQTT cover is “open”. This way, you’ll never be able to press the down button and have the door go up, and vice versa, despite them being the same MQTT messages.

Of course, this all depends on the state of your MQTT cover being reported correctly. i.e., that reed switch problem you were having will need to be worked out.

Ok then I really don’t think I am missing anything, am I ?

  - platform: mqtt
    name: garagedoor_mqtt
    command_topic: cmnd/Sonoff_SV_Garage/POWER
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_topic: cmnd/garagestate/POWER2
    state_open: "ON"
    state_closed: "OFF"
    optimistic: false
    retain: false

  - platform: template
    covers:
      garagedoor:
        friendly_name: Garage Door
        value_template: '{{ is_state("cover.garagedoor_mqtt", "open") }}'
        icon_template: '{% if is_state("cover.garagedoor_mqtt", "open") %}mdi:garage-open{% else %}mdi:garage{% endif %}'
        open_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'closed'
          - service: cover.open_cover
            entity_id: cover.garagedoor_mqtt
        close_cover:
          - condition: state
            entity_id: cover.garagedoor_mqtt
            state: 'open'
          - service: cover.close_cover
#        stop_cover:  
#            service: cover.stop_cover
#            entity_id: cover.garagedoor_mqtt

I did a telnet with Putty to HA. and logged with root but I couldn’t execute your command?
mosquitto_sub -v -h localhost -p 1883 -u [username] -P [password] -t ‘#’

Maybe I should install the internal console plugin? or replace it with this?
the mqqt and built in webservice?

Yeah, that looks right. I thought that in one of your posts, it didn’t have those conditions.

Hrm…I’m not sure how you have your MQTT set up then. I don’t use the broker that comes with HA. I didn’t like that all the MQTT devices I had would lose contact every time I restarted HA. What error did it give you running that command?

I get a “Error: Address not available” ?

So what MQTT are you using? I guess it wouldn’t be to hard to change it?
I am using the “standard one” Mosquitto broker 4.1 An Open Source MQTT broker.

I assumed that you were running mosquitto on the same machine as Home Assistant. You can replace “localhost” with whatever you’re running mosquitto on. The standard port for MQTT is 1833. If it is the same machine, try using 127.0.0.1 instead of “localhost”.