Je suis là, on va voir ce qu’on peut faire pour arranger ça
type: custom:button-card
aspect_ratio: 3/1
entity: button.portail
name: Portail
icon: |
[[[
if (states['binary_sensor.portail'].state == 'off')
return 'mdi:gate-open';
else if (states['binary_sensor.portail'].state == 'on')
return 'mdi:gate';
]]]
show_label: true
label: |
[[[
if (states['binary_sensor.portail'].state == 'off')
return '<font color= "red"><b>ouvert</font>';
else if (states['binary_sensor.portail'].state == 'on')
return '<font color= "green"><b>fermé</font>';
else
return '<font color= "orange"><b>en mouvement</font>';
]]]
styles:
name:
- font-size: 0.9em
- justify-self: middle
- align-self: end
- color: rgba(255,255,255,0.6)
card:
- background-color: rgba(64,64,64,0.8)
- box-shadow: 4px 4px 4px 0px rgba(32,32,32,0.5)
- border: 2px rgba(211,211,211,1.0) outset
icon:
- border-radius: 50%
- border: none
- box-shadow: 0px 0px 5px 5px rgba(0,128,0,0.5)
- box-shadow: |
[[[
if (states['binary_sensor.portail'].state == 'on')
return '0px 0px 5px 5px rgba(0,128,0,0.5)';
else if (states['binary_sensor.portail'].state == 'off')
return '0px 0px 5px 5px rgba(255,0,0,0.5)';
else
return '0px 0px 5px 5px rgba(255,140,0,0.5)';
]]]
- background-color: |
[[[
if (states['binary_sensor.portail'].state == 'on')
return '0px 0px 5px 5px rgba(0,128,0,0.5)';
else if (states['binary_sensor.portail'].state == 'off')
return '0px 0px 5px 5px rgba(255,0,0,0.5)';
else
return '0px 0px 5px 5px rgba(255,140,0,0.5)';
]]]
- width: 60px
- height: 60px
- color: |
[[[
if (states['binary_sensor.portail'].state == 'off')
return 'rgba(0,255,0,1.0)';
else if (states['binary_sensor.portail'].state == 'on')
return 'rgba(255,0,0,1.0)';
else
return 'rgba(255,140,0,1.0)';
]]]
tap_action:
action: Toggle
hold_action:
action: none
J’ai supprimé l’animation, l’erreur que tu avais doit être résolue. Colle le code ci-dessus à la place de ce que tu avais.
Tu ne m’as pas répondu sur l’état de ton capteur binaire.