We have a wall-mounted dashboard for Home Assistant in our Kitchen, which displays what bin day it is via a coloured Mushroom UI icon. Where we live, like most other places in the UK, there are different coloured bins for different types of waste, and each week the rubbish from one of these bins will be collected.

  • Black bin – general domestic waste
  • Blue bin – paper and cardboard recycling
  • Brown bin – mixed recycling

Whilst displaying which bin is due to be collected that week on the dashboard has been useful, we're still having to remember to put the bin out each week. It didn't take long before I thought, what if Home Assistant can remind us to put the bin out if it hasn't already been put out?

Prerequisite

Before we dig into how this works, I am going to assume that you're already able to pull in which bin day it is based on a sensor value. Our local authority didn't have a way of allowing us to scrape this from an API, so I built a basic process for looking up the week in a CSV file. It's a bit crude, but it's very reliable and I only have to update the CSV once every 12-18 months when a new schedule is published by the local authority. You can read more about this approach in my Controlling Icon Colour with Mushroom UI blog post.

The Concept

The concept of what I'm trying to achieve is fairly simple. I want Home Assistant to remind us periodically on bin collection day that the bin needs to be put out. Home Assistant should keep reminding us until one of us has done it.

On bin day, when we go into the Kitchen, we should be reminded by the Amazon Alexa that the bin needs to be put out, and which bin it is for that week. This should happen every ~20 minutes until the bin has been put out.

Putting the bin out will require opening the frontdoor so that we can move the bin from the back of the driveway onto the kurb ready for collection.

When Home Assistant detects that the front door has been opened (provided the bin hasn't already been put out), a push notification should be sent to our devices as a final reminder to put the bin out. This notification will also have an action that can be pressed to record that the bin has been put out. Once Home Assistant knows the bin has been put out, it will stop reminding us to put the bin out until next week.

Helpers

As part of these automations there are two things that I will need to track:

  • When was the last reminder issued
  • Has the bin been put out for collection

These two pieces of information will be tracked via the use of Helpers in Home Assistant. A helper can be thought of as a persisted variable that can easily be retrieved or set in automations.

Home Assistant helpers used by the bin reminder automation

bin_last_reminded will be a datetime helper that will store the date and time when the last reminder was sent.

bin_confirmed_ready will be a boolean helper – set to true when the bin is ready to be collected, and false when the bin still needs to be put out.

Automations

Our bin reminder system is comprised of three different automations:

  • An automation to that uses Amazon Alexa to reminder us periodically that it is bin day
  • An automation to use a push notification to remind us to put the bin out and capture that we have done this when we open the front door
  • An automation to reset the helpers at the end of the day, ready for next week

Amazon Alexa Reminder

We have an Amazon Alexa and a motion sensor in our Kitchen. This automation will only run when motion is the kitchen is detected and provided it is bin day (Tuesday), the bin has not already been put out and the automation hasn't run within the last 20 minutes (1200 seconds). When it runs the automation will:

  1. Set the volume on the Alexa to 30%
    It's likely to be early in the morning so we don't want Alexa to be too loud
  2. Announce using Alexa text-to-speech which colour bin day it is this week
  3. Set the bin_last_reminded helper to the current date and time
    This is to record the time the last reminder was issued
  4. Set the volume on the Alexa to 50%
    Alexa is used for other automations (e.g. doorbell notifications, etc), therefore return the volume to a sensible level that is unlikely to bne missed).
alias: Bin Day Reminder
description: "Announce a reminder to put out the bin"
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.kitchen
    to: "on"
    from: "off"
condition:
  - condition: time
    weekday:
      - tue
  - condition: state
    entity_id: input_boolean.bin_confirmed_ready
    state: "off"
  - condition: template
    value_template: "{{ now().timestamp() - state_attr('input_datetime.bin_last_reminded', 'timestamp') > 1200 }}"
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.3
    target:
      entity_id: media_player.kitchen_2
  - service: notify.alexa_media
    data:
      message: This week is {{states('sensor.bin_day')}} bin day. Please put the bin out.
      target:
        - media_player.kitchen_2
      data:
        type: announce
        method: all
  - service: input_datetime.set_datetime
    data_template:
      entity_id: input_datetime.bin_last_reminded
      datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id: media_player.kitchen_2

bin_day_reminder.yaml

Front Door Opens Reminder

Our front door has a door contact sensor that can detect when the door is open or closed. This automation will run when the door is opened, and provided that the bin hasn't already been put out and it is bin day (Tuesday).

This automation will send a push notification asking us to confirm if the bin has been put out. This notification uses actions, which means that we will be provided with the action buttons we've defined as a way of recording the response to the prompt.

The actions that we ill be able to take are:

  • Ready for Collection
  • I still need to put the bin out
Home Assistant sending a push notification with actions

Once the push notification has been sent, Home Assistant will then wait for up to 30 minutes to receive a response from one of the actions. I have set this 30 minute timeout so that Home Assistant isn't hanging around for an indefinite amount of time waiting for a push notification that may never arrive (e.g. someone has just dimsissed the notification).

  • Ready for Collection
    This will set the bin_confirmed_ready boolean helper to true, supressing all other bin reminder related automations for the rest of the day, as there is no more human action that is required
  • I still need to put the bin out
    This will ensure that the bin_confirmed_ready boolean helper is set to false, and the bin reminder related automation will continue for the rest of the day, until someone puts the bin out
alias: Bin Day Reminder - Confirmation Notification
description: "Send a confirmation to confirm that bin has been put out"
mode: parallel
trigger:
  - platform: state
    entity_id:
      - binary_sensor.zone_10
    to: "on"
    from: "off"
condition:
  - condition: time
    weekday:
      - tue
  - condition: state
    entity_id: input_boolean.bin_confirmed_ready
    state: "off"
action:
  - variables:
      action_yes: "{{ 'YES_' ~ context.id }}"
      action_no: "{{ 'NO_' ~ context.id }}"
  - service: notify.family
    data:
      message: Please confirm that the {{states('sensor.bin_day')}} bin has been put out?
      data:
        actions:
          - action: "{{ action_yes }}"
            title: "Ready for Collection"
            icon: "sfsymbols:checkmark.circle"
          - action: "{{ action_no }}"
            title: "I still need to put the bin out"
            destructive: true
            icon: "sfsymbols:nosign"
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_yes }}"
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: "{{ action_no }}"
    timeout:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
    continue_on_timeout: false
  - choose:
      - conditions: "{{ wait.trigger.event.data.action == action_yes }}"
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.bin_confirmed_ready
      - conditions: "{{ wait.trigger.event.data.action == action_no }}"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.bin_confirmed_ready

bin_day_send_confirmation.yaml

Reset Automation

Our bin collection day is Tuesday, so this automation runs at 00:00:01 on Wednesday to reset the bin_confirmed_ready helper to false ready for next week:

alias: Bin Day Reminder Reset
description: "Reset reminder to put out the bin"
mode: single
trigger:
  - platform: time
    at: "00:00:01"
condition:
  - condition: time
    weekday:
      - wed
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.bin_confirmed_ready

bin_day_reminder_reset.yaml

Conclusion

Having a series of automations to remind you to put out the corect bin is by no means the most exciting home automation I've come up with – but it is useful. What this automation also demonstrates is how helpers can be used to make a series of automations work well together by being able to check the state and values of these helpers.

Finally, whilst I've used push notifications before, this was the first attempt to use actions in push notifications – this works great for being able to capture if soemone has put the bin out or not.