Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


sfrasernz

234 posts

Master Geek
+1 received by user: 13


#299439 7-Sep-2022 17:55
Send private message

Does anyone have a working config they could share for Home Assistant that will change icons based on the state of the entity?

 

I've tried several configs from the HA forums but a lot of the commands are deprecated and none seem to work. The closest I've got is the config below but the states don't change the icon.

 

MQTT is working and I can control the door and see the State change from 1 (closed) to 0 (open). 

 

 

 

The following is in my configuration.yaml file running HASS 2022.8.7

 

 

 

mqtt:
  cover:
       - name: "Garage Door MQTT"
      device_class: "garage"
      state_topic: "shellies/shelly1-485519/input/0"  
      command_topic: "shellies/shelly1-485519/relay/0/command"
      state_closed: "1"
      state_open: "0"
      payload_open: "toggle"
      payload_stop: "toggle"
      payload_close: "toggle"
      payload_available: "online"
      payload_not_available: "offline"
      icon: >-
        {% if states['cover.garage_door_mqtt'].state == 'closed' %}
        'mdi:garage'
        {% elif states['cover.garage_door_mqtt'].state == 'open' %}
        'mdi:garage-open'
        {%else%}
        'mdi:alert'
        {%endif%}


Create new topic

This is a filtered page: currently showing replies marked as answers. Click here to see full discussion.

1yippy1
67 posts

Master Geek
+1 received by user: 1


  #2964416 7-Sep-2022 20:36
Send private message

this works for me shows blue garage icon when closed and yellow open icon when open:

 

switch garage:
  - platform: template
    switches:
      garage:
        turn_on:
          service: homeassistant.toggle
          data:
            entity_id: switch.garage_door_open_close
        turn_off:
          service: homeassistant.toggle
          data:
            entity_id: switch.garage_door_open_close
        value_template: "{{is_state('binary_sensor.garage_door', 'on')}}"    
        icon_template: >-
          {% if is_state('binary_sensor.garage_door', 'on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.