adonno / Home-AssistantConfig

๐Ÿ  My Home Assistant config & docs (Hass.io based). Be sure to ๐ŸŒŸ this repository for updates!
155 stars 16 forks source link

Smarter Diaper Trash bin #6

Closed adonno closed 4 years ago

adonno commented 4 years ago

Objective

We have a baby diaper trash bin and we can't see when it's full. Based on that id' like to get a notification to let me know before it's full so I don't have to stick up my head in it :poop: .

adonno commented 4 years ago

First I had to identify how to count the baby diapers. I used an Aqara open/close sensor and stuck it to the axle, I had to identify a spot where it could easily be mounted and it would not be in the way of the mechanism.

jcallaghan commented 4 years ago

I love this. Such a simple application and use of these sensors. It's also a great example of proactive chore maintenance and I bet great for WAF ๐Ÿ˜‹

adonno commented 4 years ago

I created a counter in Home-assistant to keep track of the diapers. and then an automation to increment it on every state change that is either close and open (do not track EVERY state change since a disconnection or a battery update would increment the counter)

Counter

---
counter: 
  diaper_counter:
    initial: 0
    step: 1
    icon: mdi:emoticon-poop

Automation

---
- id: '1579629145305'
  alias: Increment diapers counter
  description: ''
  trigger:
  - entity_id: binary_sensor.openclose_19
    from: 'on'
    platform: state
    to: 'off'
  - entity_id: binary_sensor.openclose_19
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - entity_id: counter.diaper_counter
    service: counter.increment
adonno commented 4 years ago

Whenever the bin is emptied the counter needs to be reset. I've thought about automating it but found no effective way to do it, so I just added an Aqara button which on a button press resets the counter via an automation

Automation:

- id: '1579629681167'
  alias: Reset diaper counter
  description: ''
  trigger:
  - device_id: 98bb594b8fff4e4ca78656d95a266519
    domain: deconz
    platform: device
    subtype: turn_on
    type: remote_button_short_press
  condition: []
  action:
  - entity_id: counter.diaper_counter
    service: counter.reset
adonno commented 4 years ago

Whenever a defined threshold (15) has been reached a notification should be sent to our phones as well as on each additional item until the counter has been reset

Notifications This is done via NodeRed

Threshold Reached

image

Counter Reset image

jcallaghan commented 4 years ago

Do you need to lift the lid to empty it? If so could you automate based on the sensor being open for a period longer than you would when normally using it?

adonno commented 4 years ago

Do you need to lift the lid to empty it? If so could you automate based on the sensor being open for a period longer than you would when normally using it?

Yes but i canโ€™t take that into account or iโ€™d have to add a second open/close sensor Since the bin works in both positions so Open -> 1st diaper Close -> 2nd diaper Open -> 3rd diaper

And so on

adonno commented 4 years ago

Display diaper count on switch This one is a bit more tricky to explain. The bin stands next to one of our KNX light switches. These have a screen to display additional information like time, temperature or whatever additional data one would like to display. here you can see a demo video

I won't explain how KNX works but basically you have to set up a group address like "4/2/30" and the specific function of that switch will be added to that group. I then exposed the value of the "counter" to KNX into the specific group

knx:
  expose:
    - type: 'percent'
      entity_id: counter.diaper_counter
      address: '4/2/30'

I had to use percent since the switch wouldn't allow for a plain text field

adonno commented 4 years ago

Flash red light on the wall switch when threshold reached

As explained in the previous comment these switches can display some nice information. You can also define the LEDs.

Here I used Node-Red again since I had it already set up for my mobile notifications and I didn't want to create an additional entity in HA. (see here) In Node-Red I used a Plugin called UltimateKnx. Used a switch node to change the value "15" to "true" and value 0 to "false" image