Remix.run Logo
londons_explore 2 hours ago

There's a neat way to do this that is super simple... The electricity company publishes an equation that determines the price based on the AC frequency. Ie. price_per_kwh = tan(min(max((-60 + system_frequency) * 1000, -pi/2), pi/2)).

Now every device in your home knows the price. For this to work, everyone must get the same price across the whole grid, and there must be sufficient grid capacity for energy to flow freely which isn't always the case. It will also cause issues with some very old (ie. 60+ year old) clocks with mechanical timers.

All of these issues can be fixed by updating the formula:

price_per_kwh = tan(min(max((-60 + system_frequency + published_offset) * 1000, -pi/2), pi/2))

The published_offset would be unique to each district and adjusted from time to time to keep old clocks working properly, and sometimes to deal with limited transfer properties of the grid...

But the neat thing is that even if you don't take into account the published_offset, you still make nearly optimal economic decisions.