Switch device off only when power is zero, measured by wallplug

Hello ,

Would this be possible?

I have a air compressor which makes an awful lot of noise, I have put it far far away in a little corner with a zwave wallplug, now I can switch the air compressor on and off remotely.
The problem is that you can not power off the compressor when the motor is still running , it can only be shut off with a special valve, which gets the air out when you press the off button, so with the next start , the electric motor does nut burn out.

Or wait untill the compressor has its max pressure , than it shuts off completely and than I can get the power off ( switch off the wallplug).

Untill now I do it by noise , when I don’t hear the compressor anymore I switch the wallpug to off.

I would like to automate it a little bit; only switch off the wallplug when:
-I press the off button on the wallplug ( via a mobile device) AND the power consumption = 0 watts
-When the power consumption is above x watts , than wait with switching off untill power consumption is 0
-send a notification when the wallplug is off

I probably have to do this with PLEG , but maybe there is an easier/ better way?

Thanks,
Cor

Anyone has an opinion on this?

Thanks,
Cor

Got it working with:
-fibaro wallplug
-virtual switch
-PLEG

2 triggers:
-Virtual switch
-wattage below 1000 Watts

when the virtual switch is switches to off , the wattage needs to be below 1000 watts for the wallplug to go off.

Max wattage of the compressor is 1850 watts
max allowed load on the wallplug is 2500 watts with peaks to 3000. so all is good!

Works good.!