I am trying to create a button that will open and shut the door by pressing the symbol of the door but also change colour when it is open or shut and state whether the door is open or closed.
This is really helpful, because I have my switch_relay on inching I just get the green door and it momentarily switches to red, when I put my door sensor into the equation it doesnt work .
The second line should have your binary sensor, not the switch. Also the states are reversed if your binary_sensor.door_sensor_alarm_door equals “off” when the door is closed and equals “on” when the door is open. In theory, this should work::
To change color, I have found two practical options.
The first option is to use this thing called card-mod, Which is horribly complicated, but it lets you change any style based on any property of the card, live.
The second option which is going to be far easier is to use the mushroom template card. With the mushroom template card you can template anything that goes in the card — including the icon, the color of the card or the icon, the contents of the primary and secondary lines of text and what actions may happen when the card is acted upon.
I am currently using both things right now in my dashboard to display caution/danger warning tiles, that appear conditionally on certain dashboards in different colors like yellow and red, whenever there are situations that need attention. Here is code for one of these warning tiles: