C’est peu être pas la meilleur façon, mais c’est fonctionnelle.
Code carte:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.poubelle_verte_jour
name: Poubelle Verte
icon: fas:dumpster
layout: icon_name_state2nd
show_state: true
size: 60%
custom_fields:
date: |
[[[
return 'Le ' + states['sensor.poubelle_verte_jour'].attributes.date;
]]]
statut: |
[[[
return '- ' + states['input_text.poubelle_verte_statut'].state;
]]]
state:
- value: Dans 7 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 6 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 5 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 4 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 3 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 2 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Demain
operator: '=='
color: orange
icon: mdi:delete-restore
styles:
state:
- color: orange
- value: Aujourd'hui
operator: '=='
color: red
icon: mdi:delete-restore
styles:
state:
- color: red
styles:
icon:
- margin-left: 32px
name:
- margin-left: 6px
- justify-self: start
- font-size: 15px
state:
- font-weight: bold
- margin-left: 6px
- justify-self: start
- font-size: 12px
custom_fields:
date:
- top: 73%
- left: 43%
- position: absolute
- color: white
- font-size: 12px
statut:
- top: 73%
- left: 72%
- position: absolute
- color: white
- font-size: 12px
hold_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: input_text.poubelle_verte_statut
value: Vider
card_mod:
style: |
ha-card {
margin-top: -8px;
}
- type: custom:button-card
entity: sensor.poubelle_jaune_jour
name: Poubelle Jaune
icon: fas:dumpster
layout: icon_name_state2nd
show_state: true
size: 60%
custom_fields:
date: |
[[[
return 'Le ' + states['sensor.poubelle_jaune_jour'].attributes.date;
]]]
statut: |
[[[
return '- ' + states['input_text.poubelle_jaune_statut'].state;
]]]
state:
- value: Dans 7 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 6 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 5 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 4 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 3 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 2 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Demain
operator: '=='
color: orange
icon: mdi:delete-restore
styles:
state:
- color: orange
- value: Aujourd'hui
operator: '=='
color: red
icon: mdi:delete-restore
styles:
state:
- color: red
styles:
icon:
- margin-left: 32px
name:
- margin-left: 6px
- justify-self: start
- font-size: 15px
state:
- font-weight: bold
- margin-left: 6px
- justify-self: start
- font-size: 12px
custom_fields:
date:
- top: 73%
- left: 43%
- position: absolute
- color: white
- font-size: 12px
statut:
- top: 73%
- left: 72%
- position: absolute
- color: white
- font-size: 12px
hold_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: input_text.poubelle_jaune_statut
value: Vider
card_mod:
style: |
ha-card {
margin-top: -8px;
}
Créer deux input text.
- input_text.poubelle_verte_statut
- input_text.poubelle_jaune_statut
Une automatisation, qui reset le statut au jours 7:
alias: Poubelle Statut
description: ""
trigger:
- platform: state
entity_id:
- sensor.poubelle_verte_jour
to: Dans 7 Jours
id: verte
- platform: state
entity_id:
- sensor.poubelle_jaune_jour
to: Dans 7 Jours
id: jaune
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: verte
sequence:
- service: input_text.set_value
data:
value: A vider
target:
entity_id: input_text.poubelle_verte_statut
- conditions:
- condition: trigger
id: jaune
sequence:
- service: input_text.set_value
data:
value: A vider
target:
entity_id: input_text.poubelle_jaune_statut
mode: single
Pour le fonctionnement, quand ta vider la poubelle, tu fais un appuie long sur le button et ca passe en Vider
. Quand le statut repasse a Dans 7 jours, ca change le statut en A vider
.
Je verrais pour améliorer , peu être avec des icones pour le statut au lieu du texte. a réfléchir.
Edit:
Version avec icone en statut.
code:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: sensor.poubelle_verte_jour
name: Poubelle Verte
icon: fas:dumpster
layout: icon_name_state2nd
show_state: true
size: 60%
custom_fields:
date: |
[[[
return 'Le ' + states['sensor.poubelle_verte_jour'].attributes.date;
]]]
statut: >
[[[ if (states['input_text.poubelle_verte_statut'].state == "Vider")
return '<ha-icon icon="mdi:delete" style="width: 30px; height: 30px;
color: green;"></ha-icon>';
else return '<ha-icon icon="mdi:delete-alert" style="width: 30px;
height: 30px; color: red"></ha-icon>' ]]]
state:
- value: Dans 7 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 6 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 5 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 4 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 3 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Dans 2 Jours
operator: '=='
color: green
styles:
state:
- color: green
- value: Demain
operator: '=='
color: orange
icon: mdi:delete-restore
styles:
state:
- color: orange
- value: Aujourd'hui
operator: '=='
color: red
icon: mdi:delete-restore
styles:
state:
- color: red
styles:
icon:
- margin-left: 32px
name:
- margin-left: 6px
- justify-self: start
- font-size: 15px
state:
- font-weight: bold
- margin-left: 6px
- justify-self: start
- font-size: 12px
custom_fields:
date:
- top: 73%
- left: 43%
- position: absolute
- color: white
- font-size: 12px
statut:
- top: 50%
- left: 78%
- position: absolute
- color: white
- font-size: 12px
hold_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: input_text.poubelle_verte_statut
value: Vider
card_mod:
style: |
ha-card {
margin-top: -8px;
}
- type: custom:button-card
entity: sensor.poubelle_jaune_jour
name: Poubelle Jaune
icon: fas:dumpster
layout: icon_name_state2nd
show_state: true
size: 60%
custom_fields:
date: |
[[[
return 'Le ' + states['sensor.poubelle_jaune_jour'].attributes.date;
]]]
statut: >
[[[ if (states['input_text.poubelle_jaune_statut'].state == "Vider")
return '<ha-icon icon="mdi:delete" style="width: 30px; height: 30px;
color: green;"></ha-icon>';
else return '<ha-icon icon="mdi:delete-alert" style="width: 30px;
height: 30px; color: red"></ha-icon>' ]]]
state:
- value: Dans 7 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 6 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 5 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 4 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 3 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Dans 2 Jours
operator: '=='
color: yellow
styles:
state:
- color: yellow
- value: Demain
operator: '=='
color: orange
icon: mdi:delete-restore
styles:
state:
- color: orange
- value: Aujourd'hui
operator: '=='
color: red
icon: mdi:delete-restore
styles:
state:
- color: red
styles:
icon:
- margin-left: 32px
name:
- margin-left: 6px
- justify-self: start
- font-size: 15px
state:
- font-weight: bold
- margin-left: 6px
- justify-self: start
- font-size: 12px
custom_fields:
date:
- top: 73%
- left: 43%
- position: absolute
- color: white
- font-size: 12px
statut:
- top: 50%
- left: 78%
- position: absolute
- color: white
- font-size: 12px
hold_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: input_text.poubelle_jaune_statut
value: Vider
card_mod:
style: |
ha-card {
margin-top: -8px;
}