Garbage reminder

Tags: #<Tag:0x00007fc40a38f538> #<Tag:0x00007fc40a38f470> #<Tag:0x00007fc40a38f3a8>

Get garbage notifications from up to 4 sensors. You will receive 1 notification with the friendly names of the sensors (comma separated) that have a matching date. The sensors date format is configurable. Works out of the box with integrations like TwenteMilieu or the afvalbeheer integration on HACS but can even be used for anything else that needs reminder notifications based on sensors with a date as state value.

A date offset, combined with an input for notification time is added so you can be notified on the garbage collection date (0) or any amount of days before.

I added a text input for the notifier so you can use all notification channels. Currently you have to select a value for all 4 sensors because there is no user friendly solution for this at the moment until there are multiselect entity inputs. As a workaround set the value to a sensor that has a non-date type string value when you have less than 4 sensors.

Blueprint

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: Garbage reminder
  domain: automation
  input:
    reminder_time:
      name: Reminder time
      description: At what time the day before do you want to be reminded
      default: '18:00:00'
      selector:
        time: {}
    day_offset:
      name: Day offset
      description: Amount of days to be added to the triggers date to check for sensor
        value matches. E.g. 1 to be notified the day before or 0 for notification
        on the garbage collection day.
      default: 1
    date_format:
      name: Date format
      description: Valid strftime date format. Default %Y-%m-%d
      default: '%Y-%m-%d'
    reminder_title:
      name: Reminder title
      description: Shown as title in the notification
      default: Garbage reminder
    reminder_message:
      name: Reminder message
      description: Accompanying text in the notification
      default: 'The following garbage will be picked up tomorrow: '
    notifier:
      name: Notifier
      description: Name of integration you prefer to use for notifications. E.g. notify.notify
      default: notify.notify
    garbage_sensor_1:
      name: Garbage sensor 1
      description: Sensor should be a date string formatted according to the date format input
      default: ''
      selector:
        entity:
          domain: sensor
    garbage_sensor_2:
      name: Garbage sensor 2
      description: Sensor should be a date string formatted according to the date format input
      default: ''
      selector:
        entity:
          domain: sensor
    garbage_sensor_3:
      name: Garbage sensor 3
      description: Sensor should be a date string formatted according to the date format input
      default: ''
      selector:
        entity:
          domain: sensor
    garbage_sensor_4:
      name: Garbage sensor 4
      description: Sensor should be a date string formatted according to the date format input
      default: ''
      selector:
        entity:
          domain: sensor

variables:
  garbage_sensor_1: !input 'garbage_sensor_1'
  garbage_sensor_2: !input 'garbage_sensor_2'
  garbage_sensor_3: !input 'garbage_sensor_3'
  garbage_sensor_4: !input 'garbage_sensor_4'
  reminder_title: !input 'reminder_title'
  reminder_message: !input 'reminder_message'
  day_offset: !input 'day_offset'
  date_format: !input 'date_format'
  sensors_tomorrow: '{{ [(state_attr(garbage_sensor_1, ''friendly_name''), states(garbage_sensor_1)), (state_attr(garbage_sensor_2, ''friendly_name''), states(garbage_sensor_2)), (state_attr(garbage_sensor_3, ''friendly_name''), states(garbage_sensor_3)), (state_attr(garbage_sensor_4, ''friendly_name''), states(garbage_sensor_4))] | selectattr(''1'', ''eq'', (now() + timedelta(days = day_offset | int)).strftime(date_format)) | join('', '',  attribute=0) }}'
trigger:
  platform: time
  at: !input 'reminder_time'
condition:
  condition: template
  value_template: "{{ sensors_tomorrow != '' }}"
action:
  service: !input 'notifier'
  data:
    title: '{{ reminder_title }}'
    message: '{{ reminder_message }}{{ sensors_tomorrow }}'
4 Likes

What do you think, should I call it:

a) Garbage reminder
b) Trash reminder
c) Waste reminder

My wife says:

So, I am gonna have to say garbage

2 Likes

Great that you created a blueprint for this. I use the Twentemilieu integration myself so could use it out-of-the-box.

In the blueprint it says the following:
Amount of days to be added to the triggers date to check for sensor value matches. E.g. 1 to be notified the day before or 0 for notification on the garbage collection day.

I just don’t see this reflected anywhere in the blueprint and if I make it an automation I get a message every day at the set time. Am i missing something or is there a trigger option missing?

it’s in the timedelta of variable sensors_tomorrow. So with that it calculates a day to match the sensor values against.

Also I updated the blueprint a bit, there was a bug that caused notifications to appear every day even when there is no garbage to be picked up.

1 Like

What type of sensor (contact?) do you use? What does the sensor track?

The sensors are fed from a garbage collection integration that fetches the collection dates for various types of garbage from an API. So no hardware sensors here to measure amounts of garbage etc.

In my case, I only use one sensor and it throws up an error


EDIT: It’s mentioned in the post what the solution is

I don’t have any sensors but calendar entries. Is it possible to use the blueprint for this as well?
It uses the Attribute start_time.

Updated the blueprint. You can now configure the date format and sensor inputs are optional so you can also configure less than 4 sensors.

Great blueprint, thanks!

Would you be able to add some customisation options to the notification? Color and notification channel come to mind. That’d make it perfect.

I use afvalbeheer with this but i can’t get it to define what will be picked up tomorrow

Hi, not planning on adding it but feel free to extend the blueprint and share it.