Quick Project: Rubbish Collection Panel for Home Assistant

This post may contain affiliate links. Please see the disclaimer for more information.

With my local council rolling out an increasingly complex system of rubbish bins and collection, I’ve been thinking about getting this integrated with Home Assistant so that we don’t have to remember which bins go out when. I was presently surprised to find the garbage_collection custom component whilst browsing HACS the other day. This component does exactly what I need, so I decided to give it a go.

Rubbish Collection Configuration

After installing the component via HACS, I set about configuring it. Here is the configuration I came up with:

That was easy! The only non-obvious thing is working out which bins are collected on even and odd weeks, which is easy to look up online.

Getting it into Lovelace

The garbage_collection component page in HACS has a nice screenshot of the sensors in Lovelace (which doesn’t seem to be in the repository readme). However, the sensors themselves have a state based on whether the bin is due to be put out. The state is nice and machine readable, but I wanted to recreate the panel from the screenshot for the humans that have to look at it. In the end I actually decided to simplify it down to just show “today”, “this week” or “next week” plus the number of days, since the actual date is pretty irrelevant.

home assistant rubbish collection
The finished rubbish collection panel in my Lovelace UI

This proved to be more difficult than I’d expected, since Lovelace doesn’t support templates in cards natively. I had to install the Lovelace Card Templater plugin via HACS. This plugin in turn requires the card-tools plugin, which I couldn’t find in HACS. I ended up installing it by adding it as a git submodule to my configuration repository. I then added the following to my Lovelace config to load the plugins:

Full Panel YAML

The panel itself is made up of a vertical stack card in which I put two horizontal stack cards. These in turn contain two of the templater cards. The configuration of the templater cards is a little involved since you need to specify the entity twice (which seems to be due to some internal limitation of Lovelace). My template cards are based on the sensor card to show just the data from the template. I use a state_template to do this.

Anyway, here’s the full YAML:

Each of the templater cards is pretty much the same. I just change the entity ID for each. The only improvement I would make would be to add a line break between the “Today”/”This week”/Next Week” text and the day count, since this would look slightly better. I couldn’t work out how to do that however.

Conclusion

I think I’ve achieved my goal of simplifying the task of remembering which bins go out when. Now I can quickly check that info with a glance at my HASS UI. Of course, now that I have the rubbish collection data in Home Assistant I can use it for other things such as notifications or reminder lights. I already have some ideas for status lighting, so that might become part of a larger project.

I’d like to say thanks to the authors of the custom components and plugins that I’ve used to achieve this. The HASS community really is thriving will all these third party addons at the moment!

If you liked this post and want to see more, please consider subscribing to the mailing list (below) or the RSS feed. You can also follow me on Twitter. If you want to show your appreciation, feel free to buy me a coffee.

4 thoughts on “Quick Project: Rubbish Collection Panel for Home Assistant

  1. Dan says:

    Hey man – thanks for a great post. Gave me what I needed to get this done for myself.

    Quick comment, though: your code block for the YAML doesn’t have the ‘0’ after the ‘==’ when evaluating the “today” condition for each sensor. Without this, hass throws an (annoying) error.

    Also, your ‘<'s have rendered to html '<'s. Not sure if that's a breaking typo, but it looks a little cleaner with brangles. 😉

    Cheers!

  2. Hi Dan,

    Thanks for the feedback and heads up. The code block breakage is something to do with WordPress and/or the syntax highlighting plugin I use (including the missing zeros, which is really odd). Not sure what the issue is yet, but it’s on my list to investigate.

    Thanks again!

  3. Lee says:

    Hi Thanks for your post. Its exactly what im trying to do now however im stumped and cant work out what I have done wrong. Im getting a error in the card config screen stating “end of the stream or a document separator is expected at line 49, column 1: type: vertical-stack ^
    Cannot read property ‘setConfig’ of undefined”

    – cards:
    – card:
    entity: sensor.garbage
    type: sensor
    entities:
    – entity: sensor.garbage
    state_template: >-
    {% if state_attr(“sensor.garbage”, “days”) == 0 %} Today {%
    elif state_attr(“sensor.garbage”, “days”) < 7 %} This Week {%
    else %} Next Week {% endif %} ({{ state_attr(“sensor.garbage”,
    “days”) }} days)
    type: ‘custom:card-templater’
    – card:
    entity: sensor.recycling
    type: sensor
    entities:
    – entity: sensor.recycling
    state_template: >-
    {% if state_attr(“sensor.recycling”, “days”) == 0 %} Today
    {%elif state_attr(“sensor.recycling”, “days”) < 7 %} This
    Week {% else %} Next Week {% endif %} ({{
    state_attr(“sensor.recycling”, “days”) }} days)
    type: ‘custom:card-templater’
    type: horizontal-stack
    – cards:
    – card:
    entity: sensor.garden_waste
    type: sensor
    entities:
    – entity: sensor.garden_waste
    state_template: >-
    {% if state_attr(“sensor.garden_waste”, “days”) == 0 %} Today {%
    elif state_attr(“sensor.garden_waste”, “days”) < 7 %} This Week {%
    else %} Next Week {% endif %} ({{ state_attr(“sensor.garden_waste”,
    “days”) }} days)
    type: ‘custom:card-templater’
    – card:
    entity: sensor.hard_rubbish
    type: sensor
    entities:
    – entity: sensor.hard_rubbish
    state_template: >-
    {% if state_attr(“sensor.hard_rubbish”, “days”) == 0 %} Today {%
    elif state_attr(“sensor.hard_rubbish”, “days”) < 7 %} This Week {%
    else %} Next Week {% endif %} ({{ state_attr(“sensor.hard_rubbish”, “days”) }}
    days)
    type: ‘custom:card-templater’
    type: horizontal-stack
    type: vertical-stack

    Any ideas ?

  4. Hi Lee,

    Sorry for the delay in replying, I wanted to reply after I’d had chance to try out your code.

    I’ve given it a try and I’m afraid I didn’t get very far due to the lack of indentation! Would you be able to send me a better formatted version? You can use the email address on the contact page. Alternatively you can ask on the HASS forums where you’ll have access to the expertise of the whole community. Reply with a link to your thread here and I’ll take a look too.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.