DIY-Viking

If you want something done right…

Take out the trash reminder

I have put a Bluetooth Light Energy (BLE) Beacon on my trash can, and use the signal strength to determine if the distance between my Bluetooth unit and the beacon has changed. I have tried various solutions to read the values from the beacon:

1. iBeacon tracker integration with Bluetooth-proxy on a Shelly 4PM.

2. Theengs Gateway running on a Raspberry Pi3B.

3. Open MQTT Gateway running on a ESP32.

The best solution is to use a device more or less in line with the 2 positions the trashcan might have. In my case it looks like this:

1. Shelly 4PM Bluetooth-proxy.

2. Raspberry Pi3B.

3. ESP32.

I : “HOME” position of the trashcan.

II : “AWAY” position of the trashcan.

The position of the Bluetooth-proxy is not the good one. The angle between the Shelly 4PM and the two positions of the trashcan is such that change in signal strength is not enough to give a reliable variation result.

The position of the Raspberry Pi3B is the ideal one, since a straight line from the Pi to the “Away”-position of the trashcan goes through the “Home”-position. However: when the garage-door is open the signal strength varies (also the case with the Bluetooth-proxy). In the summer we often leave the door open, and that could cause false positives. I did use a vibration sensor to only detect signal strength-variation when the trashcan was “moving”, and that worked quite good.

I have finally decided to use the ESP32 running OpenMQTTGateway. The ESP32 is far more power efficient than the Pi 3B. I moved tasks previously running on the Pi 3B over to my Proxmox-server, and have decommissioned it. In addition, the ESP32 is outside the house (under the roof), and thereby not affected by the garage door being open or closed.

I have 4 sensors defined in Home Assistant:

Signal strength MQTT-sensor:

# OpenMQTTgateway - ESP32
- name: "Poubelle RSSI OMG"
  device_class: signal_strength
  unique_id: "9f5a4ae9-e782-4c73-890b-d19088edef15"
  state_topic: "home/OMG_ESP32_BLE/BTtoMQTT/fda50693a4e24fb1afcfc6eb07647825"
  value_template: "{{ value_json.rssi }}"
  unit_of_measurement: "dB"
  state_class: measurement
  qos: 0

2 Statistics sensors that give mean values for the signal strength over last 6 minutes and last 8 hours. The RSSI value of the BLE Beacon is jumping up and down all the time, and the best way to get a reliable value of the variation is to use the median values.

  # OpenMQTTgateway
  - platform: statistics
    name: "Poubelle rssi last 6 minutes OMG"
    unique_id: "942506ce-209e-4a25-bf04-5b03a098e20a"
    entity_id: sensor.poubelle_rssi_omg
    state_characteristic: mean
    max_age:
      minutes: 6

  - platform: statistics
    name: "Poubelle rssi last 8 hours OMG"
    unique_id: "952fdc5f-e157-4916-a737-744be2bab2bf"
    entity_id: sensor.poubelle_rssi_omg
    state_characteristic: mean
    max_age:
      hours: 8

Template sensor:

{{ ((states('sensor.poubelle_rssi_last_6_minutes_omg') | float) - (states('sensor.poubelle_rssi_last_8_hours_omg') | float)) }}

An automation is triggered when the template sensor value is over or under a certain threshold, and toggles the position of the trashcan to Home or Away respectively.

My dashboard (message only visible when the trashcan is on the sidewalk):

We have to set out the trashcan before 06:00 Mondays, and I have an automation running Sunday evening 23:00 to check if the trash has been set out. Home Assistant sends a notification ONLY if the trashcan is not on the sidewalk:

Hägar

Leave a Reply

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

Back to top
WordPress Appliance - Powered by TurnKey Linux