Wastebin Notifier
We have multiple containers for different types of waste.
Green = compost
Orange = plastic
Blue = paper
Gray = all other
One has to be places at the curb in some ingenious schedule. The collection company publishes an API with the collection schedule per address. Why not put it to use?
Why not build a small notifier that signals what bin will be collected?
Why not have that notifier be the shape of a bin with a lid that will light up in the color of the bin? And have a way so signal that the bin has been placed at the curb?
My house uses HomeAssistant with ESPhome devices, so let’s build from there.
The build
3d design
The model is based on a model of Jigsawnz. I made a new model that will be able to fit some electronics to it. The model can be found on Thingiverse. It consists of three parts.
Body
The body is black and has the necessary holes and nubs to fit the USB cable, microswitch and lid-hinge.
Lid
The hinge is translucent and will fit to the nubs on the body, forming a hinge.
Electronics
The electronics part will house the electronics inside and has LED’s glued on top. It is modular so all electronics can be taken out as one part.
The notifier has a Wemos D1 Mini inside with five WS2812 RGB LED’s and a microswitch. The microswitch is hot-glued in the body and is activated when pressing the lid. The datapin of the LED’s is connected to GPIO4 (D2), the switch is connected between GPIO0 and GPIO2. GPIO2 provides the signal that will be picked up by GPIO0. By setting GPIO2 to “0”, I can disable the switch.
Firmware
It runs ESPhome and is connected to Home Assistant via the Home Assistant API.
The definition of the LEDs:
light:
- platform: fastled_clockless
chipset: WS2812
rgb_order: GRB
pin: GPIO4
num_leds: 5
name: wastebin_lid
The definition of the switch:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
name: wastebin_lidswitch
filters:
# debounce delay
- delayed_off: 10ms
The definiton of the enable/disable of the switch:
switch:
- platform: gpio
pin: GPIO2
name: wastebin_lidswitch_disable
restore_mode: ALWAYS_OFF
The complete firmware definition can be downloaded as this file.
Integration
An automation in Home Assistant checks daily the status of the API of our waste collector using pyppin’s AfvalBeheer plugin https://github.com/pippyn/Home-Assistant-Sensor-Afvalbeheer. Depending on the returned value, an API command is sent to the notifier to set the LEDs to a specific color.
It also adds an entry to my to-do list.
Some details of the action in the Home Assistant automation:
alias: Wastebin notifier
description: ""
mode: single
triggers:
- at: "12:00:00"
trigger: time
actions:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.circulus_gft
attribute: Days_until
above: 0
below: 2
sequence:
- data:
brightness: 255
color_name: green
target:
entity_id:
- light.esp_5a098d_lid
action: light.turn_on
- data:
item: Groene container bij de weg
target:
entity_id: todo.to_do
action: todo.add_item
- conditions:
- condition: numeric_state
entity_id: sensor.circulus_pmd
above: 0
below: 2
attribute: Days_until
sequence:
- data:
color_name: orange
brightness: 255
target:
entity_id:
- light.esp_5a098d_lid
action: light.turn_on
- data:
item: Oranje container bij de weg
target:
entity_id: todo.to_do
action: todo.add_item
- conditions:
- condition: numeric_state
entity_id: sensor.circulus_papier
attribute: Days_until
above: 0
below: 2
sequence:
- data:
color_name: blue
brightness: 255
target:
entity_id:
- light.esp_5a098d_lid
action: light.turn_on
- data:
item: Blauwe container bij de weg
target:
entity_id: todo.to_do
action: todo.add_item
- conditions:
- condition: numeric_state
entity_id: sensor.circulus_restafval
attribute: Days_until
above: 0
below: 2
sequence:
- data:
color_name: white
brightness: 191
target:
entity_id:
- light.esp_5a098d_lid
action: light.turn_on
- data:
item: Grijze container bij de weg
target:
entity_id: todo.to_do
action: todo.add_item
default:
- data: {}
target:
entity_id:
- light.esp_5a098d_lid
action: light.turn_off
- if:
- condition: template
value_template: |-
{% if (is_state_attr('sensor.circulus_gft', 'Days_until', 0)
or is_state_attr('sensor.circulus_papier', 'Days_until', 0)
or is_state_attr('sensor.circulus_pmd', 'Days_until', 0)
or is_state_attr('sensor.circulus_restafval', 'Days_until', 0)) %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
then:
- metadata: {}
data:
item: Container ophalen
target:
entity_id: todo.to_do
action: todo.add_item
When the lid is pressed and the microswitch is triggered, it is sent as a notification to Home Assistant and the LED’s are turned off. This is an indication that the bin has been places at the curb.
alias: Wastebin-notifier lidswitch pressed
description: ""
mode: single
triggers:
- type: turned_on
device_id: 07844aaa54d8f8d7a508e030a1e3a795
entity_id: binary_sensor.esp_5a098d_lidswitch
domain: binary_sensor
trigger: device
conditions: []
actions:
- data: {}
target:
device_id: 07844aaa54d8f8d7a508e030a1e3a795
action: light.turn_off
I hope this inspires you to create awesome things!
Future plans
I am planning to equip the bins with a tilt switch and have that signal sent over LoRaWAN back to HomeAssistant. When the bin is flipped upside-down (eg. when the bin is emptied), this status is sent back and can be used to blink the lid of the notifier as an indication that the empty bin can be retrieved from the curb.