Laundry Sensors with NodeMCU and Home Assistant

Update on my side: after much internal debate, I decided to skip the washed-washing/dried-drying approach, as I couldn’t find a reliable set of thresholds that would enable me to confidently determine that the machine is “washing” vs “washed” for my machines. What I was able to do, however, is determine if the wash/dry is completed.


Determining if the Washer/Dryer is Complete

I created a separate input boolean as a HA helper to hold the “washer completed” and “dryer completed” value. Creating this as an input boolean allowed me to manually turn it on/off for debugging or runtime purposes. Once vibrations are detected, my automation runs and once a specified time threshold has passed (10 minutes in my case) the switch is flipped to “on”. If the door is opened, the switch is flipped back to off, as it’s assumed that you opened the door and moved the laundry. I did not see an easy way to do this through ESPHome, although I do plan to keep trying, as I would like to use this logic to update the text sensor to “washing” when vibrations are detected and “washed” if the timeout passes.


Visual Notifications Approach Overview

Originally, I had planned on setting up push notifications and voice alerts from Alexa, but my wife had other plans (which I actually like better, to be honest). What she wanted was a light notification, either through our Philips Hue lights or something else, that would remind us. I didn’t want the Philips Hue bulbs to do it, as that could easily disrupt the ambience of our home or interrupt whatever we’re doing rather than allowing us to make a decision as to whether we want to wait a few minutes before moving the laundry, so instead I decided to install a WLED strip behind our TV and change the colors to reflect the notification. For those interested in doing something similar, while I know API calls can be used to programmatically set the palette colors for the lights (and while I confess that’s the route I should have taken), I decided to be lazy and predefine my palettes as presets. I used a cyan/blue color for when the wash is done, orange when the dryer is done, and both rotating around the TV when both are done.


Automations Created in Home Assistant

Overall, I created 4 automations - 2 for the washer and 2 for the dryer - to manage the logic for my setup. Each machine has a “[Washer/Dryer] Completed” automation and a *"[Washer/Dryer] Door Opened" automation. The Machine Completed automation manages the helper I mentioned earlier and turns on the correct palette once the washer/dryer has finished, while the Door Opened automation tells the WLED to go back to the default color/palette once the door has been opened.

Below are the automations I created for the Washer. Note you would use the same ones for the dryer, just change around the entities and WLED preset IDs, as needed.

The following is my Washer Completed automation:

alias: Laundry Washer Activity Complete
description: ''
trigger:
  # run when the washer senses that it's washing
  - platform: state
    entity_id: sensor.washer
    to: Washing
condition: []
action:
  # wait 10 minutes after washer is detected to be washing before running the logic
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  # loop until the washer has been idle for 10 minutes (inclusive of the delay run before the loop)
  - repeat:
      until:
        - condition: state
          entity_id: sensor.washer
          state: Idle
          for:
            hours: 0
            minutes: 10
            seconds: 0
            milliseconds: 0
      sequence:
        # wait 30 seconds between checks to see if the washer is complete
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
  # once the washer is complete, turn on the washer_complete toggle
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.washer_complete
  # run the logic until the washer has been emptied (washer_complete is turned off)
  - repeat:
      until:
        - condition: state
          entity_id: input_boolean.washer_complete
          state: 'off'
      sequence:
        - choose:
            - conditions:
                # only run the logic every 40th loop, i.e. every 10 minutes (as the delay for this loop is 15 seconds)
                - condition: template
                  value_template: '{{ repeat.first or repeat.index % 40 == 0 }}'
              sequence:
                - choose:
                        # if the dryer is complete also, turn on the preset for both machines being complete, otherwise just turn on the preset for the washer being complete (this logic could be improved by checking the state of the WLED or creating a second helper to avoid edge-case issues)
                    - conditions:
                        - condition: state
                          entity_id: input_boolean.dryer_complete
                          state: 'on'
                      sequence:
                        - service: wled.preset
                          target:
                            entity_id: light.living_room_notification_lights
                          data:
                            preset: 5
                  default:
                    - service: wled.preset
                      target:
                        entity_id: light.living_room_notification_lights
                      data:
                        preset: 3
          default: []
        - delay:
            hours: 0
            minutes: 0
            seconds: 15
            milliseconds: 0
# if the wash is detected to be washing again before the automation completes then restart it because the washer is still running
mode: restart

The following is my Washer Door Opened automation:

alias: Laundry Washer Door Opened
description: ''
trigger:
  # run the automation when the washer door is opened
  - type: opened
    platform: device
    device_id: 265e95a3d9f77fe6997279f3d2496d85
    entity_id: binary_sensor.washer_door
    domain: binary_sensor
condition: []
action:
  # turn off the washer_complete helper, as the door has been opened (assume the washer is being emptied)
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.washer_complete
  # if the dryer hasn't yet been moved, set the dryer complete preset, otherwise set the default preset
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.dryer_complete
            state: 'on'
        sequence:
          - service: wled.preset
            target:
              entity_id: light.living_room_notification_lights
            data: {}
    default:
      - service: wled.preset
        target:
          entity_id: light.living_room_notification_lights
        data:
          preset: 1
# since these run right away, there's no need to restart if a second door opened is detected
mode: single

If I can get that “washing” state figured out for ESPHome I’ll post another update.

Beyond that, good luck with your project!