Dynamic Energy Management for Home Automation

Hello,

For my internship within home automation I was tasked with using Node-Red to integrate some devices and logic into an existing home.

One of the key changes in our field in the introduction of a "capacity tariff". In the old situation the electricity bill you received from the utility company was based upon your total net usage.

To combat the grid being overloaded in the new situation your usage is now calculated every 15 minutes and the average is used for the electricity bill. This means that if you are able to spread to usage of power-hungry devices your electricity bill ends up cheaper.

Here is where I could use some input:

Wintertime: How do I create a flow where only 1 of my devices will be active at any given time? Also, the other devices that need to be activated will be put into a queue until device 1 has either finished or the 15-minute window has passed.

Summertime: I want to create a flow that activates the devices when there is a surplus from the solar panels.

Autumn/Spring: The Node-Red flow will automatically switch to wintertime operation when PV surplus is low and switch to summertime operation when the opposite is true

Not expecting a fully fleshed-out flow but some pointers and creative minds to help think along would be greatly appreciated!