Garbage pickup date (mijnafvalwijzer.nl) custom_component

The config below or sort of would be nice to have…

Hi there,

this is what I have working right now (thanks to @smarthomejunkie) .

Stil three issue I don’t get managed;

1: Vandaag (Today) should show “Restafval” and “Papier”. Somehow the sensor “sensor.afvalwijzer_today_formatted” does not give the right value hence “Restafval” and “Papier”. My waste provider is RD4.
2: Where can I modify the date format from “01-08-2023” to “01-08” ?
3: The two big images in the middle not seem to fit! How can I edit this.

Hope you can help me out here. Keep on going the great work here!!!

Greetz Herman

Hi guys,

Im trying to get this sensor to work, however without succes. This config should be enough right? My code below doesn’t generate the sensors.

 sensor:
   - platform: afvalwijzer
     provider: mijnafvalwijzer 
     postal_code: 1234XX             
     street_number: 20

Mine has stopped last update of HA

HA 2023.8.3
supervisor 2023.8.1
OS 10.5
Front latest

It did work till this update now there is no afvalwijzer snsor working anymore.

Any one any Ideas?

Reinstall/reboot HA solved it.

Since the Afvalwijzer app has been broken for weeks now, I figured I’d try to use this integration to replace its notifications.
I didn’t need anything else from it, just the notifications.
This is what I ended up with, seems to be working great on manual triggers so far, I assume it’ll also work on auto-triggers.

alias: Notify Trash Pickup
description: Notify Trash Pickup
trigger:
  - platform: state
    entity_id: sensor.afvalwijzer_next_in_days
    to: "1"
