Automation to switch off power plug to avoid black-out

Hi, I am finished with putting HASS controlled switches in power outlet at home (various type, sSonoff, Shelly, Broadlink, Meross, etc…)

My goal is never exceed total home current power limit (6KW), to avoid a black-out. Unfortunately this happens usually in summer with many air conditioners on: sometimes a member of the family forgets that too many appliances are on and … puff … black-out. An increase in power is out of the questions, it would cost a lot in increased monthly bill plus the cost of electric upgrade.
The black-out does not happen often (but it happens), so I hoped for a software solution, with HASS…

So now I have
switch .twenty

and relative sensors that measures power (also current and voltage)


Basically when the sum of the power is near 6KW, then an automation should start turning off some switches.

Any clue in how to achieve this in yaml?
Maybe an appadaeom app or node-red is easier?

p.s. I do have a monitor of instant power for the whole house, with Efergy, but it has a delay of 10 seconds,way too long to avoid a blackout, so I do need to sum the power from the single power plugs

For summing the power, you can use a statistics sensor to get the total value of all of your loads.

As for the actual load shedding scheme, I would recommend something a bit more advanced, like AppDaemon to achieve this. NodeRed always seems to get super messy with complicated automations, but you might have more luck. And doing this in normal HA automations would get pretty complicated.

You probably want to do something like assign load priorities to each switch (1 through 10, or whatever) to represent how critical of a load they are. You can group many switches into a single priority. The system can then activate when the total house load gets above a threshold (5.5kW maybe) and start shedding the least critical loads. If a few seconds pass and you are still above the threshold, shed the next lowest priority loads, etc.

You can also be more proactive, such as summing the power in each load shed priority group. This would allow you to raise your shedding threshold because you can immediately predict how many load groups you need to drop to stay within your limit.

Also, this is a VERY interesting use case. I’d love to see how it works out.

1 Like

A lot of good ideas. Other additional ideas are that you could power off the fridge momentarily (it can stay 15 minutes off without consequences I think), blow dryer and iron indefinitely, and so on, for each device how long they can stay off (if needed to switch them off) without bad consequences (a fridge off too long has bad conseguences)

Now that the ideas are in place is needed someone with coding abilities and spare time :slight_smile:

How to do that? I do not see SUM in statistic sensor