Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's bin day πŸ“… and the bin has been emptied πŸš› notification ⏰ #53

Closed
Tracked by #52
jcallaghan opened this issue May 8, 2020 · 7 comments
Closed
Tracked by #52

Comments

@jcallaghan
Copy link
Owner

jcallaghan commented May 8, 2020

Objective

I work from home a lot and it is not unusual to be on calls for most of the day. Sometimes this leads to bin mix up where someone takes the wrong bin or worse where you're left with no bin at all πŸš”.

As I know what day my bins are being updated through my calendar integration I added a vibration sensor to each bin lid. On bin day when this is turned upside down 180Β° degrees or received significant vibration, I send a notification to say the bin has been emptied. This allows me to almost immediately fetch it back in without forgetting about it or it going astray.

Ingredients

  • Aqara vibration sensor
  • Home Assistant automation
  • Companion app
  • HTML5 notifications
  • Google Calendar integration

Related

@jcallaghan
Copy link
Owner Author

jcallaghan commented Jun 8, 2020

Calendar integration

I have copied in our local rubbish and recycling bin collection schedule as reoccurring events in my calendar. I adjust the occurrence accordingly to account for public holidays etc.

  • ⬜ Grey - Non-recyclable waste
  • ⬛ Black - Mixed recycling (cans, tins & bottles)
  • 🟦 Blue - Paper and card
  • 🟩 Green - Food and garden waste

Using the Google Calendar integration I am able to add a search pattern search: '* bin' which creates a binary_sensor that becomes active on any day where there is a matching event in my calendar.

image

Additionally, I have created a secondary template sensor that displays the name of the next event that has the event details as attributes.

platform: template
sensors:
  calendar_house_bin:
    friendly_name: 'Next Bin'
    value_template: >
      {{ state_attr('calendar.house_bin','message') }}
    attribute_templates:
      description: >-
        {{ state_attr('calendar.house_bin','description') }}
      location: >-
        {{ state_attr('calendar.house_bin','location') }}
      start_time: >-
        {{ state_attr('calendar.house_bin','start_time') }}
      end_time: >-
        {{ state_attr('calendar.house_bin','end_time') }}
    icon_template: mdi:trash-can

image

I use information from this template sensor in my text-to-speech notifications.

@jcallaghan
Copy link
Owner Author

jcallaghan commented Jun 8, 2020

Notification templating

While I was creating the automation I use the Developer Tools > Template tool to evaluate my conditions and templates.

During this exercise, I noticed the last_triggered date isn't taking into account +1hr summertime. Need to dig into this some more but it might be my config or a bug.

image

Template

Vibration sensor last changed: 
{{ states.binary_sensor.black_bin_vibration.last_changed }}

Bin day:
{{ states('calendar.house_bin') }} 
{{ states('sensor.calendar_house_bin') }}

Is this great than 4 hours?
{{ (as_timestamp(states.sensor.date_time.last_changed) - 
(as_timestamp(states.binary_sensor.black_bin_vibration.last_changed))) > 14400 }}

Have 25 minutes passed since the last update?
{{ (as_timestamp(states.sensor.date_time.last_changed) - 
(as_timestamp(state_attr('automation.bin_notification','last_triggered')))) > 1500 }}

Notification:
The {{ states('sensor.calendar_house_bin') | lower }} is being collected today.


*** summertime bug *** 

This triggered 10 minutes ago but shows as 70 minutes ago
{{state_attr('automation.bin_notification','last_triggered')}}

Time now:
{{states('sensor.date_time') }}

Output

Vibration sensor last changed: 
2020-06-07 21:21:22.863079+00:00

Bin day:
off 
🟦 Blue Bin

Is this great than 4 hours?
True

Have 25 minutes passed since the last update?
False

Notification:
The 🟦 blue bin is being collected today.


*** summertime bug *** 

This triggered 10 minutes ago but shows as 70 minutes ago
2020-06-08 11:40:20.124624+00:00

Time now:
2020-06-08, 12:52

@CCOSTAN
Copy link

CCOSTAN commented Jun 8, 2020

Would love to see a picture of the actual bin cover. :)

@jcallaghan jcallaghan changed the title Bin emptied notification It's bin day πŸ“… and the bin has been emptied πŸš› notification ⏰ Jun 10, 2020
@jcallaghan
Copy link
Owner Author

jcallaghan commented Jun 10, 2020

Bin emptied templating

Again to test my automation I use the template tool to help see what data I have.

image

Template

Bin day?
{{ states('calendar.house_bin') }}

Next bin:
{{ states('sensor.calendar_house_bin') }}

Orientation X: {{ state_attr('binary_sensor.black_bin_vibration','orientation')[0] | int }} 
Open: 7; 
Closed: 6;

Orientation Y: {{ state_attr('binary_sensor.black_bin_vibration','orientation')[1] | int }} 
Open: -3; 
Closed: -2;

Orientation Z: {{ state_attr('binary_sensor.black_bin_vibration','orientation')[2] | int }} 
Open: -82; 
Closed: -83;

Vibration: {{ state_attr('binary_sensor.black_bin_vibration','vibrationstrength') }}
Idle: ~6
Slammed: ~45

Tilt: {{ state_attr('binary_sensor.black_bin_vibration','tiltangle') }}
Open: 360
Partial Open:  ~45
Closed: ~8

Output

Bin day?
off

Next bin:
🟦 Blue Bin

Orientation X: 6 
Open: 7; 
Closed: 6;

Orientation Y: -2 
Open: -3; 
Closed: -2;

Orientation Z: -83 
Open: -82; 
Closed: -83;

Vibration: 49
Idle: ~6
Slammed: ~45

Tilt: 360
Open: 360
Partial Open:  ~45
Closed: ~8

@jcallaghan
Copy link
Owner Author

jcallaghan commented Jun 10, 2020

Sensor attached to bin lid

I can’t say I’ve taken a picture of the inside of a bin before but in the interest of sharing...here is a picture @CCOSTAN.

image

The Retreat automation moved this from In progress to Done Jun 10, 2020
@jcallaghan
Copy link
Owner Author

Consider adding a more visual card https://github.com/bruxy70/Garbage-Collection/.

@atv2016
Copy link

atv2016 commented Jun 26, 2022

@jcallaghan Bin a while i see, but ..still working ok for you ?

The bin guys here usually take the bin up the street for a bin, so the sensor will go out of range no doubt. How does one deal with that? Does the 180' flip get registered upon return ?

Also, i guess you need to place the sensor at the right spot, but the shaking up in the truck is pretty brutal, no issues with the sensor falling off yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
The Retreat
  
Done
Development

No branches or pull requests

3 participants