condition: []
action:
  - service: notify.mobile_app_op8
    data:
      message: >-
        Tomorrow is the {{ states('sensor.afvalwijzer_next_type') }} trash
        pickup.

        Upcoming collections: {% set collections = [
          ('Plastic', state_attr('sensor.afvalwijzer_plastic', 'days_until_collection_date'), state_attr('sensor.afvalwijzer_plastic', 'year_month_day_date')),
          ('GFT', state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date'), state_attr('sensor.afvalwijzer_gft', 'year_month_day_date')),
          ('Papier', state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date'), state_attr('sensor.afvalwijzer_papier', 'year_month_day_date')),
          ('Restafval', state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date'), state_attr('sensor.afvalwijzer_restafval', 'year_month_day_date'))
        ] %} {% for item in collections|sort(attribute=1) %}

        - {{ item[0] }}: in {{ item[1] }} {{ 'day' if item[1] == 1 else 'days'
        }} ({{ as_timestamp(item[2]) | timestamp_custom('%A, %d-%m') }}) {%
        endfor %}
mode: single

This leverages the Home Assistant app for a specific device (“op8” in my case), and sends a push notification:

It’s a bit rough around the edges, but might help someone else looking for a similar solution out.

?
My setup hasn’t given a blink in years now and still looks good as I designed it:

dashboard once again (and sorry for the long lines in the Markdown, its always a pain to format nicely:

type: custom:mod-card
card_mod:
  style: |
    :host {
      --stack-card-margin: 0px;
    }
card:
  type: vertical-stack
  cards:

    - type: custom:button-card
      name: Ophaaldata
      template: button_default_title
      hold_action:
        action: navigate
        navigation_path: >
          [[[ return window.location.pathname.split('/')[2] == 'kalender'
              ? '/ui-data/summary' : null; ]]]

    - type: custom:hui-element
      card_type: markdown
      card_mod:
        style: |
           ha-card.type-markdown {
             box-shadow: none;
           }
      content: >
        <font color={{states('sensor.trash_color')}}><ha-icon icon= {{'mdi:delete-alert' if states('sensor.afvalwijzer_vandaag') != 'geen' else 'mdi:delete-outline'}}> </ha-icon></font> Vandaag, {{states('sensor.vandaag')}}: <font color= {{states('sensor.trash_color')}}>**{{states('sensor.afvalwijzer_vandaag')|capitalize}}</font>**

        <font color={{states('sensor.trash_next_color')}}><ha-icon icon= {{states('sensor.trash_next_icon')}}> </ha-icon></font> Volgende afval-ophaal over **<font color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_in_days')}}</font>** {{'dag' if states('sensor.afvalwijzer_next_in_days') == '1' else 'dagen'}} op:

        <ha-icon icon= 'mdi:delete-alert'> </ha-icon> {{states('sensor.volgende_afval_ophaal_dag')}}: **<font color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_type')|capitalize}}</font>**

    - type: horizontal-stack
      cards:
        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('input_boolean.afval_vandaag_notificatie','on')
                             and states('sensor.afvalwijzer_vandaag') != 'geen' -%}
                           blink 2s linear infinite;
                           {% else -%} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_vandaag
          name: Vandaag
          show_state: false
          state_image: &state_image
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            plastic: /local/afvalwijzer/plastic.png
            geen: /local/afvalwijzer/kliko_geen.png
            unknown: /local/afvalwijzer/kliko_geen.png

        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('input_boolean.afval_morgen_notificatie','on')
                              and states('sensor.afvalwijzer_morgen') != 'geen' -%}
                            blink 2s linear infinite;
                           {% else -%} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_morgen
          name: Morgen
          show_state: false
          state_image: *state_image

        - type: picture-entity
          entity: sensor.afvalwijzer_overmorgen
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
              }
          name: Overmorgen
          show_state: false
          state_image: *state_image

    - type: custom:auto-entities
      card:
        type: entities
      filter:
        exclude:
          - entity_id: sensor.afvalwijzer*next*
          - entity_id: sensor.afvalwijzer_*orgen
          - entity_id: sensor.afvalwijzer_v*
        include:
          - entity_id: sensor.afvalwijzer_*
            options:
              type: custom:template-entity-row
              image: >
                {% set type = config.entity.split('afvalwijzer_')[1] %}
                /local/afvalwijzer/{{type}}.png
              state: >
                {% set trash = config.entity %}
                {% set today = state_attr(trash,'is_collection_date_today') %}
                {% set future = state_attr(trash,'days_until_collection_date') %}
                {% if future is none or
                   (is_state(trash,'geen') and future == 0) %} Tba
                {% else %}
                {{as_timestamp(strptime(states(trash),'%d-%m-%Y'))
                                |timestamp_custom('%-d %b')}}
                {% endif %}
              secondary: >
                {% set trash = config.entity %}
                {% set today = state_attr(trash,'is_collection_date_today') %}
                {% set future = state_attr(trash,'days_until_collection_date') %}
                {% if future is none or
                   (is_state(trash,'geen') and future == 0) %} Nog niet gepubliceerd
                {% else %}
                  {% set count =
                    state_attr(trash,'days_until_collection_date')|int(default=0) %}
                  {% set dagnummer = as_timestamp(strptime(states(trash),'%d-%m-%Y'))
                     |timestamp_custom('%w')|int(default=0) %}
                  {% set dagen =
                    ['Zondag','Maandag', 'Dinsdag', 'Woensdag','Donderdag','Vrijdag',
                     'Zaterdag'] %}
                  {% set dag = dagen[dagnummer] %}
                  {% set unit = 'dag' if count == 1 else 'dagen' %}

                  {% if count >= 28 %} {% set phrase = dag + ' over 4 weken' %}
                  {% elif count >= 21 %} {% set phrase = dag + ' over 3 weken' %}
                  {% elif count >= 14 %} {% set phrase = dag + ' over 2 weken' %}
                  {% elif count >= 7 %} {% set phrase = 'Volgende week ' + dag %}
                  {% elif count >= 3 %} {% set phrase = 'komende ' + dag %}
                  {% elif count == 2 %} {% set phrase = dag + ', overmorgen' %}
                  {% elif count == 1 %} {% set phrase = 'morgen, ' + dag %}
                  {% else %} {% set phrase = 'Vandaag, ' + dag %}
                  {% endif %}
                  {{phrase}} {% if count != 0 %} ({{count}} {{unit}}) {% endif %}
                {% endif %}
      sort:
        method: attribute
        attribute: days_until_collection_date
        numeric: true

      entities:
        - type: custom:fold-entity-row
          head:
            type: section
            label: Automaten
            card_mod:
              style: |
                .label {
                  margin-left: 0px;
                }
          group_config:
            state_color: true
            secondary_info: last-triggered
          padding: 0
          entities:
            - entity: input_boolean.afval_reminder
              secondary_info: last-changed
            - entity: input_boolean.afval_staat_voor
              secondary_info: last-changed
            - type: divider
            - entity: automation.afval_vandaag
              name: Notify vandaag
            - entity: automation.afval_morgen
              name: Notify morgen
            - entity: automation.saver_offline
            - entity: automation.reset_trash_notification
            - entity: automation.mark_trash_as_moved_outside_from_notification

backend package:

##########################################################################################
## AfvalWijzer Custom Component
## created by @xirixiz, more info on https://github.com/xirixiz/home-assistant-config
## https://community.home-assistant.io/t/garbage-pickup-date-mijnafvalwijzer-nl-custom-component/34631
# @mariusthvdb
##########################################################################################

##########################################################################################
# Customize
##########################################################################################

homeassistant:

  customize:

    sensor.afvalwijzer_vandaag: &afval
      hide_attributes: templates
      templates:
        entity_picture: >
          var path = '/local/afvalwijzer/';
          var ext = '.png';
          var type = ['papier','gft','plastic','restafval'];
          return type.includes(state) ? path + state + ext : path + 'kliko_geen' + ext;

    sensor.afvalwijzer_morgen: *afval

    sensor.afvalwijzer_overmorgen: *afval

# niet in frontend
#    sensor.afvalwijzer_next_in_days:
#      hide_attributes: templates
#      templates:
#        icon: >
#          if (state === 'Geen') return 'mdi:calendar-question';
#          var items = ['1','2','3','4','5','6','7','8','9'];
#          if (items.includes(state))
#            return 'mdi:numeric-' + state + '-box-multiple-outline';
#          return 'mdi:help';

##########################################################################################
# Sensors
##########################################################################################

sensor:

  - platform: afvalwijzer
    provider: mijnafvalwijzer
    postal_code: !secret postcode
    street_number: !secret huisnummer

##########################################################################################
# Templates
##########################################################################################

template:

  - trigger:

      - platform: homeassistant
        event: start

      - platform: time_pattern
        hours: '/1'

    sensor:

      - unique_id: trash_alert
        state: >-
          {% if has_value('sensor.afvalwijzer_morgen') or
                has_value('sensor.afvalwijzer_vandaag') %}
            {%- if states('sensor.afvalwijzer_morgen') != 'geen' and
                states('input_boolean.afval_morgen_notificatie') == 'on'%}
              Afval: {{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald
            {%- elif states('sensor.afvalwijzer_vandaag') != 'geen'%}
              Afval: {{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald
            {%- else -%} Geen afval alert
            {%- endif -%}
          {% else %} Geen sensors gemaakt
          {% endif %}

      - unique_id: trash_next_icon
        state: >
          {% set days = states('sensor.afvalwijzer_next_in_days') %}
          {% if days != 'geen' %}
            {% if days|int <= 9 %} mdi:numeric-{{days}}-box-multiple-outline
            {% else %} mdi:numeric-9-plus-box-multiple-outline
            {% endif%}
          {% else %} mdi:checkbox-blank-outline
          {% endif %}

      - unique_id: trash_next_color
        state: >
          {% set next = states('sensor.afvalwijzer_next_type') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                           'plastic':'orange','restafval':'black'} %}
          {{colors.get(next,'grey')}}

      - unique_id: trash_color
        state: >
          {% set vandaag = states('sensor.afvalwijzer_vandaag') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                           'plastic':'orange','restafval':'black'} %}
          {{colors.get(vandaag,'grey')}}

      - unique_id: volgende_afval_ophaal_dag
        state: >
          {%- set next = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),
                         '%d-%m-%Y',none),none) %}
          {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                            'Augustus','September','Oktober','November','December'] %}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                           'Vrijdag','Zaterdag'] %}
          {%- set wday = next|timestamp_custom('%w',default=none)|int(default=0) %}
          {%- set month = next|timestamp_custom('%m',default=none)|int(default=0) %}
          {{next|timestamp_custom(wdays[wday] ~ ' %-d ' ~ months[month-1],default=none)}}

  - binary_sensor:

      - unique_id: afval_notificatie
        state: >
          {{is_state('input_boolean.afval_vandaag_notificatie','on') or
            is_state('input_boolean.afval_morgen_notificatie','on')}}

      - unique_id: saver_offline
        state: >
          {{states.sensor.afvalwijzer_vandaag is none}}
        device_class: problem

