Past Condition on Trigger - Automation

I have an automation to let me know when the washer is done based on trigger of being idle for greater than 4 minutes (to avoid short cycles where the washer sits and then goes again). It uses the power monitoring of a smart plug.

- id: '1618601325583'
  alias: Washer - Idle
  description: ''
  trigger:
  - type: power
    platform: device
    device_id: 2755bf72f9d10dff4615cc48ac639547
    entity_id: sensor.sonoff_sp20_1_energy_power
    domain: sensor
    below: 5
    for:
      hours: 0
      minutes: 4
      seconds: 0
      milliseconds: 0
  condition: []
  action:
  - service: input_text.set_value
    data:
      value: Idle
    target:
      entity_id: input_text.washer_state
  - service: notify.iphones
    data:
      message: '{{ [ 
        "Clothes are clean and ready for the dryer." , 
        "Ahhh, clean clothes!" , 
        "Time to go upstairs!" , 
        "Dryer Time! "
        ] |random }}'
      title: Washing Machine is Done!
  mode: single

However, my washer seems to randomly draw 8-12W of power throughout the day for a few seconds which causes the automation to fire, even though it has not run a full cycle prior to that.

Is there a way to set a condition that looks into the past and says, only execute the automation if the trigger is met AND when it was running (ie power greater than 5W) for more than ‘x’ minutes?

If it helps, here is the automation that sets the Washer state to “Washing.”

- id: '1618603144462'
  alias: Washer - Washing
  description: ''
  trigger:
  - type: power
    platform: device
    device_id: 2755bf72f9d10dff4615cc48ac639547
    entity_id: sensor.sonoff_sp20_1_energy_power
    domain: sensor
    above: 4
    for:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  condition: []
  action:
  - service: input_text.set_value
    data:
      value: Washing
    target:
      entity_id: input_text.washer_state
  mode: single

How about adding this condition to your first automation:

  condition:
    - condition: state
      entity_id: input_text.washer_state
      state: Washing

@pnbruckner, thanks I’ll try that as well.

So far I got it working better by setting the ‘above’ for washing to 24W and the below for ‘idle’ to 25W since the spikes are never more than about 15W and the washer goes well above 24-25W when in operation.

So here’s the other thing you can do. You can have these two automations just change input_text.washer_state. In that case, changing it to “Idle” when it already is isn’t a problem (other than it’s probably annoying to see the automation run in the Logbook when it doesn’t need to. You could still add that condition to avoid that.)

Then create a new automation that is triggered by the state of input_text.washer_state and sends the notification when it changes to “Idle”.

It’s better to modularize and keep these two things separate anyway. That way you could, for example, disable the automation that notifies, but still have the other automations keep input_text.washer_state up to date.

1 Like

@pnbruckner, oh that’s a good idea. Remove the notification from the ‘idle’ automation, and make a new automation that send a notification only if the state has changed from ‘washing’ to ‘idle’. Thanks!

Now the next step is to figure out how to keep the iOS notifications firing every ‘x’ minutes until the wash is actually moved to the dryer. Unfortunately, once you look at the iOS notification it goes away. Would be nice if it kept firing every ‘x’ minutes until manually cleared (ie. when you actually move the wash!)

I’ve tried setting up an alert that repeats every 5 minutes, but am having a few issues with them disappearing as well form the iPhone:

In Configuration YAML:

#Alert Notifications
input_boolean:
  washing_machine_state:
    name: Washing Machine State
    icon: mdi:washing_machine

alert:
  washing_machine:
    name: Washer is Done
    message: Washing Machine is Done!
    entity_id: input_boolean.washing_machine_state
    repeat: 5
    can_acknowledge: true
    notifiers:
      - mobile_app_johns_iphone

In automations YAML:

- id: '1618933247757'
  alias: Notify Washer is Done
  description: ''
  trigger:
  - platform: state
    entity_id: input_text.washer_state
    from: Washing
    to: Idle
  condition: []
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.washing_machine_state
  mode: single