Customising Dashboard

Hello,

I am new to HA, and I am currently trying to customise my dashboard and I am a little bit confused on how to do it.
I have currently sensor that detect door open and door closed. they are working fine and the following code entered in the UI is working well

type: entities
entities:
  - entity: binary_sensor.window_door_sensor_entree
  - entity: binary_sensor.openclose_portejardin
  - entity: binary_sensor.openclose_11
title: Ouvertures
show_header_toggle: true
state_color: true

Now I would like to have the icon changed based on state and I cannot find a way to do it. I read the documentation about template but it is not clear for me what to use and how to make it work. Should I enter the code in the UI, shoud I create a file and reference it in may config file with the customize tag?

Nicolas

Can you tell us how the binary_sensors were defined?

Here it is.

Sorry, that is not what I meant.

How was the binary sensor made?

What platform was used?

Hello Tom,

Sorry I am not sure which information you want.
This is a zigbee sensor, I added via the deCONZ UI interface
It is working fine as it shows open and closed status.

The things now is that I don’t understand from the documentation how to have the icon changed based on the status on/off

That’s what I wanted. As you can not edit this directly you will have to use customize to change your icons.

If you add this to your customize.yaml flie:

binary_sensor.window_door_sensor_entree:
  device_class: door

The icon should change with state.

Thanks Tom, i have added the customization file according to the documentation and put
binary_sensor.window_door_sensor_entree:
device_class: door

But the icon doesn’t change (only the color changes)
I have tried adding
icon: if (state === 'on') return 'mdi:door'; return 'mdi:door-open';

but this doesn’t work either

Did you reload customize after adding this to the file:

binary_sensor.window_door_sensor_entree:
  device_class: door

Do not use templates in customize. They do not work there.

Yes I did reload, but the icon doesn’t change, it only changes the color of the door.
Reading you message I should use “template” with the icon_template tag to implement this behaviour?
If yes how do I link my sensor with the template?
Should I put this template in the configuration file?

Thanks again for the time you spend answering my questions, I really apreciate

Nicolas

You don’t need a template.

You can’t use a template.

Put this in your customize.yaml file:

binary_sensor.window_door_sensor_entree:
  device_class: door

Put this in your configuration.yaml file:

homeassistant:
  customize: !include customize.yaml

Restart home assistant.

I have done that, but it doesn’t make my icon change when the status change

Try removing this:

b9735a1789007827269f6d455745d244c97ee244

It might have priority over customize.

1 Like

you were right, It works!!

Thanks very much
now can I do the same thing for a window? is there a place in the documentation where all the device_class are described?

What if I want to change the default icons?

I tested window is working

Here’s one I prepared earlier:

The image on the official page is a bit outdated (and I can’t update it):

Thanks,

I’ll look at it.