#Garage Open Icon

1 messages · Page 1 of 1 (latest)

brave tapir
#

Can someone help me out with this. I want a red background with yellow open garage icon if my tilt sensor is "up" and a black background w blue color closed garage icon if closed. Here is my YAML (which I adit, I dont fully understand). Thanks.

type: custom:button-card
entity: binary_sensor.2_garage_tilt_sensor_third_reality_opening
show_state: true
name: Garage
styles:
card:
- height: 100px
- width: 100px
- background-color: |
[[[
if (states['binary_sensor.2_garage_tilt_sensor_third_reality_opening'].state == 'open')
return 'red';
if (states['binary_sensor.2_garage_tilt_sensor_third_reality_opening'].state == 'closed')
return 'black';

    ]]]
#

BTW, here are the current icons in their states.

craggy panther
#

The state of a binary sensor is always on and off, not open or closed

#

It looks like your binary_sensor has a device_class of opening, you would get a garage door icon if you change that to device_class garage_door.

brave tapir
#

ok, this is where being a newbie getting me caught up. From what I can tell, its open or closed but I guess I am wrong about that.

craggy panther
#

Yeah those are translations of the state, not the raw state.

#

Always check developer-tools/states if you want to see the actual string value of a state, not necessarily the "prettified" version.

brave tapir
#

ok, so i am still having probs w the icon. Did i put this in the wrong place?

craggy panther
#

This is a fine place for this thread.

brave tapir
craggy panther
#

oh

#

yes, the device_class is a property of the entity itself, not part of the card UI

brave tapir
craggy panther
#

open the more-info for that entity, and click the cog

brave tapir
#

Ah! That should be garage door... got it

craggy panther
#

yes, that is the device_class

brave tapir
#

It works!! I learned something too!

#

Now i have to fix the colors.. ill change to On vs off?

craggy panther
#

sure give that a try

brave tapir
#

Holy crap - it worked! Thank you so much Karwosts!!!!

#

Super super appreciate this Been trying to get this to work for weeks!