##########################################################################################
# Scripts
##########################################################################################

script:

  notify_trash_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.notify_utility
        state: 'on'
      - service: notify.notify
        data:
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
          message: >
            {{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!

  persistent_trash_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.persistent_notification_create
        state: 'on'
      - service: persistent_notification.create
        data:
          notification_id: afval_vandaag_notificatie
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
          message: >
            {{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_vandaag_notificatie

  notify_trash_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.notify_utility
        state: 'on'
      - service: notify.notify
        data:
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
          message: >
            {{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!

  persistent_trash_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.persistent_notification_create
        state: 'on'
      - service: persistent_notification.create
        data:
          notification_id: afval_morgen_notificatie
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
          message: >
            {{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_morgen_notificatie

  trash_outside_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.afval_staat_voor
        state: 'off'
      - condition: state
        entity_id: input_boolean.afval_reminder
        state: 'on'
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: >
            {% set title = states('sensor.afvalwijzer_morgen')|title %}
            {{title}} wordt morgen opgehaald, zet het afval aan de straat
          data:
            actions:
              - action: MARK_TRASH_MOVED
                title: Afval verwerkt
                destructive: true
            push:
              badge: 5
              sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav

  trash_outside_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.afval_staat_voor
        state: 'off'
      - condition: state
        entity_id: input_boolean.afval_reminder
        state: 'on'
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: >
            {% set title = states('sensor.afvalwijzer_vandaag')|title %}
            {{title}} wordt vandaag opgehaald, zet het afval aan de straat
          data:
            actions:
              - action: MARK_TRASH_MOVED
                title: Afval verwerkt
                destructive: true
            push:
              badge: 5
              sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav
            action_data:
              entity_id: input_boolean.afval_staat_voor

##########################################################################################
# Automations
##########################################################################################

automation:

  - id: saver_offline
    trigger:
      platform: state
      entity_id: binary_sensor.saver_offline
      to: 'on'
    action:
      - service: persistent_notification.create
        data:
          notification_id: saver_notificatie
          title: Saver melding
          message: >
            {{now().strftime('%d %B')}}: Saver is Offline
      - service: script.intercom_message
        data:
          message_nl: >
            Het is {{states('sensor.vandaag').split('dag ')[1]}}:
            Saver is Offline, geen data voor Home Assistant
          message_en: >
            Today is {{now().strftime('%A %-d %B')}}:
            Saver is Offline and experiencing issues, no data provided to Home Assistant

##########################################################################################
# Vandaag moet het afval worden voorgezet
##########################################################################################

  - id: afval_vandaag
    trigger:
      platform: time
      at: '07:00'
    condition:
      - >
        {{has_value('sensor.afvalwijzer_vandaag')}}
      - not:
          condition: state
          entity_id: sensor.afvalwijzer_vandaag
          state: geen
    action:
      - service: script.intercom_message
        data:
          message_nl: >
            {% set vandaag = states('sensor.afvalwijzer_vandaag') %}
            {{states('sensor.vandaag').split('dag ')[1]}}: vandaag wordt {{vandaag}} opgehaald!
          message_en: >
            {% set today = states('sensor.afvalwijzer_vandaag') %}
            {{now().strftime('%A %-d %B')}}: today {{today}} will be collected!
      - service: script.persistent_trash_today
      - service: script.trash_outside_today

##########################################################################################
# Morgen moet het afval worden voorgezet
##########################################################################################

  - id: afval_morgen
    trigger:
      platform: time
      at: '21:00'
    condition:
      - >
        {{has_value('sensor.afvalwijzer_morgen')}}
      - not:
          condition: state
          entity_id: sensor.afvalwijzer_morgen
          state: geen
    action:
      - service: script.intercom_message
        data:
          message_nl: >
            Het is {{states('sensor.vandaag').split('dag ')[1]}}: Morgen wordt
            {{states('sensor.afvalwijzer_morgen')|title}} opgehaald!
          message_en: >
            Today is {{now().strftime('%d %B')}}: Tomorrow
            {{states('sensor.afvalwijzer_morgen')|title}} will be picked up!
      - service: script.persistent_trash_tomorrow
      - service: script.trash_outside_tomorrow

  - id: reset_trash_notification
    trigger:
      platform: state
      entity_id: input_boolean.afval_staat_voor
      to: 'on'
      for:
        hours: 5
    action:
      service: input_boolean.turn_off
      target:
        entity_id: input_boolean.afval_staat_voor

  - id: reset_trash_notification_today
    trigger:
      platform: state
      entity_id: sensor.afvalwijzer_vandaag
      to: geen
    condition:
      condition: state
      entity_id: input_boolean.afval_vandaag_notificatie
      state: 'on'
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: afval_vandaag_notificatie
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.afval_vandaag_notificatie

  - id: reset_trash_notification_tomorrow
    trigger:
      platform: state
      entity_id: sensor.afvalwijzer_morgen
      to: geen
    condition:
      condition: state
      entity_id: input_boolean.afval_morgen_notificatie
      state: 'on'
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: afval_morgen_notificatie
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.afval_morgen_notificatie

  - id: dismiss_afval_notificatie
    trigger:
      - platform: persistent_notification
        update_type: removed
        notification_id: afval_vandaag_notificatie
      - platform: persistent_notification
        update_type: removed
        notification_id: afval_morgen_notificatie
    condition:
      or:
        - condition: state
          entity_id: input_boolean.afval_vandaag_notificatie
          state: 'on'
        - condition: state
          entity_id: input_boolean.afval_morgen_notificatie
          state: 'on'
    action:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_staat_voor
      - service: input_boolean.turn_off
        data:
          entity_id: >
            input_boolean.{{trigger.notification.notification_id}}
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: Afval staat aan de straat
          data:
            push:
              badge: 0
              sound: >
                US-EN-Morgan-Freeman-Good-{{(states('sensor.part_of_day')
                in ['Morning','Afternoon'])|iif('Morning','Night')}}.wav

  - id: mark_trash_as_moved_outside_from_notification
    trigger:
      platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: MARK_TRASH_MOVED
    action:
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_staat_voor
      - service: persistent_notification.dismiss
        data:
          notification_id: >
            afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')
              |iif('vandaag','morgen')}}_notificatie
      - service: input_boolean.turn_off
        data:
          entity_id: >
            input_boolean.afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')
                |iif('vandaag','morgen')}}_notificatie
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: Afval staat aan de straat
          data:
            push:
              badge: 0
              sound: >
                US-EN-Morgan-Freeman-Good-{{(states('sensor.part_of_day')
                in ['Morning','Afternoon'])|iif('Morning','Night')}}.wav
1 Like

I was talking about the official Afvalwijzer app on the play store, not yours. The official Afvalwijzer app has been refusing to send notifications across multiple independent devices/addresses, so I took to HASS and this integration as a replacement.
Nothing’s wrong with this integration as far as I’ve seen.

o right, sorry for any misunderstanding.
fwiw, the official app on the iPhone is working effortlessly also, and does send me notifications on the configured times in advance.
Maybe a platform issue?

Not unlikely, however that doesn’t make it less problematic for us Android users :sweat_smile:

1 Like

Somehow this isn’t just a copy/paste action.
It keeps giving me error’s like this:

Notifcatie: Afvalwijzer ophaal melding: Error executing script. Error for call_service at pos 1: Error rendering data template: TypeError: ‘<’ not supported between instances of ‘int’ and ‘NoneType’

Error while executing automation automation.notifcatie_afvalwijzer_ophaal_melding: Error rendering data template: TypeError: ‘<’ not supported between instances of ‘int’ and ‘NoneType’

yeah I just renamed them :wink:

Hi @Mariusthvdb,

Firstly, I want to commend your excellent coding skills!

I’ve tried to make it work myself following your scripts, but since I’m not a coding expert, I’m having some trouble figuring out where to insert which pieces of code.

Could you please give me some additional guidance on where to place specific parts of the code? If possible, could you point me to the YAML files where you’ve added the correct code?

Your help would be greatly appreciated!

Best regards,
Herman F.

sure, but what have you done yourself now? Where did you endup?

I have all of the backend code in a package, and the frontend code is all up to you ho you organize it. I use yaml mode so that makes it a lot easier moving code around :wink:

take a step back, and start at the beginning: what do you have so far.

Hi @Mariusthvdb,

Thank you for the quick responses. I’ve tried to incorporate your code into the correct YAML files. I assume this is also the intention? Below, you can see everything I’ve managed to put together so far.

Somehow, I can’t find the sensor “sensor.today” anymore. In the map, you can see this as “Today, unknown: Gft, paper.”

As you can see on the card, there are 2 types of waste being collected on September 26th, namely “GFT and Paper.” I haven’t been able to split the image into two parts for this either. I saw in the community that it’s possible, but I wasn’t able to find the “How To” guide. Perhaps you have a solution for this?

It’s a lot. I hope that you’re willing and able to help me further. After all, I also want to learn from it. Just keep in mind that coding is not my strongest skill. :wink:

The Card (so far)

Somehow the “sensor.today” is not showing up anymore.

Code of the card

type: custom:mod-card
card_mod:
  style: |
    :host {
      --stack-card-margin: 0px;
    }
card:
  type: vertical-stack
  cards:
    - type: custom:button-card
      name: Afvalwijzer
      template: null
      hold_action:
        action: navigate
        navigation_path: |
          [[[ return window.location.pathname.split('/')[2] == 'kalender'
              ? '/ui-data/summary' : null; ]]]
      styles:
        card:
          - background-color: var(--background-color-off)
          - color: Darkgreen
          - font-size: 20px
          - font-weight: Bold
          - padding: 12px
        name:
          - justify-self: left
    - type: custom:hui-element
      card_type: markdown
      card_mod:
        style: |
          ha-card.type-markdown {
            box-shadow: none;
          }
      content: >
        <font color={{states('sensor.trash_color')}}><ha-icon icon=
        {{'mdi:delete-alert' if states('sensor.afvalwijzer_today') != 'geen'
        else 'mdi:delete-outline'}}> </ha-icon></font> Vandaag,
        {{states('sensor.today')}}: <font color=
        {{states('sensor.trash_color')}}>**{{states('sensor.afvalwijzer_today')|capitalize}}</font>**

        <font color={{states('sensor.trash_next_color')}}><ha-icon icon=
        {{states('sensor.trash_next_icon')}}> </ha-icon></font> Volgende
        afval-ophaal over **<font
        color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_in_days')}}</font>**
        {{'dag' if states('sensor.afvalwijzer_next_in_days') == '1' else
        'dagen'}} op:

        <ha-icon icon= 'mdi:delete-alert'> </ha-icon>
        {{states('sensor.afvalwijzer_next_date')}}: **<font
        color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_type')|capitalize}}</font>**
    - type: horizontal-stack
      cards:
        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('input_boolean.afval_vandaag_notificatie','on')
                             and states('sensor.afvalwijzer_today') != 'geen' -%}
                           blink 2s linear infinite;
                           {% else -%} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_today
          name: Vandaag
          show_state: false
          state_image:
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            plastic: /local/afvalwijzer/plastic.png
            geen: /local/afvalwijzer/geen.png
            unknown: /local/afvalwijzer/geen.png
        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('input_boolean.afval_morgen_notificatie','on')
                              and states('sensor.afvalwijzer_morgen') != 'geen' -%}
                            blink 2s linear infinite;
                           {% else -%} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_tomorrow
          name: Morgen
          show_state: false
          state_image:
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            plastic: /local/afvalwijzer/plastic.png
            geen: /local/afvalwijzer/geen.png
            unknown: /local/afvalwijzer/geen.png
        - type: picture-entity
          entity: sensor.afvalwijzer_day_after_tomorrow
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
              }
          name: Overmorgen
          show_state: false
          state_image:
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            plastic: /local/afvalwijzer/plastic.png
            geen: /local/afvalwijzer/geen.png
            unknown: /local/afvalwijzer/geen.png
    - type: custom:auto-entities
      card:
        type: entities
      filter:
        exclude:
          - entity_id: sensor.afvalwijzer*next*
          - entity_id: sensor.afvalwijzer*to*
          - entity_id: sensor.afvalwijzer*until*
        include:
          - entity_id: sensor.afvalwijzer_*
            options:
              type: custom:template-entity-row
              image: >
                {% set type = config.entity.split('afvalwijzer_')[1] %}
                /local/afvalwijzer/{{type}}.png
              state: >
                {% set trash = config.entity %} {% set today =
                state_attr(trash,'is_collection_date_today') %} {% set future =
                state_attr(trash,'days_until_collection_date') %} {% if future
                is none or
                   (is_state(trash,'geen') and future == 0) %} Tba
                {% else %} {{as_timestamp(strptime(states(trash),'%d-%m-%Y'))
                                |timestamp_custom('%-d %b')}}
                {% endif %}
              secondary: >
                {% set trash = config.entity %} {% set today =
                state_attr(trash,'is_collection_date_today') %} {% set future =
                state_attr(trash,'days_until_collection_date') %} {% if future
                is none or
                   (is_state(trash,'geen') and future == 0) %} Nog niet gepubliceerd
                {% else %}
                  {% set count =
                    state_attr(trash,'days_until_collection_date')|int(default=0) %}
                  {% set dagnummer = as_timestamp(strptime(states(trash),'%d-%m-%Y'))
                     |timestamp_custom('%w')|int(default=0) %}
                  {% set dagen =
                    ['Zondag','Maandag', 'Dinsdag', 'Woensdag','Donderdag','Vrijdag',
                     'Zaterdag'] %}
                  {% set dag = dagen[dagnummer] %}
                  {% set unit = 'dag' if count == 1 else 'dagen' %}

                  {% if count >= 28 %} {% set phrase = dag + ' over 4 weken' %}
                  {% elif count >= 21 %} {% set phrase = dag + ' over 3 weken' %}
                  {% elif count >= 14 %} {% set phrase = dag + ' over 2 weken' %}
                  {% elif count >= 7 %} {% set phrase = 'Volgende week ' + dag %}
                  {% elif count >= 3 %} {% set phrase = 'komende ' + dag %}
                  {% elif count == 2 %} {% set phrase = dag + ', overmorgen' %}
                  {% elif count == 1 %} {% set phrase = 'morgen, ' + dag %}
                  {% else %} {% set phrase = 'Vandaag, ' + dag %}
                  {% endif %}
                  {{phrase}} {% if count != 0 %} ({{count}} {{unit}}) {% endif %}
                {% endif %}
      sort:
        method: attribute
        attribute: days_until_collection_date
        numeric: true
      entities:
        - type: custom:fold-entity-row
          head:
            type: section
            label: Automaten
            card_mod:
              style: |
                .label {
                  margin-left: 0px;
                }
          group_config:
            state_color: true
            secondary_info: last-triggered
          padding: 0
          entities:
            - entity: input_boolean.afval_reminder
              secondary_info: last-changed
            - entity: input_boolean.afval_staat_voor
              secondary_info: last-changed
            - type: divider
            - entity: automation.afval_vandaag
              name: Notify vandaag
            - entity: automation.afval_morgen
              name: Notify morgen
            - entity: automation.saver_offline
            - entity: automation.reset_trash_notification
            - entity: automation.mark_trash_as_moved_outside_from_notification

/config/sensors.yaml

#### Afvalwijzer ##################################
- platform: afvalwijzer
  provider: rd4                       # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer or afvalstoffendienstkalender
  postal_code: 9999AA                 # (required, default = '')
  street_number: 99                   # (required, default = '')
  #    suffix: A                      # (optional, default = '')
  #    exclude_pickup_today: true     # (optional, default = true) to take or not to take Today into account in the next pickup.
  default_label: Geen                 # (optional, default = Geen) label if no date found
  #    id: ''                         # (optional, default = '') use if you'd like to have multiple waste pickup locations in HASS
  #    exclude_list: ''               # (optional, default = '') comma separated list of wast types (case ignored). F.e. "papier, gft"

/config/customize.yaml

sensor.afvalwijzer_vandaag: &afval
      hide_attributes: templates
      templates:
        entity_picture: >
          var path = '/local/afvalwijzer/';
          var ext = '.png';
          var type = ['restafval','gft','pmd','papier','best_tas','snoeiafval'];
          return type.includes(state) ? path + state + ext : path + 'geen' + ext;

sensor.afvalwijzer_morgen: *afval

sensor.afvalwijzer_overmorgen: *afval

# niet in frontend
#    sensor.afvalwijzer_next_in_days:
#      hide_attributes: templates
#      templates:
#        icon: >
#          if (state === 'Geen') return 'mdi:calendar-question';
#          var items = ['1','2','3','4','5','6','7','8','9'];
#          if (items.includes(state))
#            return 'mdi:numeric-' + state + '-box-multiple-outline';
#          return 'mdi:help';

/config/templates.yaml

  - trigger:

      - platform: homeassistant
        event: start

      - platform: time_pattern
        hours: '/1'

    sensor:

      - unique_id: trash_alert
        state: >-
          {% if has_value('sensor.afvalwijzer_tomorrow') or
                has_value('sensor.afvalwijzer_today') %}
            {%- if states('sensor.afvalwijzer_tomorrow') != 'geen' and
                states('input_boolean.afval_morgen_notificatie') == 'on'%}
              Afval: {{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald
            {%- elif states('sensor.afvalwijzer_today') != 'geen'%}
              Afval: {{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald
            {%- else -%} Geen afval alert
            {%- endif -%}
          {% else %} Geen sensors gemaakt
          {% endif %}

      - unique_id: trash_next_icon
        state: >
          {% set days = states('sensor.afvalwijzer_next_in_days') %}
          {% if days != 'geen' %}
            {% if days|int <= 9 %} mdi:numeric-{{days}}-box-multiple-outline
            {% else %} mdi:numeric-9-plus-box-multiple-outline
            {% endif%}
          {% else %} mdi:checkbox-blank-outline
          {% endif %}

      - unique_id: trash_next_color
        state: >
          {% set next = states('sensor.afvalwijzer_next_type') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                          'plastic':'orange','restafval':'black'} %}
          {{colors.get(next,'grey')}}

      - unique_id: trash_color
        state: >
          {% set vandaag = states('sensor.afvalwijzer_today') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                           'plastic':'orange','restafval':'black'} %}
          {{colors.get(vandaag,'grey')}}

      - unique_id: volgende_afval_ophaal_dag
        state: >
          {%- set next = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),
                         '%d-%m-%Y',none),none) %}
          {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                            'Augustus','September','Oktober','November','December'] %}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                           'Vrijdag','Zaterdag'] %}
          {%- set wday = next|timestamp_custom('%w',default=none)|int(default=0) %}

