An 'arm and release' automation option, for things like washing machine state tracking

I’ve got a simple automation for tracking when the washing machine is done. If power consumption is below X for Y many minutes, assume the washing machine is done and notify me.

This works well enough, but if I have to reboot HA or reload my automations, that automation fires after Y minutes because technically the power usage has been less than X watts. In other words, it doesn’t know if the washing machine has been on or not.

I could expand this with a second automation that would check if the power consumption is above X, then switch on a second automation that would check to see if power consumption is below X before notifying, but that’s two automations just to know with certainty if the washing machine is done.

I’d like to see an “arm and release” style trigger option, like the numeric_trigger, but with a start and end. For example:

# This automation will fire only when the washing machine goes above 500w for > 5 minutes, then drop below 50w for > 5 minutes
- alias: Notify when washing machine done
  trigger:
    - platform: armed_state
      entity_id: sensor.washing_machine_power
      start: # The trigger is "armed" when this condition is met
        above: 500 # When the washing machine goes above 500w
        for:
          minutes: 5 # For more than 5 minutes 
      end: # This automation is "fired" (triggered) when this condition is met, but only if the 'start' condition is met
        below: 50 # When the washing machine goes below 50w (standby mode, for example)
        for:
          minutes: 5
  action:
    - service: light.turn_on
      entity_id: light.laundry

I’d imagine this would work a little like the generic_thermostat component which watches an entity’s value and takes action based on when a value goes above or below a certain limit.

I’d have a go at this myself, but I’m still teaching myself Python…

I’ve done this for my washing machine, dryer and dishwasher, though I used an input_select with Off, Powered Down, Rinse, Wash, then created automations that moved it through the cycle (e.g. can only go Off -> Powered Down -> Rinse Wash) but its allowed to skip items just not go backwards. Took a bit of tuning but works well.

Was overly complicated for what it was unfortunately. Did it this way as I wanted notifications when a wash was complete but not a rinse (mostly dishwasher, as I don’t care when it only does a rinse and does not require to be emptied).

Having a component with multiple stages would be handy actually. Something like:

state_component:
  alias: Rice Cooker
  states:
    warm:
      above: 0
      below: 50
    cook:
      above: 50

With a bit of knowledge about your particular appliance and what power it uses, you could write some configs that would accurately reflect the state of your device. So if your dishwasher used more power during wash than it did rinse, and more power than idle, you could use a component to track the state based on what you know about your appliance’s usage.

Yeah might be that simple for constant draw appliances, but something like my dishwasher, dryer and washing machine, they continuously bounce between 0 and 2400w draw. That’s why I had to define a bunch of ranges, duration and stepping states that could only move forward.

If something bounces between idle and wash constantly, you won’t get a reliable indicator of when it really finishes.