Window Icons Opened/Closed

Hi there,

I would like to use the mdi:window-closed/open-variant instead of the mdi:window-open/closed icons. I changed the Icon in the frontend, but now it only shows the closed icon.

Come on, with this minimal information we can’t help you because we don’t know what you are trying to do :man_shrugging:
Where are you trying to use the icon? In a card? Which card? Where in the frontend? So many questions …

Mats789 is right that your post as written is unlikely to get you responses from people who might know the answer, without some uncommon luck.

You might be lucky today, though, because I think I know what you’re talking about: I recently encountered an issue that could be described in a similar way. You have changed an icon, somewhere (possibly in the Entity configuration dialog, or possibly in some card on a dashboard), and although the icon is the one you selected, you’ve lost functionality. Previously, with the default setting, the icon would update based on the state, but you’re now seeing the same icon regardless of the state.

Which sucks, even though it’s the icon you selected.

You should give more information about exactly where you changed the icon, because there might be a simpler way to do than what I’m about to suggest. But one general way to define context-dependent icons in HA is to define a Template (in this case a Binary Sensor) that has the same exact state as the original entity. You can define an icon: with that mechanism using a Jinja template that can reference the state. So, in the template binary sensor definition, you could do, for example:

template:

  # ... other template code if it exists
  - binary_sensor:

    - name:         your_new_sensor_name
      state:        > 
        {{ 
           states   ('binary_sensor.entity_id_of_existing_sensor') 
        }}
      availability: > 
        {{ 
           has_value('binary_sensor.entity_id_of_existing_sensor') 
        }}
      icon:  >
        {% if has_value('binary_sensor.entity_id_of_existing_sensor')  %}
          {% set  val = states('binary_sensor.entity_id_of_existing_sensor') |bool %}
          {% if   val %}
             mdi:window-open-variant 
          {% else %}
             mdi:window-closed-variant 
          {% endif %}
        {% else %}
          mdi:skull-outline
        {% endif %}
             

Thanks for the reply, even if my question was not very detailed. What you described is exactly what happened. I want to display the window icon on a dashboard and it now does not change anymore after I defined a new icon in the entity-definition via frontend.

Do I really have to create new binary_sensor entities? I really don’t want to redo all my dashboards. I want the functionality in the existing binary_sensors. And I would be very happy, if there is an option to do this for all window entities, as I have about 50 of them.

Just for clarification. I changed the icon by clicking on it in a header-card on a dashboard and then clicking on the gear icon.

If you want the entity’s icon to work this way across all of HA, I am not aware of another way. Perhaps someone else here is and, if they are, they’ll chime in. I’d be interested in a less laborious way, too, because having to create template sensors just to change the dynamic icons takes… dedication, at minimum.

If you do end up doing it, you might be able to help yourself by writing a blueprint.

OK. Thanks. I at least got it to work the old way, by just clicking on the “x” beneath the icon field in the very same dialog were I changed it. So I’ll live with the US-window icons, which nobody in Europe understands, as we open our windows like doors.