Skip to content

lostinthebuild/S01E02-state-machine-washer-notifier-II

Repository files navigation

Washer Notifier

Source code and configuration accompanying the videos
Part 1 (hardware, esphome etc) : https://www.youtube.com/watch?v=atD7VcXrfWY
Part 2 (home assistant automation, appdaemon etc) : https://youtu.be/t5eoUQmB4SA

Leaving the clothes in the washer for too long? Need a way to detect when the washer is done? In this video I walk you through the process I went through to create such a device and the related automation code.

I build a little sensor using an ESP-01 and an accelerometer (MPU6050) that send off data to my home assistant instance. The programming was done using ESPHome. A Home Assistant automation then takes these readings and detects when the washer is complete and announces over Amazon Echo and Google Home devices in the home.

In part I, I wrote a little python script to read the sensor readings from ESPHome and dump it into a CSV file. Using a Jupyter notebook, I then load this CSV file and plot the sensor values. This made it easy to try out various algorithms to identify the washer cycles. I also explain (briefly) the process of converting this algorithm into a custom filter that acts on the sensor readings in ESPHome.

In part II, I walk you through the design and implementation of a state machine in Home Assistant using AppDaemon to identify the state of the washer from the vibration sensor values. When the automation detects that the washer is done, it send notifications (as broadcasted messages) over Google Home and Amazon Echo/Alexa.

All the code, configurations and schematics are in the repository.

State Diagram

State Diagram

dot diagram viewer

Graphviz Diagram

digraph G {
    graph [fontname = "DigitalStrip BB"];
    node [fontname = "DigitalStrip BB", fillcolor="#EEEEEE;0:#D8D8D8;1.0", style=filled, gradientangle=270];
    edge [fontname = "DigitalStrip BB"];
    IDLE->MAYBE_WASHING[label="wash, spin"];
    ERROR->MAYBE_WASHING[label="wash\n  spin"];
    DONE->MAYBE_WASHING[label="   wash, spin"];
    MAYBE_WASHING->WASHING[label="timeout 1 min"];
    MAYBE_WASHING->MAYBE_IDLE[label="idle"];
    MAYBE_IDLE->IDLE[label="timeout 5 min"];
    MAYBE_IDLE->MAYBE_WASHING[label="wash\n spin"];
    WASHING->SPINNING[label="  spin"];
    WASHING->MAYBE_ERROR[label="idle"];
    SPINNING->MAYBE_DONE[label=" idle  "];
    SPINNING->WASHING[label="\n\n  wash"];
    MAYBE_DONE->WASHING[label="  wash"];
    MAYBE_DONE->SPINNING[label="\n\n  spin"];
    MAYBE_DONE->DONE[label="timeout 8 min"];
    MAYBE_ERROR->WASHING[label="wash"];
    MAYBE_ERROR->SPINNING[label="spin"];
    MAYBE_ERROR->ERROR[label="\n\ntimeout 75 min"];
}

Additional info

In case you are planning to build this, here are a few things to help you along the way.

  1. The vibration levels and the timeouts between the various states is highly dependent on the washer, how you place the sensor and other factors. So you will need to tweak it based on actual readings from the washer.
  2. Configure influxdb and grafana with home assistant and setup a (dashboard for the washer)[grafana-washer-dashboard.png] related sensors. It was a tremendous help for me to tweak the thresholds and timeouts. Json export of my dashboard.
  3. Stick with it for a couple of days while you tweak the values. Try different types of wash cycles (hot, cold, cotton, whatever else you use in your home) and tweak the values. It was helpful for me to configure the notifications to just come to me (I used the telegram integration) while I was working on it. Once it is setup properly, it is zero maintenance and works beautifully.
  4. For the privacy conscious amoung us, use a different notification mechanism that is more privacy friendly like a buzzer or even an offline text to speech based one. Drop me a note if you are interested seeing a build video for one. I have some plans for such a device in my notes.

Improvements

You could add a door open sensor using one of those reed switches or something similar and wire it to the ESP-01. Modify the state machine to take this into account and have a "pending_clearance" 😊 or something similar and send out notifications periodically until the washer is emptied.

Links:

Aliexpress: