Energy control

hello, I bought the advanceflow version to try to create an energy control on the current consumption of the house.
my idea was to be able to disconnect certain equipment based on instantaneous consumption before triggering the electricity supplier’s meter.
I have a qubino that measures the total consumption of the whole house, and I have smart sockets for high loads with power reader on various appliances such as oven, washing machine, dryer. the idea was to ensure that if the main reader (qubino) exceeds 4 kw, the flow reads the instantaneous consumption of the secondary devices, compares them and disconnects the one with the highest consumption before blowing up the current.
any idea how to do it?

This AF should work:

I tried to explain it a bit and I hope that you understand it.
If you want to test it first, please create 3 logic numeric variable and fill them with some values.

thanks for the answer, then yesterday I got to it and managed to do it this way, it looks very similar to yours I added an update of the consumption with new variables to better understand but it is not necessary

This is really a smart way to determine the max. consumption. But will it work with the logic cards consumption of device x is equal with massimo? Does the flow run so fast that the consumption of a device has not changed in the meantime (between the determination of the highest consumption and the comparison with the variable massimo)?

Even if it’s easier to create the flow with the additional variables, I wouldn’t choose this way. Because every change in the consumption of each device Homey must calculate. I don’t think that this flow will be a big problem for Homey, but if you have multiple flows with frequent triggers, Homey will surely be loaded more at some point.
If these variables are removed, the flow is only triggered when the total consumption rises above 4.500 W.

yes, actually my concern was what you say, i fixed it like this now, it should work better. I also connected an http request for voice monkey (a skill that I discovered yesterday interesting for making announcements on alexa of the device that has been turned off)