Thanks do much to @dexstar
final code:
type: custom:button-card
show_entity_picture: true
state:
- value: 'off'
icon: mdi:garage-open
color: red
- value: 'on'
icon: mdi:garage-lock
color: green
tap_action:
action: toggle
entity: binary_sensor.shelly_shsw_1_e8db84d7180f_switch
show_state: false
show_label: true
size: 20%
label: |
[[[
if (states['binary_sensor.shelly_shsw_1_e8db84d7180f_switch'].state === "on")
return "closed";
else if (states['binary_sensor.shelly_shsw_1_e8db84d7180f_switch'].state === "off")
return "open";
]]]