Bon ben j’ai bien avancé, maintenant (grâce a toi) ça fonctionne impeccable, ci-dessous le code final utilisé :
Pour la carte :
type: custom:button-card
name: Porte Garage
label: |
[[[
if (states['timer.timergarage'].state === 'active') return 'Fermeture';
if (states['binary_sensor.porte_garage'].state === 'on') return 'Ouverte';
if (states['binary_sensor.porte_garage'].state === 'off') return 'Fermée';
return 'État inconnu';
]]]
show_label: true
custom_fields:
my_icon:
card:
type: custom:button-card
icon: |
[[[
if (states['timer.timergarage'].state === 'active') return 'mdi:window-shutter-cog';
if (states['binary_sensor.porte_garage'].state === 'on') return 'mdi:window-shutter-open';
if (states['binary_sensor.porte_garage'].state === 'off') return 'mdi:window-shutter';
return 'mdi:window-shutter-alert';
]]]
styles:
card:
- background-color: rgba(44,44,44,1)
- border-radius: 50%
- width: 40px
- height: 40px
- display: flex
- align-items: center
- justify-content: center
- pointer-events: none
- cursor: default
icon:
- color: |
[[[
if (states['timer.timergarage'].state === 'active') return 'orange';
if (states['binary_sensor.porte_garage'].state === 'on') return 'red';
if (states['binary_sensor.porte_garage'].state === 'off') return 'green';
return 'lightgray';
]]]
- animation: |
[[[
return states['timer.timergarage'].state === 'active' ? 'blink 1.5s infinite' : 'none';
]]]
- width: 25px
button_up:
card:
type: custom:button-card
icon: mdi:arrow-up
tap_action:
action: call-service
service: script.garage_ouverture
styles:
card:
- background-color: rgba(44,44,44,1)
- width: 95px
- height: 40px
- pointer-events: |
[[[
return states['binary_sensor.porte_garage'].state === 'off' ? 'auto' : 'none';
]]]
- cursor: |
[[[
return states['binary_sensor.porte_garage'].state === 'off' ? 'pointer' : 'default';
]]]
icon:
- color: |
[[[
return states['binary_sensor.porte_garage'].state === 'off' ? 'rgba(255,255,255,0.8)' : 'rgba(255,255,255,0.1)';
]]]
button_down:
card:
type: custom:button-card
icon: mdi:arrow-down
tap_action:
action: call-service
service: script.garage_fermeture
styles:
card:
- background-color: rgba(44,44,44,1)
- width: 95px
- height: 40px
- pointer-events: |
[[[
return states['binary_sensor.porte_garage'].state === 'on' ? 'auto' : 'none';
]]]
- cursor: |
[[[
return states['binary_sensor.porte_garage'].state === 'on' ? 'pointer' : 'default';
]]]
icon:
- color: |
[[[
return states['binary_sensor.porte_garage'].state === 'on' ? 'rgba(255,255,255,0.8)' : 'rgba(255,255,255,0.1)';
]]]
styles:
card:
- height: 120px
- width: 240px
- background-color: rgba(28, 28, 28, 1)
- border-radius: 12px
- box-shadow: none
- border: 1px solid rgba(44,44,44,1)
- pointer-events: |
[[[
return (['Ouverte', 'Fermée'].includes(states['input_select.etatportegarage'].state)) ? 'none' : 'auto';
]]]
- cursor: |
[[[
return (['Ouverte', 'Fermée'].includes(states['input_select.etatportegarage'].state)) ? 'default' : 'pointer';
]]]
grid:
- grid-template-areas: >-
"my_icon n" "my_icon l" "button_up button_down" "timer_status
timer_status"
- grid-template-columns: 60px auto
- grid-template-rows: 20px 40px 42px 42px
- align-items: flex-start
- padding-left: 10px
name:
- font-size: 14px
- font-weight: bold
- color: rgba(255,255,255,0.8)
- justify-self: start
- text-align: left
label:
- font-size: 12px
- color: |
[[[
const s = states['timer.timergarage'].state;
return s === 'active' ? 'orange' : 'rgba(255,255,255,0.8)';
]]]
- justify-self: start
- text-align: left
- margin-top: 4px
custom_fields:
button_up:
- position: absolute
- top: 68px
- left: 15px
button_down:
- position: absolute
- top: 68px
- right: 15px
script garage fermeture
sequence:
- action: timer.start
metadata: {}
data: {}
target:
entity_id: timer.timergarage
- action: input_select.select_option
metadata: {}
data:
option: Fermeture
target:
entity_id: input_select.etatportegarage
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.sonoff_100173bbc2
alias: garage_fermeture
description: ""
script garage ouverture
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.sonoff_100173bbc2
- action: input_select.select_option
metadata: {}
data:
option: Ouverte
target:
entity_id: input_select.etatportegarage
alias: garage_ouverture
description: ""
le timer garage
la liste déroulante etat porte garage
le résultat :
porte fermée
porte ouverte
porte en cours de fermeture (icone clignotante)
le seul point qui me reste a régler c’est comment aligner cette carte avec les autres…
je voudrais pouvoir la positionner a coté du volet cuisine.