Detect when appliance is finished based on power usage

Hello,

I’d like to detect when an appliance, in this case my dishwasher, is done based on power usage. I have a power monitor (CT Clamp) on the circuit the dishwasher is on, unfortunately a few other kitchen appliances are also on the same circuit, including the refrigerator.

This is what the dishwasher power usage looks like after it runs

And another:

My first thought was to use the Derivative integration on that sensor and use a range for a trigger, and this seems to work, but after testing it for a few weeks, I’ve had a few false positives and it also missed one time that should have triggered.

Is there a better way to try to identify this particular power signature and use it as a trigger?

If all the high values are from the dishwasher - with a low in the middle of the cycle, what about using an automation that just tracks if power is below xx for yy minutes.

Are you saying use the “Numeric State” trigger for < XX for YY?

My assumption is that that would have a lot of false positives when any other kitchen appliance on the same circuit turns off.

Ideally I’d like to capture the device being on consuming power withing a certain range, in this case 600-800W, and then fire a trigger when that stops.

The dishwasher always have the same 3 spikes of power. So tracking the three spikes might be a good signal, but I can’t think of a good way to do that without a bunch of helpers and additional automations. But any method that works reliable enough is good with me.

alias: Notify Dishwasher Finished
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.kitchen_appliances
    for: '00:01:00'
    above: '1000'
condition:
  - condition: template
    value_template: >-
      {{ (as_timestamp(now())-as_timestamp(state_attr('automation.notify_dishwasher_finished', 'last_triggered') | default(0)) | int > 5400)
action:
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.kitchen_appliances
        below: '150'
        for: '00:01:00'
  - service: notify.mobile_app
    data:
      message: Dishwasher is fininished

I don’t know if it works or not, but this is the explanation-

  1. Automation is triggered when sensor.kitched_appliances went to above 1000W - this only happens when the dishwasher is ON
trigger:
  - platform: numeric_state
    entity_id: sensor.kitchen_appliances
    for: '00:01:00'
    above: '1000'
  1. The action part will wait for trigger when sensor.kitched_appliances went below 150 for more than 60 seconds - which should be when dishwasher is finished.
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.kitchen_appliances
        below: '150'
        for: '00:01:00'
  1. Prevent automation from being triggered again if the last_triggered is below 1.5 hours to anticipate multiple spikes of power
  - condition: template
    value_template: >-
      {{ (as_timestamp(now())-as_timestamp(state_attr('automation.notify_dishwasher_finished', 'last_triggered') | default(0)) | int > 5400)

Note: Tweak the number to reduce false positives

1 Like

Thanks for the detailed example and explanation! I like the idea of having the automation reference itself. I never thought of that.

I’ll try to implement this and give if a try. Now I just need to make some dirty dishes to test it!

Tangential question: for the wait_for_trigger action, what would happen if say Home Assistant was rebooted while it was waiting? Would it be smart enough to know to resume when it comes back, or since the original trigger had not fired since the most recent boot would nothing happen? I’m not really concerned about this scenario, but I am curious to know if the wait_for_trigger action is stateful or not.

I don’t think wait_for_trigger can survives HA restart.

To try the automation, you can simply remove the for: time in both the trigger and action.

Then, you can change the value manually in the Developer Tools.

Yes, but the automation would still fail if server reboot happen on the last dishwasher cycle - while wait_for_trigger is waiting for the sensor to drop below 150.

Also, does last_triggered will be retained after a reboot or will it be wiped out?

Why?
It would not trigger if the dishwater ends during the reboot, but otherwise it would re-enter the wait…

Yes, last_triggered survives reboots.

  1. For the condition of sensor value above 1000, it will need to be modified- to find the lowest possible power when dishwasher is ON (maybe above 200). Because if the reboot happen when the value is 500 (at downward slope after the third power spikes), it will not be triggered.

  2. If last_triggered value is retained after a reboot, then the second condition will not be satisfied as it requires last_triggered value to be above 1.5 hours. This will need to be modified to find the average time needed by the dishwasher to reach the downward slope (below 1000) after the third power spike.

Ah, right. I didn’t properly read the OP. Will delete…

No, your suggestion is correct. But lanrat need to find the proper value which can be challenging as the power usage is combined with other appliances (which may also have power spikes).

If you don’t mind a delay in the “off” event of the longest duration of the mid drop power cycles (plus a smaller buffer maybe) you can simply use a template binary sensor. If the longest drop is 10 minutes something like this would work.

template:
  - binary_sensor:
      - unique_id: dishwasher_power
        name: Dishwasher Power
        icon: "{{ 'mdi:dishwasher' if is_state('binary_sensor.dishwasher_power,'on') else 'mdi:dishwasher-off' }}"
        device_class: power
        delay_off: 
          minutes: 11 # 10 minute power drop + 1 minute
        state: "{{ states('sensor.ad_power')|int > 400 }}"  # highest possible value without dishwasher on

This would give you an entity to display in the UI, would turn back on after a restart if the dishwasher is still on and you can use this binary sensor as the trigger wherever you need it (notification etc.)

trigger:
  - platform: state
    entity_id: binary_sensor.dishwasher_power
    to: 'off'
    from: 'on'
1 Like

Thanks for all the suggestions.

I forgot to mention, that my Stove is on the same circuit as the dishwasher. Well, it uses two-phase power, so its on both the dishwasher and another circuit. I need to be sure that the stove does not also trigger the dishwasher automation too.

To test this, I’ve added a condition to the automation that checks that the other circuit the stove is on does not have abnormally high power. I think this should work unless both the stove and dishwasher are on at the same time, but I don’t expect this to happen often, if ever.

I’ll be running my dishwasher tomorrow and test it. If it works I’ll post the yaml for the automation.

Thanks for the help everyone. I had to tweak the automation over the past few weeks and tuen it every time I ran the dishwasher to fix false positives/negatives. This is the version I settled on that appears to work great for me:

alias: dishwasher done notification
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.a_d_power
    above: '700'
    below: '1100'
    for: '00:10:00'
condition:
  - condition: numeric_state
    entity_id: sensor.b_c_power
    below: '700'
action:
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.a_d_power
        below: '400'
        for: '00:05:00'
    continue_on_timeout: false
    timeout: '00:30:00'
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.a_d_power
        below: '1100'
        for: '00:10:00'
        above: '700'
    continue_on_timeout: false
    timeout: '01:00:00'
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: sensor.a_d_power
        below: '400'
        for: '00:30:00'
    continue_on_timeout: false
    timeout: '01:00:00'
  - service: notify.mobile_app_pixel_5
    data:
      message: dishwasher done
mode: parallel
max: 3
1 Like