/config/scripts.yaml

  notify_trash_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.notify_utility
        state: 'on'
      - service: notify.notify
        data:
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
          message: >
            {{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!

  persistent_trash_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.persistent_notification_create
        state: 'on'
      - service: persistent_notification.create
        data:
          notification_id: afval_vandaag_notificatie
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval vandaag
          message: >
            {{states('sensor.afvalwijzer_vandaag')|title}} wordt vandaag opgehaald!
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_vandaag_notificatie

  notify_trash_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.notify_utility
        state: 'on'
      - service: notify.notify
        data:
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
          message: >
            {{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!

  persistent_trash_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.persistent_notification_create
        state: 'on'
      - service: persistent_notification.create
        data:
          notification_id: afval_morgen_notificatie
          title: >
            {{states('sensor.vandaag').split('dag ')[1]}}: Afval morgen
          message: >
            {{states('sensor.afvalwijzer_morgen')|title}} wordt morgen opgehaald!
      - service: input_boolean.turn_on
        target:
          entity_id: input_boolean.afval_morgen_notificatie

  trash_outside_tomorrow:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.afval_staat_voor
        state: 'off'
      - condition: state
        entity_id: input_boolean.afval_reminder
        state: 'on'
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: >
            {% set title = states('sensor.afvalwijzer_morgen')|title %}
            {{title}} wordt morgen opgehaald, zet het afval aan de straat
          data:
            actions:
              - action: MARK_TRASH_MOVED
                title: Afval verwerkt
                destructive: true
            push:
              badge: 5
              sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav

  trash_outside_today:
    mode: restart
    sequence:
      - condition: state
        entity_id: input_boolean.afval_staat_voor
        state: 'off'
      - condition: state
        entity_id: input_boolean.afval_reminder
        state: 'on'
      - service: notify.mobile_app_marijn
        data:
          title: iOS notification
          message: >
            {% set title = states('sensor.afvalwijzer_vandaag')|title %}
            {{title}} wordt vandaag opgehaald, zet het afval aan de straat
          data:
            actions:
              - action: MARK_TRASH_MOVED
                title: Afval verwerkt
                destructive: true
            push:
              badge: 5
              sound: US-EN-Morgan-Freeman-Cleaning-Supplies-Closet-Opened.wav
            action_data:
              entity_id: input_boolean.afval_staat_voor

/config/automations.yaml

- id: '1692794685448'
  alias: Stalamp Abbygael schakelen
  description: Stalamp slaapkamer Abbygael geschakeld met tweevoudige schakelaar
  trigger:
  - platform: device
    domain: mqtt
    device_id: 13bfa105be59e6e04453dd11fb9ef379
    type: action
    subtype: 1_single
    discovery_id: 0xf4b3b1fffe45cd92 action_1_single
  condition: []
  action:
  - type: toggle
    device_id: fcac236e31949416cbb8d63f62176eea
    entity_id: 7906cef79b8897909ab931db4ab62e21
    domain: light
  mode: single
- id: '1692797554562'
  alias: Licht woonkamer schakelen
  description: ''
  trigger:
  - platform: sun
    event: sunset
    offset: -00:20:00
    id: Lampen aan
  - platform: time
    at: '23:00:00'
    id: Lampen uit
  condition: []
  action:
  - choose:
    - conditions:
      - condition: trigger
        id:
        - Lampen aan
      sequence:
      - service: light.turn_on
        data:
          brightness_pct: 50
        target:
          entity_id:
          - light.lampen_woonkamer_50
      - service: light.turn_on
        data:
          brightness_pct: 35
        target:
          entity_id: light.lampen_woonkamer_35
    - conditions:
      - condition: trigger
        id:
        - Lampen uit
      sequence:
      - service: light.turn_off
        data: {}
        target:
          entity_id: light.lampen_woonkamer
  mode: single
- id: '1695670434798'
  alias: saver_offline
  description: ''
  trigger:
    platform: state
    entity_id: binary_sensor.saver_offline
    to: 'on'
  action:
  - service: persistent_notification.create
    data:
      notification_id: saver_notificatie
      title: Saver melding
      message: '{{now().strftime(''%d %B'')}}: Saver is Offline

        '
  - service: script.intercom_message
    data:
      message_nl: 'Het is {{states(''sensor.vandaag'').split(''dag '')[1]}}: Saver
        is Offline, geen data voor Home Assistant

        '
      message_en: 'Today is {{now().strftime(''%A %-d %B'')}}: Saver is Offline and
        experiencing issues, no data provided to Home Assistant

        '
- id: '1695670498783'
  alias: afval_vandaag
  description: ''
  trigger:
    platform: time
    at: 07:00
  condition:
  - '{{has_value(''sensor.afvalwijzer_vandaag'')}}

    '
  - not:
      condition: state
      entity_id: sensor.afvalwijzer_vandaag
      state: geen
  action:
  - service: script.intercom_message
    data:
      message_nl: '{% set vandaag = states(''sensor.afvalwijzer_vandaag'') %} {{states(''sensor.vandaag'').split(''dag
        '')[1]}}: vandaag wordt {{vandaag}} opgehaald!

        '
      message_en: '{% set today = states(''sensor.afvalwijzer_vandaag'') %} {{now().strftime(''%A
        %-d %B'')}}: today {{today}} will be collected!

        '
  - service: script.persistent_trash_today
  - service: script.trash_outside_today
