Trash Card Highlight für Müll heute/morgen

Hallo. Ich möchte gerne in den Trash Cards, die heute oder morgen abgeholt werden mit einem Style hinterlegen um mehr Aufmerksamkeit drauf zu legen. Geht das?

Weiterhin möchte ich eine custom-button-card anzeigen, wen der Müll morgen abgeholt wird, kann mir da wer helfen?

Musst “musst” du wirklich alle Tonnen in 4 Tagen rauststellen? :slight_smile:

Ich habs so gelöst (ohne Trash HACS Card):

Du brauchst die Custom Button Card:

und die decluttering Card (optional)

Decluttering ist optional. Dann musst du aber die Variablen aus dem Code nehmen und wieder hard in den Quellcode schreiben. Bei mir verwende ich das an mehreren Stellen, daher decluttering.

Du brauchst einen Kalender mit deinen Terminen. Ob selbst erstellt oder importiert ist egal.

In die configuration.yaml:

Zusammenfassung
template:
  - triggers:
      - trigger: time_pattern
        hours: "/1"
      - trigger: homeassistant
        event: start
      - trigger: state
        entity_id: input_datetime.mullabfuhr_zeit_ausblenden
    actions:
      - action: calendar.get_events
        target:
          entity_id: calendar.mullkalender
        data:
          duration:
            days: 30
        response_variable: abfuhr
      - variables:
          rest: >
            {{ abfuhr['calendar.mullkalender'].events | selectattr('summary', 'eq', 'Restmüll') | list }}
          papier: >
            {{ abfuhr['calendar.mullkalender'].events | selectattr('summary', 'eq', 'Papiermüll') | list }}
          bio: >
            {{ abfuhr['calendar.mullkalender'].events | selectattr('summary', 'eq', 'Bio-Müll') | list }}
          wertstoff: >
            {{ abfuhr['calendar.mullkalender'].events | selectattr('summary', 'eq', 'Wertstoffmüll') | list }}
    sensor:
      # RESTMÜLL
      - name: "Abfuhr Restmüll"
        unique_id: abfuhr_restmuell
        icon: mdi:trash-can-outline
        state: >
          {% if rest | length > 0 %}
            {% set tage = ((as_timestamp(rest[0].start) - as_timestamp(today_at())) / 86400) | int %}
            {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
              {% if rest | length > 1 %}
                {{ ((as_timestamp(rest[1].start) - as_timestamp(today_at())) / 86400) | int }}
              {% else %}
                999
              {% endif %}
            {% else %}
              {{ tage }}
            {% endif %}
          {% else %}
            999
          {% endif %}
        attributes:
          datum: >
            {% if rest | length > 0 %}
              {% set tage = ((as_timestamp(rest[0].start) - as_timestamp(today_at())) / 86400) | int %}
              {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
                {% if rest | length > 1 %}
                  {{ as_timestamp(rest[1].start) | timestamp_custom('%d.%m.%Y', true) }}
                {% else %}
                  --
                {% endif %}
              {% else %}
                {{ as_timestamp(rest[0].start) | timestamp_custom('%d.%m.%Y', true) }}
              {% endif %}
            {% else %}
              --
            {% endif %}

      # PAPIERMÜLL
      - name: "Abfuhr Papiermüll"
        unique_id: abfuhr_papiermuell
        icon: mdi:newspaper
        state: >
          {% if papier | length > 0 %}
            {% set tage = ((as_timestamp(papier[0].start) - as_timestamp(today_at())) / 86400) | int %}
            {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
              {% if papier | length > 1 %}
                {{ ((as_timestamp(papier[1].start) - as_timestamp(today_at())) / 86400) | int }}
              {% else %}
                999
              {% endif %}
            {% else %}
              {{ tage }}
            {% endif %}
          {% else %}
            999
          {% endif %}
        attributes:
          datum: >
            {% if papier | length > 0 %}
              {% set tage = ((as_timestamp(papier[0].start) - as_timestamp(today_at())) / 86400) | int %}
              {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
                {% if papier | length > 1 %}
                  {{ as_timestamp(papier[1].start) | timestamp_custom('%d.%m.%Y', true) }}
                {% else %}
                  --
                {% endif %}
              {% else %}
                {{ as_timestamp(papier[0].start) | timestamp_custom('%d.%m.%Y', true) }}
              {% endif %}
            {% else %}
              --
            {% endif %}

      # BIO-MÜLL
      - name: "Abfuhr Bio-Müll"
        unique_id: abfuhr_biomuell
        icon: mdi:flower
        state: >
          {% if bio | length > 0 %}
            {% set tage = ((as_timestamp(bio[0].start) - as_timestamp(today_at())) / 86400) | int %}
            {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
              {% if bio | length > 1 %}
                {{ ((as_timestamp(bio[1].start) - as_timestamp(today_at())) / 86400) | int }}
              {% else %}
                999
              {% endif %}
            {% else %}
              {{ tage }}
            {% endif %}
          {% else %}
            999
          {% endif %}
        attributes:
          datum: >
            {% if bio | length > 0 %}
              {% set tage = ((as_timestamp(bio[0].start) - as_timestamp(today_at())) / 86400) | int %}
              {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
                {% if bio | length > 1 %}
                  {{ as_timestamp(bio[1].start) | timestamp_custom('%d.%m.%Y', true) }}
                {% else %}
                  --
                {% endif %}
              {% else %}
                {{ as_timestamp(bio[0].start) | timestamp_custom('%d.%m.%Y', true) }}
              {% endif %}
            {% else %}
              --
            {% endif %}

      # WERTSTOFFMÜLL
      - name: "Abfuhr Wertstoffmüll"
        unique_id: abfuhr_wertstoffmuell
        icon: mdi:recycle-variant
        state: >
          {% if wertstoff | length > 0 %}
            {% set tage = ((as_timestamp(wertstoff[0].start) - as_timestamp(today_at())) / 86400) | int %}
            {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
              {% if wertstoff | length > 1 %}
                {{ ((as_timestamp(wertstoff[1].start) - as_timestamp(today_at())) / 86400) | int }}
              {% else %}
                999
              {% endif %}
            {% else %}
              {{ tage }}
            {% endif %}
          {% else %}
            999
          {% endif %}
        attributes:
          datum: >
            {% if wertstoff | length > 0 %}
              {% set tage = ((as_timestamp(wertstoff[0].start) - as_timestamp(today_at())) / 86400) | int %}
              {% if tage == 0 and now().strftime('%H:%M:%S') >= states('input_datetime.mullabfuhr_zeit_ausblenden') %}
                {% if wertstoff | length > 1 %}
                  {{ as_timestamp(wertstoff[1].start) | timestamp_custom('%d.%m.%Y', true) }}
                {% else %}
                  --
                {% endif %}
              {% else %}
                {{ as_timestamp(wertstoff[0].start) | timestamp_custom('%d.%m.%Y', true) }}
              {% endif %}
            {% else %}
              --
            {% endif %}

Das kommt in den Raw Konfigurationseditor (Dashboard / Stift oben rechts / wieder oben rechts drei Punkte / Raw-Konfigurationseditor):

Zusammenfassung
decluttering_templates:
  muellAbfuhr:
    card:
      type: custom:button-card
      entity: "[[muellAbfuhr_entity]]"
      tap_action:
        action: none
      hold_action:
        action: none
      show_name: true
      show_icon: true
      show_label: true
      show_state: false
      name: "[[muellAbfuhr_name]]"
      label: |
        [[[ 
          if (entity.state == '0') return 'Heute';
          if (entity.state == '1') return 'Morgen';
          
          var datum = states['[[muellAbfuhr_entity]]'].attributes.datum;
          return 'In ' + entity.state + ' Tagen';
        ]]]
      styles:
        card:
          - background-color: |
              [[[
                if (parseInt(entity.state) <= '[[muellAbfuhr_daysForHighlight]]') return '[[muellAbfuhr_cardBackground]]';
                return 'rgba(27, 35, 54, 1)';
              ]]]
          - border-radius: 12px
          - padding: 8px
          - height: 100px
        grid:
          - grid-template-areas: "\"i\" \"n\" \"l\""
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr auto auto
        icon:
          - width: 35px
          - color: |
              [[[
                if (parseInt(entity.state) <= '[[muellAbfuhr_daysForHighlight]]') return '#fff';
                return '#929292';
              ]]]
        name:
          - color: |
              [[[
                if (parseInt(entity.state) <= '[[muellAbfuhr_daysForHighlight]]') return '[[muellAbfuhr_nameColor]]';
                return '#929292';
              ]]]
          - font-size: 13px
          - font-weight: 400
          - margin-top: 8px
        label:
          - color: |
              [[[
                if (parseInt(entity.state) <= '[[muellAbfuhr_daysForHighlight]]') return '[[muellAbfuhr_labelColor]]';
                return '#e1e1e1';
              ]]]
          - font-size: 11px
          - font-weight: 300
          - margin-top: 4px
        img_cell:
          - width: 50px
          - height: 50px
          - justify-content: center
          - border-radius: 14px
          - background-color: |
              [[[
                if (parseInt(entity.state) <= '[[muellAbfuhr_daysForHighlight]]') return 'rgba([[muellAbfuhr_imgCellBackgroundColor]],[[muellAbfuhr_imgCellBackgroundColorOpacity]])';
                return '#2f374a';
              ]]]

Das kommt dann ins Dashboard (Beispiel Bio-Müll) (declutteringcard):

Zusammenfassung
type: custom:decluttering-card
template: muellAbfuhr
variables:
  - muellAbfuhr_entity: sensor.abfuhr_bio_mull
  - muellAbfuhr_name: Bio-Müll
  - muellAbfuhr_daysForHighlight: 3
  - muellAbfuhr_cardBackground: "#4ab14f"
  - muellAbfuhr_nameColor: "#0a2f0c"
  - muellAbfuhr_labelColor: "#0a2f0c"
  - muellAbfuhr_imgCellBackgroundColor: 255, 255, 255
  - muellAbfuhr_imgCellBackgroundColorOpacity: "0.2"

Ohne Decluttering Card baust du dir die Button Card direkt ins Dashboard. Dort nimmst du den Code der in den Configurationseditor gehört. Die Variablen tauscht du dann gegen die Entitäten der Decluttering Dashboard Card aus.

Anzuzeigende Tage sind einstellbar. Farben usw sowieso. Es wird immer die Karte hell, deren Tonne als nächstes drann ist. Siehst du alles im Code.

Um die Belegung der Farbe aufzuheben prauchst du noch einen input-datetime Helfer. Da kannst du die Uhrzeit einstellen, ab der die Karte am Abholtag nicht mehr als relevant gehighlighted wird.

Da kannst du dir sicher was ableiten. Have Fun :slight_smile:

2 „Gefällt mir“

Okay danke. Das sieht ja mal sehr stark aus. Ich bekomme allerdings noch “In unknown Tagen“ bei der Card angezeigt.

In der configuration.yaml habe ich entity_id: calendar.mullkalender → entity_id: calendar.waste_collection_schedule_eaw_rheingau_taunus_kreis geändert. Ebenso abfuhr[‘calendar.mullkalender’].events → abfuhr[‘calendar.waste_collection_schedule_eaw_rheingau_taunus_kreis’].events …

Habe ich etwas übersehen? Den Helfer habe ich ebenfalls erstellt:

image

EDIT: Im Raw-Code habe ich bei Label auf entity.state getestet: Unknown

Woher kommen denn im Raw-Code die muellAbfuhr_entity und muellAbfuhr_name?

Ob deine Calender funktionieren weiß ich nicht, gehe ich aber von aus, wenn die Termine enthalten sind.

die Equals, also die Überstimmungen müssen natürlich auch passen. Wenn dein Eintrag bspw nicht Restmüll heißt, dann findet der natürlich nichts …

Der Helfer sollte so passen.

Die kommen aus der Dashboardkarte.

Im Raw-…Editor steht bespw:

decluttering_templates:
  muellAbfuhr:
    card:
      type: custom:button-card
      entity: "[[muellAbfuhr_entity]]"
      tap_action:
        action: none
      hold_action:
        action: none
      show_name: true
      show_icon: true
      show_label: true
      show_state: false
      name: "[[muellAbfuhr_name]]"

Das hier: [[muellAbfuhr_entity]] und das hier: [[muellAbfuhr_name]] sind Variablen der decluttering-Card. Die werden befüllt, aus der Dashboardkarte. Dafür setzt du die Decluttering-Card in dein Dashboard, dahin wo die Ausgabe erscheinen soll und befüllst nur noch die Variablen, so z.B. (für Bio Müll)

type: custom:decluttering-card
template: muellAbfuhr
variables:
  - muellAbfuhr_entity: sensor.abfuhr_bio_mull
  - muellAbfuhr_name: Bio-Müll
...

Durch das Script in deiner configuration.yaml sind dir auch 4 neue Entitäten angelegt worden.

sensor.abfuhr_bio_mull zum Beispiel. Die musst du dann in die Karte übernehmen.

Wenn du das alles nicht benötigst (geht ja auch ohne Decluttering Card), dann nimmst du alles aus dem Raw-…Editor wieder raus und packst das einfach in eine Custom Button Card in deinem Dashboard.

Die Variablen musst du dann aber rausnehmen und mit den echten Entitäten befüllen., zum Beispiel dann so:

type: custom:button-card
entity: sensor.abfuhr_bio_mull
tap_action:
  action: none
hold_action:
  action: none
show_name: true
show_icon: true
show_label: true
show_state: false
name: Bio-Müll
label: |
  [[[ 
    if (entity.state == '0') return 'Heute';
    if (entity.state == '1') return 'Morgen';
    
    var datum = states['sensor.abfuhr_bio_mull'].attributes.datum;
    return 'In ' + entity.state + ' Tagen';
  ]]]
styles:
  card:
    - background-color: |
        [[[
          if (parseInt(entity.state) <= '6') return '#4ab14f';
          return 'rgba(27, 35, 54, 1)';
        ]]]
    - border-radius: 12px
    - padding: 8px
    - height: 100px
  grid:
    - grid-template-areas: "\"i\" \"n\" \"l\""
    - grid-template-columns: 1fr
    - grid-template-rows: 1fr auto auto
  icon:
    - width: 35px
    - color: |
        [[[
          if (parseInt(entity.state) <= '6') return '#fff';
          return '#929292';
        ]]]
  name:
    - color: |
        [[[
          if (parseInt(entity.state) <= '6') return '#0a2f0c';
          return '#929292';
        ]]]
    - font-size: 13px
    - font-weight: 400
    - margin-top: 8px
  label:
    - color: |
        [[[
          if (parseInt(entity.state) <= '6') return '#0a2f0c';
          return '#e1e1e1';
        ]]]
    - font-size: 11px
    - font-weight: 300
    - margin-top: 4px
  img_cell:
    - width: 50px
    - height: 50px
    - justify-content: center
    - border-radius: 14px
    - background-color: |
        [[[
          if (parseInt(entity.state) <= '6') return 'rgba(255, 255, 255,0.2)';
          return '#2f374a';
        ]]]

1 „Gefällt mir“

Gerne möchte ich noch eine Text-Karte “muss muss … ;-)“ hinzufügen, wenn eines der Müll-Typen morgen abgeholt wird. Kannst du mir dabei noch helfen?

Ich würd da einfach ne Konditional Karte drum herum setzen.

Also alle vier Karten für die Abfuhrtermine in einen Querstapel.

Dann wählst du dir die Koditional Karte aus. Im Bereich Sichtbarkeit setzt du den jeweiligen Sensor auf unter 3. Das sollte bewirken dass nur eine Abfuhrkarte angezeigt wird, bzw je nachdem wie das bei dir vor Ort üblich ist.

Im Bereich Karte setzt du dann den jeweiligen Code für die Button Card rein… oder decluttering Card… je nachdem was du verwendest.

1 „Gefällt mir“

Danke damit ist alles geklärt. Durch dich habe ich wirklich viel gelernt. Vielen lieben Dank.

Sehr gerne. Schön das es funktioniert.