Dynamic Icon on Cover MQTT failes on external state update

Hi HA Community,

Tinkering w/o sucess sucks :slight_smile: :frowning:

I do want to change my garage door integration to a shelly1plus running a script that uses MQTT with HA and a MQTT cover. Almost everything works, however, i fail with dynamic setting of my icon. I run updated HA on an odroid-n2.

  • Home Assistant 2022.8.2
  • Supervisor 2022.07.0
  • Operating System 8.4
  • Frontend 20220802.0 - latest

The config i use is:

mqtt:
  cover:
    - name: "Garagentor"
      device_class: "garage"
      unique_id: "MQTTGARAGE"
      command_topic: "home-assistant/garage/set"
      payload_open: "OPEN"
      payload_close: "CLOSE"
      payload_stop: "STOP"
      state_topic: "home-assistant/garage/state"
      state_open: "open"
      state_opening: "opening"
      state_closed: "closed"
      state_closing: "closing"
      icon: >-
        {% if states['cover.garagentor'].state == 'open' %}
        'mdi:garage-open'
        {% elif states['cover.garagentor'].state == 'closed' %}
        'mdi:garage'
        {% elif states['cover.garagentor'].state == 'opening' %}
        'mdi:arrow-up-bold'
        {% elif states['cover.garagentor'].state == 'closing' %}
        'mdi:arrow-down-bold'
        {%else%}
        'mdi:alert'
        {%endif%}

i think it is not part of my issue, but the shelly script is here:

Id say it works good, just the dyn icon fails greatly.

Imagine the following matrix:

  1. I update the status via Dev Tools / States
  2. I update the status via shelly / mqtt. I can see the correct state under Dev Tools / States

and

A. I review the output of the icon script in the Dev Tools / Template
B. I look at the Icon in the Dashboard or App.

Now what drives me crazy

1A - works. i can see always the right icon name
2A - works. i can see always the right icon name (!)
1B - works. i can see the icon change as soon as i sert the state
2B - nope. no icon is shown. empty.

That drives me a little cazy.

My conlusions:

  • My Icon Template works
  • The way i configured the MQTT cover works. I can see in the status the correct values; i can send the right results
  • Dynamicl changing of cover icons work

So, I’d say, it must work perfectly, right?

But it does not. Can anybody hint me into what could possibly go wrong here? I miss what i could possibly look after anymore…

Best
Michael

Hmm, i checkt a lot of permutations. This morning it runs without the icon entry of the template perfectly, obviously following the device class garage.

Nevertheless i can not explain to me the behaviour above…