- id: '1695670548995'
  alias: afval_morgen
  description: ''
  trigger:
    platform: time
    at: '21:00'
  condition:
  - '{{has_value(''sensor.afvalwijzer_morgen'')}}

    '
  - not:
      condition: state
      entity_id: sensor.afvalwijzer_morgen
      state: geen
  action:
  - service: script.intercom_message
    data:
      message_nl: 'Het is {{states(''sensor.vandaag'').split(''dag '')[1]}}: Morgen
        wordt {{states(''sensor.afvalwijzer_morgen'')|title}} opgehaald!

        '
      message_en: 'Today is {{now().strftime(''%d %B'')}}: Tomorrow {{states(''sensor.afvalwijzer_morgen'')|title}}
        will be picked up!

        '
  - service: script.persistent_trash_tomorrow
  - service: script.trash_outside_tomorrow
- id: '1695670581563'
  alias: reset_trash_notification
  description: ''
  trigger:
    platform: state
    entity_id: input_boolean.afval_staat_voor
    to: 'on'
    for:
      hours: 5
  action:
    service: input_boolean.turn_off
    target:
      entity_id: input_boolean.afval_staat_voor
- id: '1695670617793'
  alias: reset_trash_notification_today
  description: ''
  trigger:
    platform: state
    entity_id: sensor.afvalwijzer_vandaag
    to: geen
  condition:
    condition: state
    entity_id: input_boolean.afval_vandaag_notificatie
    state: 'on'
  action:
  - service: persistent_notification.dismiss
    data:
      notification_id: afval_vandaag_notificatie
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.afval_vandaag_notificatie
- id: '1695670651401'
  alias: reset_trash_notification_tomorrow
  description: ''
  trigger:
    platform: state
    entity_id: sensor.afvalwijzer_morgen
    to: geen
  condition:
    condition: state
    entity_id: input_boolean.afval_morgen_notificatie
    state: 'on'
  action:
  - service: persistent_notification.dismiss
    data:
      notification_id: afval_morgen_notificatie
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.afval_morgen_notificatie
- id: '1695670701224'
  alias: dismiss_afval_notificatie
  description: ''
  trigger:
  - platform: persistent_notification
    update_type: removed
    notification_id: afval_vandaag_notificatie
  - platform: persistent_notification
    update_type: removed
    notification_id: afval_morgen_notificatie
  condition:
    or:
    - condition: state
      entity_id: input_boolean.afval_vandaag_notificatie
      state: 'on'
    - condition: state
      entity_id: input_boolean.afval_morgen_notificatie
      state: 'on'
  action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.afval_staat_voor
  - service: input_boolean.turn_off
    data:
      entity_id: 'input_boolean.{{trigger.notification.notification_id}}

        '
  - service: notify.mobile_app_marijn
    data:
      title: iOS notification
      message: Afval staat aan de straat
      data:
        push:
          badge: 0
          sound: 'US-EN-Morgan-Freeman-Good-{{(states(''sensor.part_of_day'') in [''Morning'',''Afternoon''])|iif(''Morning'',''Night'')}}.wav

            '
