Optimizing Power Usage with PV system - Need Advice

Hi all,

I’m looking for advice on optimizing our power usage with a PV system. We have several devices that I would like to run when our PV system generates excess power, and I want to prioritize them. We have a smart meter that provides real-time data on energy flow, and I believe this could be the trigger for my automation.

Our smart meter reports “real power” every minute, indicating whether we’re consuming energy from the grid (positive value) or sending energy back to the grid (negative value).

My concept is to create two automations.

First automation (turn devices on):

  1. When the trigger activates, I would store the “real power” value in a variable called “remainingPower.”

  2. Then, I would check if there is enough remaining power (remainingPower > x) to turn on my first priority device. I already know how much energy my devices need, so I’d subtract that value from “remainingPower.”

  3. Repeat this process for all my devices.

The second automation would utilize the same trigger, but its purpose would be to sequentially deactivate the devices (the same set of devices but in reverse order of priority) one at a time.


  • Is my approach reasonable, or am I thinking in the wrong direction?
  • If this concept makes sense, how can I create, compare and manipulate the “remainingPower” variable in Home Assistant?

Any insights or advice would be greatly appreciated. Thank you!