When do I have to bring out the trash? We here in the nice city of Bad Homburg have 4 different trash collections (not counting the “special” collections like garden waste etc.):
- Organic waste (weekly, usually on a Thursday, except if Thursday is a holiday)
- Recyling waste (bi-weekly, also usually on a Thursday, except…)
- Paper waste (bi weekly, on Monday, except…)
- Other waste (everthing which does not fit into the other categories, bi-weekly, on Tuesdays, except…)
So you see its complicated. And we have to bring the waste bin to the edge of the street for collection on the evening before (and take it back after it has been emptied).
I am using HomeAssistant for my home automation, so the idea was to use that as a reminder when to move which of the bins to the street.
Part 1 – setting up HomeAssistant
HomeAssistant works with so-called “integrations” and fortunately there is already an integration implementing a waste collection schedule. It is called “Waste Collection Schedule” and part of the HACS (Home Assistant Community Store) and you can download it here.
Please check if your town/street is supported (a lot are, also a lot are not), and configure it (see my example below).
First thing you have to configure is the source of the information. The nice town of Bad Homburg does not have an API of their own, but fortunately you can get the waste times via Jumomind. For my home the entry in configuration.yaml
looks like:
waste_collection_schedule:
sources:
- name: jumomind_de
args:
service_id: hom
city_id: 1
area_id: 77
This is not all, this gives you the source of the information, but for the ePaper tag you want to know how many days until the next collection. So for each collection type you need a sensor entry. To create them, you first need to know how the collection types are called. For this, create a simple sensor in your configuration.yaml
:
sensor:
- platform: waste_collection_schedule
name: next_garbage_collection
event_index: 0
value_template: '{{value.types|join(", ")}} in {{ value.daysTo }} days'
Reminder: Each time you add something into your configuration.yaml
you have to restart HomeAssistant.
Now in your HomeAssitant website go to “Developer tools”, “States” and search for entity “sensor.next_garbate_collection“. In the “Attributes” column you should see all collection dates and names. Pick the ones you need as sensors.
Now again in configuration.yaml define a sensor for each of these collections you want to track. Sorry for the German names in the example, I simply copied my config:
sensor:
- platform: waste_collection_schedule
name: next_restmuell
value_template: '{{value.daysTo}}'
types:
- "Restmülltonne"
- platform: waste_collection_schedule
name: next_biomuell
value_template: '{{value.daysTo}}'
types:
- Bioabfall
- platform: waste_collection_schedule
name: next_papiermuell
value_template: '{{value.daysTo}}'
types:
- Papiertonne
- platform: waste_collection_schedule
name: next_gelbersack
value_template: '{{value.daysTo}}'
types:
- "Gelbe Säcke"
Here is another pitfall: These sensors return their values as strings – not as integers! The value_template
takes care that only a number is returned (otherwise it would return “In x days”), but it is still a string so where ever you process this value it might have to be converted into an integer first!
Now we have prepared HomeAssistant to deliver sensor values about the next garbage collections. Next step will be setting up the ePaper tag.
Part 2 – ePaper Tags
I am using OpenEPaperLink as a framework. Please see their wiki for all the details. Just some basic information on how I got it up and running.
List of hardware:
- ESP32-S3, I am using this one from Wemos. Not sure if a “mini” would do as well, the description says “it needs RAM”.
- ESP32-C6 to communicate with the tags – I simply bought one from Aliexpress and then bought another one because the first one was to small.
- Some wires to connect them together. See here for the wiring. The Wemos S3 does not have all the required pins so I could not flash the C6 from the S3, I simply connected it to my Mac and used the Mac for flashing.
Flash the two ESPs, connect them with the wires, power one of them (the other gets the power via the wires) and you are ready to go.
The tags I am using I bought here – they come pre-flashed and ready to be used.
You also have to add an integration to Home Assistant.
For the image to be shown I followed this blog here – with some changes as for whatever reason it looks like the syntax required in home assistant has changed. Also I wanted the display to look a bit differently:
- Four types of waste
- An icon for each waste
- Name of the waste as text
- Days until collection as: “Tomorrow”, “Today” or number of days
- If collection is tomorrow, Icon should be red.
So, here the code for one of the waste types as an HomeAssistant automation. It starts with a name, no description, it is triggered each night at 02:00. The “action” part then is most interesting, it contans a call to a service named “open_epaper_link.drawcustom” doing all the work:
- Target is the identifier of your ePaper tag
- we have a white background, not rotated
- an Icon
- the “color” of the icon contains the first code, make it “red” if the collection is tomorrow (1), be aware of the “
| int
” – this converts the string from the sensor to an integer. - x and y are the coordinates where to draw, we are using a font of a specific size – you can figure that out yourself.
- The “value” of the second “text” again is interesting, here is the logic that depending on the value of the sensor different things are printed. Again – we convert into integer.
alias: Abfall-EPaper
description: ""
trigger:
- platform: time
at: "02:00:00"
condition: []
action:
- service: open_epaper_link.drawcustom
target:
entity_id: open_epaper_link.0000021ed1db3b1e
data:
background: white
rotate: 0
payload:
- type: icon
value: compost
x: 0
"y": 5
color: >-
{% if states('sensor.next_biomuell') | int == 1%}red{% else
%}black{% endif %}
size: 50
- type: text
value: Biotonne
font: ppb.ttf
x: 50
"y": 5
size: 18
- type: text
x: 50
"y": 25
font: ppb.ttf
size: 15
value: >-
{% if states('sensor.next_biomuell') == 'unknown' %}??? {% elif
states('sensor.next_biomuell') | int == 0 %}Heute! {% elif
states('sensor.next_biomuell') | int == 1 %}Morgen! {% else %}in
{{states('sensor.next_biomuell')}} Tagen {% endif %}