Laundry automation

Sidebar, I have been an on again/off again user of HA for a long time, but I am really getting serious about it now, and I am trying to move as much of my other automation into HASS as it makes sense.

Background

I have a binary sensor on the washer and the dryer in my laundry room that are True when the machine is running (one for each machine).

I have a python script that I run separately to send a slack message when the washer or dryer finishes, and I have an extra gate to notice when one is done, but not the other, which doesn’t send a slack message.

The Question

How do I achieve this same functionality, or better in HA?

I would like to have the UI show some other state from the result of these calculations. For example, “Washing”, “Running”, “Needs Change”, “Clean”, or “Idle”.

I am not sure which pieces need to come together for this. Automation? Scripts? Events? How do I make a new state?

More thoughts.

Here’s one thing I could do:

If washer turns off, and dryer is already off:

  • Set the status (how do I make this status to change in this automation?) to “Needs Change”
  • Send slack message
  • Wait 60 mins
  • Reset state to “Idle”

If dryer turns off, and washer is already off:

  • Set the status to “Clean” (But somehow only when the washer wasn’t running?)
  • Send slack message
  • Wait 60 mins
  • Reset state to “Idle”

Then what happens when the washer finishes before the dryer? Then we need it to go to “Needs Change”.

I feel like this will end up being like 15 lines of config, but I’m not sure how to frame this in the language of HA.

Thanks for reading.

Unless the laundry equipment has an API (like LG and some others), the usual way of determining what the equipment is doing is by inferring it from its power consumption. Otherwise, a vibration sensor alone won’t provide much insight into whether a washer is filling/washing/spinning/draining/rinsing etc.

I posted what I did to determine my washer’s operating states here (see the second half of the post). I’m using a Wemo Insight Smart Plug (that I got for free due to a pricing error) to acquire the washer’s power consumption. Using the technique I described, I can detect each operating phase and trigger a notification when the entire wash cycle has finished (or at any step in the process). To be honest, I don’t need it but it seemed like a fun way to use that free plug. :slight_smile:

As for the electric dryer, it’s a North American 220VAC version so there are no energy monitoring smart plugs available in that form factor. I have some spare current clamps that, I suppose, I could use to monitor the dryer’s power consumption (minimally, on/off) but I haven’t found the time to do that (yet). Ideally, a whole-home energy monitoring system would report consumption per (desired) circuit but it’s not a cheap proposition.

1 Like

Thank you for the quick reply,

I don’t have a problem with the binary sensor. I have that working already. I have an esp8266 attached with a photoresistor glued to the “on” led for each machine. It publishes a 1, or 0 to an mqtt topic, and I have that being read into HA.

What I’m wondering about is to take that raw data (running, not running) and automating another state (like, “Needs Change” when the washer has finished (and has wet clothes inside)).

Is there a way to make an “entity” that is only controlled by automation and doesn’t directly represent any actual hardware?

1 Like

If you check the post I linked, it explains how I used an input_select to track the washer’s current operating state. In a perfect world, I could have used just a Template Sensor but my post explains why that wasn’t possible (I had to use both a Template Sensor and an input_select controlled by an automation). Regardless of which one you use (or both) when the entity changes state, that’s what can serve to trigger an automation to report the equipment’s status.

What I don’t understand is how you intend to infer the washer’s many states from a single binary_sensor that can only tell you if it’s running or not. Or does the washer have several indicator lamps, one for each operating state, and you have multiple binary_sensors reporting which state is currently active?

1 Like

OK. I have to confess I did not read that post the first time, because I thought you were trying to help me figure out the hardware. Now that I’ve read it, I have it on my list to go read about template sensors and input_select.

I can’t determine what “subcycle” the washer is in. I’m not interested in states related to rinsing or spinning, for example. (well, it would be cool, but I don’t have that kind of sensor). I am more interested in the user’s perspective.

  • If the washer is finished, but the dryer isn’t, then I don’t need to go to the basement yet. I will just wait for the dryer to finish.
  • If the washer and dryer both finished, then I need to go take the dry clothes out, and move the wet clothes to the dryer.
  • If I didn’t run the washer, and the dryer is finished, then I have clean clothes in the dryer, and probably no clothes in the washer. So I don’t have to do anything immediately, but It’s still good to know it’s done.

These are the states I think I need:

  • Washing: only the washer is running
  • Running: The washer and dryer are both running (honestly, there isn’t much benefit to splitting washing and running).
  • Needs Change: The washer and dryer are done, and there are probably clothes in the washer, because it recently finished
  • Clean: The washer wasn’t running recently, but the dryer finished recently.
  • Idle: No machines were running recently.

