Hi all
Im feeling so close to have the correct and cool icon so i can see if my garage door is closed or open. But i got a problem i hope you can help with ![]()
The yaml is (Thanks for gimini and chatgpt ) ![]()
type: custom:button-card
entity: switch.shelly_hojre_garage_port # Assuming this is your right garage door switch
name: Right Garage Door
show_state: false
tap_action:
action: call-service
service: switch.toggle
service_data:
entity_id: switch.shelly_hojre_garage_port
# Conditional confirmation based on the sensor state
confirmation:
text: >
[[[
var contact_state = states['binary_sensor.garage_sensor_hojre_contact'].state;
if (contact_state == 'off') {
return 'Are you sure you want to **OPEN** the right door?';
} else if (contact_state == 'on') {
return 'Are you sure you want to **CLOSE** the right door?';
}
]]]
icon: mdi:garage
color: green # <-- Default color is GREEN
color_type: icon
state:
# đź”´ STATE 1: GARAGE DOOR OPEN (ON)
# This state overrides the default color and icon when the sensor is "on"
- entity_id: binary_sensor.garage_sensor_hojre_contact
value: "on"
color: red # <-- Becomes RED when "on"
icon: mdi:garage-open
styles:
icon:
- animation: blink 1.5s infinite alternate
# 🟢 STATE 2: GARAGE DOOR CLOSED (OFF)
# This state enforces GREEN, even though it matches the default color
- entity_id: binary_sensor.garage_sensor_hojre_contact
value: "off"
color: green
icon: mdi:garage
But i when the garage door is finish “opening” it changes to “green”
Is it not possible to just have it “red” when the sensor is “on”?
I little confusion that the state is “on” and “off” but i Z2M it is “contact”: true og false.
Thanks!
