Garbage pickup date (mijnafvalwijzer.nl) custom_component

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

please post your configuration.yaml, and show a screenshot of the /config showing the map for the packages?

it should be something like
/config/packages/afvalwijzer_backend.yaml

and inside that package just list all integrations a top, so you would need

script:


template:

automation:

inside that

Here you go.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Example configuration.yaml entry

frontend:
  themes: !include_dir_merge_named themes
  
sensor: !include sensors.yaml
template: !include templates.yaml

homeassistant:
# customize: !include customize.yaml
  packages: !include_dir_named packages

And the card looks like this now.

And the package ?

And the Config/packages config.

The scripts.yaml, template.yaml, and automation.yaml contain no code for ‘Afvalwijzer’ anymore.

image

The package provide by you :wink:

##########################################################################################
## 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: rd4
    postal_code: 9999ab
    street_number: 99

##########################################################################################
# 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

How odd, looks good :wink:

If you take out the package from the config, and do config check, does it still error?

Btw please edit your postcode

"If you take out the package from the config, and do config check, does it still error?"
Not exactly know hoe to do that with one separate file

Btw please edit your postcode
Postcode should be lowercase like 9999ab?

From the point I can judge, only the automations and scripts are not working. See previous screenshot.

What could have happened is that your automations have different object_id s and because of that don’t list as in the card.

Check dev tools /state for automation.automation_xxx where xxx will be a number.

If that is the case, you can simply change that object_id to the id of the automation and you should be good

I believe the card also shows the sensor.vandaag not to be created . Might be the same issue, as template integration auto adds ‘template’ in that object_id.
Again, simply edit that away.

As for your postcode: I meant you posted your actual postcode and you should not ….

Scripts: those should really be ok, so I am not sure what happened there .

The error you posted seems to indicate some top level hierarchy being incorrect .

Please check your indenting carefully, because if the yaml is off at some point, the checker will error with these types of warnings .

The beauty of packages is just that you can take out the file completely and then check the remaining config.

Just open the config directory in your file browser and take it out and store it somewhere you can drag it back from :wink:

Starting to be a bit frustrated! Now the whole card doesn’t function anymore :o( just suddenly after checking 1 hour later or so…

this is going to go far beyond the topic of this thread, so I suggest you open a new and dedicated topic, on how to install a package.
The package I have should be a drop in, and all in it should just work. I cant imagine what could be wrong now, but we need to take it a step back and go from there to build it up again.

also, you need to make sure you can easily edit files (preferably outside of HA, so you are not depending on a working frontend for that), and you can manipulate files over your network (preferably with something like SMB add-on, again so your are not depending on the frontend )

lets go there and Ill be glad to assist you further

You are right. Start a new topic next week.

For now I did start over by taking out the package and cleanup all the sensors. After putting the package back again it looks like the card is working partially.

See you on the other side.

Thank for al the help so far!

The majority of the ‘Automaten’ seem to be working. However, I can’t seem to get the two ‘input booleans’ to work. I’ve looked for incorrect ‘IDs.’ I’ve looked for incorrect naming. Unfortunately, I can’t pinpoint the error. I’m using a ‘Package’ where all the code resides. Thanks to @Mariusthvdb for all the support in this!

Any ideas?

image

The backend code of the '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_gft:
      friendly_name: GFT
    sensor.afvalwijzer_papier:
      friendly_name: Papier
    sensor.afvalwijzer_restafval:
      friendly_name: Restafval
    sensor.afvalwijzer_pmd:
      friendly_name: PMD
    sensor.afvalwijzer_best_tas:
      friendly_name: Best-tas
    sensor.afvalwijzer_snoeiafval:
      friendly_name: Snoeiafval

    sensor.afvalwijzer_vandaag: &afval
      hide_attributes: templates
      templates:
        entity_picture: >
          var path = '/local/afvalwijzer/';
          var ext = '.png';
          var type = ['restafval','gft','papier','pmd','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';

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

sensor:

  - platform: afvalwijzer
    provider: rd4
    postal_code: 6369hj
    street_number: 33

##########################################################################################
# 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',
                           'pmd':'orange','restafval':'black'} %}
          {{colors.get(next,'grey')}}

      - unique_id: trash_color
        state: >
          {% set vandaag = states('sensor.afvalwijzer_vandaag') %}
          {% set colors = {'papier':'deepskyblue','gft':'darkgreen',
                           'pmd':'orange','restafval':'black'} %}
          {{colors.get(vandaag,'grey')}}
          
      - unique_id: today_date
        state: >
          {%- set now = as_timestamp(now()) %}
          {%- set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                            'Augustus','September','Oktober','November','December'] %}
          {%- set weekdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag',
                              'Vrijdag','Zaterdag'] %}
          {%- 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 -}}          
          
      - 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
```

All of my Boolean’s are created in the Ui helper section …

They are not in the yaml package

Seven days ago, you told me that everything is in the ‘backend script’ and that it should work straightforwardly. I’ve mentioned multiple times that I’m not a programmer. Therefore, it’s sometimes challenging for me to connect the dots. I’m doing my best.

Is it possible to post the YAML of the helpers?

@Mariusthvdb,

It looks like I’ve probably figured out how it works. After some “Googling” and watching “YouTube” videos, it seems like I’ve got it. Now, let’s see if we can also create a nice Dutch text from it.
image

Already said we need to take a step back… this it part of that.

There is no yaml of these helpers (well technically there is but we don’t use that) . You simple create it in the helper section . In Dutch it is a schakelaar.

Can you have a go at that? Just take care they use the same name as the object id

Edit

We cross posted … cool

Sometimes, I can be a bit like a pitbull when I really want to get something working. Sorry if I come across as impatient then.

Is it possible to provide the “Automaten” with a Dutch text? Perhaps something like a “Friendly name”?"