How to switch off Shelly smart switches when grid power consumation exceed value? Help needed

Hi all, fresh here. Greetings from Belgium!
I use HA for some months now mainly for some power measuring and switching.
HA (latest version) is running in a Oracle VM container on a Windows 10 laptop.
I’ve a setup with a bunch of Shelly devices and a Sensibo device, to name a few.
For the next fase I need some help.
Setup and goal:
depending of the amount of power I pull from the grid I want to switch off certain large consumers (2 hybrid cars, laundry dryer, washing machine etc) in order to avoid to get to high peaks over a period of 15minutes (our energy supplier charges me the highest peak I consume during a period of 15minutes of use).
All of the large consumers have Shelly devices on it, all of them can switch and measuring power.
In my main switch board I have a Shelly 3EM where I measure with a CT clamp channel A (I’ve single phase connection with the grid and have 2 CT clamps in spare) to measure the consumption from the grid and/or the injections in the grid.

So, how can I set this up with an automation for instance?

Case:
Let’s say I dont want to exceed 4kW (using from the grid) over a period of 15minutes and if I do I want to switch off automatic:
or

  • Plug1 : hybrid car1 IF this one is charging
    or
  • Plug2 : hybrid car1 IF this one is charging
    or
  • Plug3 : dryer IF this one is working
    or
    etc
    I hope the explanation and setup are clear :wink: if there are questions please let me know
    I’ve searched the forums but couldn’t find a similiar case, maybe I’m not searching with the right keywords, that’s possible.
    Thanks in advance!
    Marc

i dont use it, but there are things like solar excess optimizer, maybe you can use something like this.

maybe relevant:
load shedding

Tx @vajdum I’ll have a look at it!