- id: '1695670755636'
  alias: mark_trash_as_moved_outside_from_notification
  description: ''
  trigger:
    platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: MARK_TRASH_MOVED
  action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.afval_staat_voor
  - service: persistent_notification.dismiss
    data:
      notification_id: "afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')\n
        \ |iif('vandaag','morgen')}}_notificatie\n"
  - service: input_boolean.turn_off
    data:
      entity_id: "input_boolean.afval_{{is_state('input_boolean.afval_vandaag_notificatie','on')\n
        \   |iif('vandaag','morgen')}}_notificatie\n"
  - service: notify.mobile_app_marijn
    data:
      title: iOS notification
      message: Afval staat aan de straat
      data:
        push:
          badge: 0
          sound: 'US-EN-Morgan-Freeman-Good-{{(states(''sensor.part_of_day'') in [''Morning'',''Afternoon''])|iif(''Morning'',''Night'')}}.wav

The images

first of all, why the splitting up? If you set HA up for using packages, you can keep everything together. I’ve always found it very illogical to order files by integration since life eisnt organized like that either.

A package can hold all that being to the same aspect of life, and make it easy as can be changing/deleting/testing that.

Also, please dont post all non relevant yaml for this, it makes it less obvious for us to help you if we need to go through your complete config.

the sensor was changed to sensor.vandaag :wink: and its a template sensor in another package I use, and basically is this:

  {%- set nu = as_timestamp(now()) %}
  {%- set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                    'Augustus','September','Oktober','November','December'] -%}
  {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                  'Vrijdag','Zaterdag'] -%}
  {%- set wday = nu|timestamp_custom('%w',default=none)|int(default=0) -%}
  {%- set month = nu|timestamp_custom('%m',default=none)|int(default=0) -%}
  {%- set datum = nu|timestamp_custom(wdays[wday]  ~ ' %-d ' ~ months[month-1]) -%}
  {{- datum -}}

