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 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.
The body is black and has the necessary holes and nubs to fit the USB cable, microswitch and lid-hinge.
The hinge is translucent and will fit to the nubs on the body, forming a hinge.
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 touching 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.
It runs ESPhome and is connected to Home Assistant via MQTT.
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 can be downloaded here.
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 MQTT command is sent to the notifier to set the LEDs to a specific color.
Some details of the action in the Home Assistant automation:
alias: Wastebin notifier
description: ''
trigger:
- at: '18:00'
platform: time
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.circulus_berkel_morgen
state: gft
sequence:
- data:
payload: '{"state":"ON","brightness":191,"color":{"r":0,"g":255,"b":0}}'
topic: waste/notifier/light/lid/command
service: mqtt.publish
- conditions:
- condition: state
entity_id: sensor.circulus_berkel_morgen
state: pmd
sequence:
- data:
payload: '{"state":"ON","brightness":255,"color":{"r":255,"g":127,"b":0}}'
topic: waste/notifier/light/lid/command
service: mqtt.publish
- conditions:
- condition: state
entity_id: sensor.circulus_berkel_morgen
state: papier
sequence:
- data:
payload: '{"state":"ON","brightness":191,"color":{"r":0,"g":0,"b":255}}'
topic: waste/notifier/light/lid/command
service: mqtt.publish
- conditions:
- condition: state
entity_id: sensor.circulus_berkel_morgen
state: restafval
sequence:
- data:
payload: '{"state":"ON","brightness":191,"color":{"r":255,"g":255,"b":255}}'
topic: waste/notifier/light/lid/command
service: mqtt.publish
default:
- data:
payload: '{"state":"OFF","brightness":191,"color":{"r":255,"g":255,"b":255}}'
topic: waste/notifier/light/lid/command
service: mqtt.publish
mode: single
When the lid is pressed and the microswitch is triggered, it is sent as a notification on an MQTT topic 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 - lid pressed
description: ''
trigger:
- platform: state
entity_id: binary_sensor.wastebin_notifier_lidswitch
from: 'off'
to: 'on'
condition: []
action:
- service: mqtt.publish
data:
payload: '{"state":"OFF","brightness":191,"color":{"r":255,"g":255,"b":255}}'
topic: waste/notifier/light/lid/command
mode: single
I hope this inspires you to create awesome things!
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.