Bonjour,
j’ai refais ma carte poubelle identique a Garbage card mais avec Button-card.
1er ligne avec Garbage card
2eme ligne avec Button-card
autre exemple:
Les sensors template ( j’ai ajouter des attributs date et jours ):
template:
- sensor:
- name: "poubelle_verte_jour"
state: >-
{% set delta = state_attr('calendar.poubelle_verte', 'start_time') | as_datetime | as_local - today_at() %}
{{ {0: "Aujourd'hui", 1: "Demain"}.get(delta.days, 'Dans ' ~ delta.days ~ ' Jours') }}
attributes:
date: >-
{{ as_timestamp(states.calendar.poubelle_verte.attributes.start_time) | timestamp_custom("%d/%m/%y", True) }}
jours: "{{((as_timestamp(states.calendar.poubelle_verte.attributes.start_time)- as_timestamp(now())) /86400+1) | int}}"
- name: "poubelle_jaune_jour"
state: >-
{% set delta = state_attr('calendar.poubelle_jaune', 'start_time') | as_datetime | as_local - today_at() %}
{{ {0: "Aujourd'hui", 1: "Demain"}.get(delta.days, 'Dans ' ~ delta.days ~ ' Jours') }}
attributes:
date: >-
{{ as_timestamp(states.calendar.poubelle_jaune.attributes.start_time) | timestamp_custom("%d/%m/%y", True) }}
jours: "{{((as_timestamp(states.calendar.poubelle_jaune.attributes.start_time)- as_timestamp(now())) /86400+1) | int}}"
Le code Button-card:
- 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;
]]]
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
- 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;
]]]
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
Pour l’icone fas:dumpster, j’utilise l’intégration hass-fontawesome a installer dans HACS.
A mon grand regret, désinstallation de Garbage Collection et Garbage Card