I have that as a macro in a custom_templates so I can throw any datetime at it, but that would be beyond this for now

as for the double pickups, I never explored those, since I dont have them.

Maybe first fix the above? 1 step at a time …

btw you need to change all occurrences of

if you havent done so already :wink:

Hello @Mariusthvdb,

Thanks again for the quick response.

I understand what you’re saying, but my idea was to provide everything as complete as possible.

If I’m honest, I haven’t seen the use of ‘packages’ before. Do you mean calling a file from the configuration.yaml using the following code?:

homeassistant:
  customize: !include example.yaml

Perhaps you can briefly explain how this works or point me to where I can find the information.

As for the “sensor.today,” I have put the following in my “templates.yaml,” but unfortunately without success:

sensor:
  - unique_id: today
    state: >
      {%- set now = as_timestamp(now()) %}
      {%- set months = ['January','February','March','April','May','June','July',
                        'August','September','October','November','December'] -%}
      {%- set weekdays = ['Sunday','Monday','Tuesday','Wednesday','Thursday',
                         'Friday','Saturday'] -%}
      {%- set weekday = now|timestamp_custom('%w',default=none)|int(default=0) -%}
      {%- set month = now|timestamp_custom('%m',default=none)|int(default=0) -%}
      {%- set date = now|timestamp_custom(weekdays[weekday] ~ ' %-d ' ~ months[month-1]) -%}
      {{- date -}}

