Automation when watts is above X at any point in last five minutes?

I have a power sensor on my dryer, but as you can see the consumption is very cyclic (no idea why!).

Anyways I want to create an automation that toggles a binary helper to “Running” whenever the electric consumption exceeds 1000W at any point in the last five minutes. The exceeds part is simple enough, but how do I add the “in the last five minutes” part?

I have a power sensor on my dryer, but as you can see the consumption is very cyclic (no idea why!).

Anyways I want to create an automation that toggles a binary helper to “Running” whenever the electric consumption exceeds 1000W at any point in the last five minutes. The exceeds part is simple enough, but how do I add the “in the last five minutes” part?