Icon State Change_Garage

Need some help again with my HA home screen icons. Have a single and a double garage icons, the single garage icon changes its state to open when garage door is open but the double garage doesn’t show the door open. I know HA has evolved considerably since the last time I did something like this. I think I use a Custom Card but I will like to achieve the same results on the this binary sensor card on my home screen. I’m using Sonoff as my Zigbee coordinator with some Aqara contact sensors to monitor my garage doors.

  1. a picture like this tells absolutely nothing, your code is needed to tell anything
  2. binary.sensor actual state is not open/close but on/off

Edit you could use “Custom: Template-entity-row” to show whatever you want

The device class (that has the changing icon) is only for a single garage. There is no double garage device class. All you have done is change the default icon.

This can be fixed with an icon template if the the cover is defined in yaml. If it is a discovered entity you are out of luck. I proposed a fix for this you can vote for it here: https://community.home-assistant.io/t/custom-binary-sensor-device-classes/368238

1 Like

I have this code on my configuration.yaml that created another entity that I’m using on a custom card but I notice that it didn’t change the icon either.

binary_sensor:
  - platform: template
    sensors:
      double_garage:
        friendly_name: Double Garage
        device_class: opening
        value_template: "{{ states('binary_sensor.double_garage_contact') }}"
        icon_template: "mdi:garage-{{ 'open-' if is_state('binary_sensor.double_garage_contact', 'on') else '' }}variant"

Can you correctly format your pasted code please?

My apologies Tom … Can you tell me which option do I use to post the code. I’m a little rusted

Follow the link in my post. It has an explanation.

Thank you Tom. I corrected the code

Thanks.

The icon template looks correct to me.

It’s possible that this is overriding the icon template:

device_class: opening

Try it without that device class (just as a test). The states will be on/off instead of open/closed but ignore that for the test.

The removal of the device class, did not made the icon switch from a close visual state to an open visual state.

Ok, put this in the developer tools template editor and screen-shot the output with your door open and closed:

state: {{ states('binary_sensor.double_garage_contact' }}
icon: mdi:garage-{{ 'open-' if is_state('binary_sensor.double_garage_contact', 'on') else '' }}variant

Here is what I got for the output on both instances

Ok so that all looks good.

Are you perhaps overriding the icon in the card config?

Yehp! I did found exactly what you just mention. I had the

mdi:garage_door_variant

and it was super seeding the yaml code. Below is the way it needs to be for it to work correctly.