I don’t need to tell you how grateful I am, right :slight_smile:

Regard,
Herman

Hello @Mariusthvdb,

It seems that the “sensor” code is indeed working. I think I should have had a bit more patience. Apparently, restarting Home Assistant is not enough to activate the code.

What I do notice is that “template” is set for all sensors. Is this normal? Can I fix this?

The code that I used in templates.yaml is as follows:

  - trigger:

      - platform: homeassistant
        event: start

      - platform: time_pattern
        hours: '/1'

    sensor:
      - unique_id: today
        state: >
          {%- set nu = as_timestamp(now()) %}
          {%- set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                       'Augustus','September','Oktober','November','December'] -%}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                           'Vrijdag','Zaterdag'] -%}
          {%- set wday = nu|timestamp_custom('%w',default=none)|int(default=0) -%}
          {%- set month = nu|timestamp_custom('%m',default=none)|int(default=0) -%}
          {%- set datum = nu|timestamp_custom(wdays[wday]  ~ ' %-d ' ~ months[month-1]) -%}
          {{- datum -}}

      - unique_id: trash_alert
        state: >
          {% if has_value('sensor.afvalwijzer_tomorrow') or
                has_value('sensor.afvalwijzer_today') %}
            {%- if states('sensor.afvalwijzer_tomorrow') != 'geen' and
                states('input_boolean.afval_morgen_notificatie') == 'on'%}
              Afval: {{states('sensor.afvalwijzer_tomorrow')|title}} wordt morgen opgehaald
            {%- elif states('sensor.afvalwijzer_today') != 'geen'%}
              Afval: {{states('sensor.afvalwijzer_today')|title}} wordt vandaag opgehaald
            {%- else -%} Geen afval alert
            {%- endif -%}
          {% else %} Geen sensors gemaakt
          {% endif %}

      - unique_id: trash_next_icon
        state: >
          {% set days = states('sensor.afvalwijzer_next_in_days') %}
          {% if days != 'geen' %}
            {% if days|int <= 9 %} mdi:numeric-{{days}}-box-multiple-outline
            {% else %} mdi:numeric-9-plus-box-multiple-outline
            {% endif%}
          {% else %} mdi:checkbox-blank-outline
          {% endif %}

      - unique_id: trash_next_color
        state: >
          {% set next = states('sensor.afvalwijzer_next_type') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                          'plastic':'orange','restafval':'black'} %}
          {{colors.get(next,'grey')}}

      - unique_id: trash_color
        state: >
          {% set vandaag = states('sensor.afvalwijzer_today') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                           'plastic':'orange','restafval':'black'} %}
          {{colors.get(vandaag,'grey')}}

      - unique_id: volgende_afval_ophaal_dag
        state: >
          {%- set next = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),
                         '%d-%m-%Y',none),none) %}
          {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                            'Augustus','September','Oktober','November','December'] %}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                           'Vrijdag','Zaterdag'] %}
          {%- set wday = next|timestamp_custom('%w',default=none)|int(default=0) %}
          {%- set month = next|timestamp_custom('%m',default=none)|int(default=0) %}
          {{next|timestamp_custom(wdays[wday] ~ ' %-d ' ~ months[month-1],default=none)}}

Cheers Herman

the prefix ‘template’ happens on all new template sensors, unless you set a name: in that yaml config.
What I mostly do is set a name, check if the object_id of the entity (the part after the .) is ok, and then comment that name: filed again.

Ive made it a sport to not have anything in yaml if we can set it in the UI. That way we minimize user errors, and can always click and edit from the Frontend.

Given the fact you have a unique_id, you can edit all properties in the UI afterwards. So yes, you can change those easily

as for

I already did provide that link the post above your question :wink:

configuration.yaml needs to contain:

homeassistant:
  packages: !include_dir_named packages

and then create a folder packages in your main /config

next you can create yaml files (packages) with everything grouped logically according to your preferences.

this is however getting a bit off-topic here, so for more generic config questions, feel free to open a new topic, or check the community, because this is very well covered elsewhere

Many thanks @Mariusthvdb!

Much to learn I guess… ;o))

Cheers Herman.

Hi @Mariusthvdb,

I did try to implement the packages as you advised. Unfortunately, I’m getting the following error.
Of course, first I excluded the other imported scripts like sensor, templates, customize, etc.

image

Any suggestions?

Regards, Herman