Manage separate waste collection via home automation Home Assistant

5 minutes of reading
  • Define virtual sensors that signal how much, in days, the differentiated collection is missing
  • Difficulty level: bass
  • Cost: null

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (this guide is for educational purposes only);
  • any changes implemented in probefore a device will void the warranty.
revision projet: 1.2


The growing and blessed sensitivity to environmental issues our daily habits are slowly but surely changing, starting, without a doubt, from the introduction of recycling, often in a door-to-door collection mode. Being a "home" theme, it is natural to think of it as personal home automation can intervene to make the collection and disposal experience more efficient, above all with respect to remembering the different days of collection - especially in the case of particularly complex plans.


In this procast we will see how, through the adoption of the custom component "Garbage Collection", it is possible to define at Home Assistant, of virtual sensors that indicate to users of home automation based on this personale HUB how many days are missing in the collection of this or that type of waste.

The component is rather simple to use and at the same time quite flexible: it not only allows you to define sensors settimanali, but also of a different nature, or rather with a very specific cyclical nature (in the case, for example, of monthly collections on a given day of the month, or other case studies).


For this prowe will assume the presence of a type entity "E-mail Notifications"Call notify.marco and another, analogous, resulting from integration di Amazon Echo (Alexa) as Media Player (and therefore as a notification system), call media_player.alexa.

We will use these two entities as elements to define the automations of notification in the face of the approaching collection days.


Being a custom component (so not officially included on theHUB), before you can take advantage of the features you need to install it. To do this you can use both the manual mode (not described in this projet) is the - very facilitated - way HACS.

To do this it is necessary that HACS was, of course, previously installed on Home Assistant. Once you have access to the HACS panel, perform a search in your store looking specifically for the component "Garbage Collection"

Once identified, prosee to install it:

Home Assistant - HACS - Garbage Collection installation

After that prosee a reboot di Home Assistant.


We therefore assume that you are in the exemplary situation of a door-to-door collection which includes:

  • the collection of paper Tuesday and Saturday;
  • the collection of the fraction undifferentiated Monday and Friday;
  • the collection of the fraction biodegradable/ compostable on Mondays and Wednesdays;
  • the collection of plastic, Tuesdays and Saturdays;
  • the collection of bulky materials, the first and third Saturday of the month.

We will therefore add to define the sensors in configuration, in the section dedicated to "Sensor", Of the items of this type:

  - name: "Indifferenziato"
    frequency: "weekly"
    verbose_state: true
    - mon
    - fri
  - name: "Bio"
    frequency: "weekly"
    verbose_state: true
    - mon
    - wed
  - name: "Carta"
    frequency: "weekly"
    verbose_state: true
    - tue
    - sat
  - name: "Plastica e metallo"
    frequency: "weekly"
    verbose_state: true
    - tue
    - sat
  - name: "Rifiuti ingombranti"
    frequency: "monthly"
    collection_days: "sat"
    verbose_state: true
    - 1
    - 3

Which configuration, after the reboot necessary of Home Assistant, will generate some entity so call:

  • sensor.indifferenziato
  • sensor.carta
  • sensor.plastica_e_metallo
  • sensor.rifiuti_ingombranti

rappresented at the frontend Lovelace di Home Assistant, for example like this:

Home Assistant - Garbage Collector sample

As you notice, the entity states display the remaining time at prosime collections (the photo was taken on Wednesday 9 October 2019).

Explanation of the fields available for configuration:

platfom(Required) Must necessarily be "Garbage_collection"
collection_days(Mandatory) Days, indicated in English and with three letters: "mon","tue","wed","thu","fri","sat","sun"
frequency(Optional) Frequency of collection, expressed in English, chosen from these elements: "weekly","even-weeks","odd-weeks""every-n-weeks"Or"monthly". Default: "weekly"
name(Optional) Name of the sensor. Default: "garbage_collection"
first_month(Optional) First month in which the collection is made, expressed in three letters and in English (eg. "jan“).
last_month(Optional) Last month in which the collection is made, expressed in three letters and in English (eg. "dec“).
(Optional) Indicates which day of the month the collection occurs. If for example collection_days contains "sat" and this parameter is set to 2, collection will take place on the second Saturday of the month.
Period(Optional) Used in abbinameto the parameter "frequency"Set to"every-n-weeks": Indicates the"n"Weeks how often the collection takes place.
first_week(Optional) First week of the year from which the collection starts (1-53).
excude_dates(Optional) List of dates to be excluded in format "yyyy-mm-dd"
include_dates(Optional) List of dates to be included in format "yyyy-mm-dd"
icon_normal(Optional) Sensor icon. Default “mdi:trash-can"
icon_today(Optional) Sensor icon in the occurrence of the collection day. Default “mdi:delete-restore"
icon_tomorrow(Optional) Sensor icon in occurrence of the previous day of collection. Default “mdi:delete-circle"
verbose_state(Optional) When set to true, the sensor returns to the status la proexpected collection date. In case of false (default), displays an integer rappgive the number of missing days (0 for the day of collection).


Obviously this paragraph it will not be decisive: choosing when (and if) being alerted to the collection day is a personal choice. We will therefore limit ourselves to explaining notification techniques, but personalization will be charged profirst (as always, in the end).

As sappIAMO the automations of Home Assistant are based on the change of status of one or more set entities such as trigger automation / s. Entities defined through "Garbage Collection" contain an attribute ("days") Which contains the number of days remaining to the collection; using the status changes of this attribute we can trigger classic notifications and / or announcements by our smart speaker (or other).

A typical automation could be the following:

  alias: "Notifica ritiro biodegradabile"
    platform: numeric_state
    value_template: "{{ state.attributes.days }}"
    below: 1
  condition: []
    service: notify.famiglia
      title: "Domotica"
      message: "Attenzione: domani è giorno di ritiro frazione biologica."

or in the case you want to talk Alexa:

  alias: "Notifica ritiro biodegradabile"
    platform: numeric_state
    entity_id:, sensor.carta
    value_template: "{{ state.attributes.days }}"
    below: 1
  condition: []
    service: notify.alexa
      target: media_player.alexa
        type: announce
        method: spoken
      message: "Attenzione: domani è giorno di ritiro frazione {{ trigger.from_state.attributes.friendly_name }}."

We also took the opportunity in this second automation to use more sensors like trigger, so you can write a single automation instead of one for each sensor. Obviously the notification message has also been adjusted to report the correct forecast collection.

Obviously the change of state takes place every day at midnight, time not prosuitable to be notified, if any, prossima separate collection. In case you prefer to be alerted to another time - or on trigger specific - a block will be needed action different, which interprets the status of the sensors and notifies what you believe.

Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.

Please comment below