Need help to making a pump out sensor for dehumidifier

I have a dehumidifier that has a has a spike in power use when it pumps out. I made an automation and a counter to count the pump outs. The problem is the dehumidifier power use goes up and down with the ambient temperature, so a static value does not work well,

I can think of a couple of complicated software solutions, like temperature compensating your threshold or using moving averages but the simplest solution would be to add more hardware. Monitor the pump switch directly with a relay.

You could set up an ‘average’ sensor of the humidifier power using for example 5 minutes average.

then if the power exceeds the average by a set amount/percentage and the average is far above zero (to prevent a count when the humidifier first starts) then trigger the counter.

That’s what I did. It works good enough for me. You get an extra spike when it turns on but I’m ok with that.