If you have two binary_sensors (one for each of the two machines) then there are 22 = 4 states they can report. You listed five states so I’m not sure how you will infer the fifth one. Perhaps it’s based on the order, or timing, of the states?

1 Like

The order is important, yes. In the case where nothing is running, the difference in the states is based on which of the two states were running.

I think I can do this with two input_select. One is the pretty output state. The other is an internal state to store the machine state in between when one finishes early:

on falling edge of washer:
 If the dryer is still running:
   set the internal state to "washer wet"
 else
   set the external state to "Needs Change"

on falling edge of the dryer:
 if washer is still running:
   set the internal state to "dryer dry"
 else
   if the internal state is "washer wet"
     set the external state to "Needs Change"
   else
     set the external state to "Clean"

on rising edge of washer:
  set the external state to "Running"

on rising edge of dryer:
  set the external state to "Running"

Then the only thing that’s left is getting back to idle. I need something that is similar to “In the last 60 mins, the washer and dryer have both been off: set external state to idle”

Bookmarked for next project.

Here’s a rough translation of your pseudo-code into Home Assistant’s automations. I didn’t quite understand your concept of internal/external state so I just threw everything into the same input_select. Clearly what I’m providing here is not a turn-key solution but simply a starting point for you to work out the ‘laundry logic’ you require.

Input Select

input_select:
  laundry:
    name: Laundry State
    options:
      - 'running'
      - 'washer wet'
      - 'dryer dry'
      - 'needs change'
      - 'clean'

Automations

- alias: Washer Off
  trigger:
  - platform: state
    entity_id: sensor.washer
    from: 'on'
    to: 'off'
  action:
  - service: input_select.set_option
    data:
      entity_id: input_select.laundry
      option: >
        {{ 'washer wet' if is_state('sensor.dryer', 'on') else 'needs change' }}

- alias: Washer Off
  trigger:
  - platform: state
    entity_id: sensor.dryer
    from: 'on'
    to: 'off'
  action:
  - service: input_select.set_option
    data:
      entity_id: input_select.laundry
      option: >
        {% if is_state('sensor.washer', 'on') %}
          dryer dry
        {% elif is_state('input_select.laundry', 'washer wet') }}
          needs change
        {% else %}
          clean
        {% endif %}

- alias: Washer or Dryer On
  trigger:
  - platform: state
    entity_id: sensor.washer
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: sensor.dryer
    from: 'off'
    to: 'on'
  action:
  - service: input_select.set_option
    data:
      entity_id: input_select.laundry
      option: 'running'

The input_select goes into the configuration.yaml file and, if your automations reside in a separate automations.yaml file (which I believe is the default nowadays) put them there.

Here is where I ended up with these automations.

This automation just sets the state to “running” when we start either machine:

- id: '1608078034049'
  alias: laundry-running
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.washing
    to: 'on'
    from: 'off'
  - platform: state
    entity_id: binary_sensor.drying
    to: 'on'
    from: 'off'
  condition: []
  action:
  - service: input_select.select_option
    data:
      option: running
    entity_id: input_select.laundry_state
  mode: single

Automation when the washer finishes (Doesn’t account for the state of the dryer):

- id: '1608077513039'
  alias: laundry-washer-done
  description: What to do when the washer is done
  trigger:
  - platform: state
    entity_id: binary_sensor.washing
    to: 'off'
  condition: []
  action:
  - service: input_select.select_option
    data:
      option: wet-clothes
    entity_id: input_select.laundry_state
  - service: notify.notify
    data:
      message: The washer is finished
  - service: script.house_talk
    data:
      message: There are wet clothes in the washer.
  mode: single

This script runs when the dryer finishes. This also returns the state to idle in an hour (There is a flaw in this):

- id: '1608077810900'
  alias: laundry-clean-clothes
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.drying
    to: 'off'
    from: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.washing
    state: 'off'
  - condition: not
    conditions:
    - condition: state
      entity_id: input_select.laundry_state
      state: wet-clothes
  action:
  - service: input_select.select_option
    data:
      option: clean-clothes
    entity_id: input_select.laundry_state
  - service: notify.notify
    data:
      message: The clothes are clean
  - service: script.house_talk
    data:
      message: There are clean clothes in the dryer
  - delay: 01:00:00
  - service: input_select.select_option
    data:
      option: idle
    entity_id: input_select.laundry_state
  mode: restart

This is working great for me and my family. We have the display show the state (idle/running/wet/clean) and the individual states. The notification script is separately doing some obnoxious things like toggling lights and making tts on our chromecast.

There is a weakness though, which is, if the washer ever finished first, the dryer finishing will clear the “wet clothes” state and return everything to idle. It isn’t a huge deal. Luckily, our washer takes longer than the dryer. At least mine does.

Thanks for your help.