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.
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:
- 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 - Announce using Alexa text-to-speech which colour bin day it is this week
- Set the
bin_last_reminded
helper to the current date and time
This is to record the time the last reminder was issued - 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).
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
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 thebin_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 thebin_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
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:
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.