Heuristics for power monitoring in an automation

I have an older “non-smart” dishwasher that I’d like to add some smarts to. In a nutshell, we don’t have the ability to skip the heated drying phase, and I’d like to kill the power to a smart plug when it hits that phase. I’ve got the data on power consumption and can tell by rough time elapsed and draw when it enters this phase (See red circle below):

I’m not sure how to create a foolproof automation that can flip the switch on the smart plug when it hits this section. In my head the logic is some combo of “if at least minutes have elapsed” and “if power was at watts for duration before dropping below watts for duration” but I’m curious if there’s a smarter and more reliable way to implement this?

Typically, the way I do it for my washer for notifications is exactly that using a threshold sensor. If the sensor is off (meaning the power is below 10 watts) for 2 minutes, the washer cycle has completed and I kick off a notification and turn the power off on it.

This is basically the same thing. Create a threshold sensor helper, give it min/max values and you have a binary sensor that you can test for time periods pretty easily.

  - platform: state
      - binary_sensor.laundry_room_washer_running
    to: "off"
    from: "on"
      hours: 0
      minutes: 2
      seconds: 0 

Where is that phase on your graph?

The red circled part looks far too low a power to be a drying stage.

Is this the bit you want to skip?

Turns out the easiest solution was to wait for the dishwasher to consume > 125w, when wait a specified time before triggering the smart plug to go off. The cycles are always the same length.