Calculate Grid Usage

I need to calculate Grid Consumption , I have the following entities available.

  • Total Daily Power Load for House Kw
  • Total Daily Solar Produced Kw
  • Total Daily Solar Exported Kw
    Whilst I understand the basic maths required I need assistance with setting up in Home Assistant.

use a template sensor with a formula similar to this in jinja:

{{ state('load') | float - (state('produced') | float - state('exported') | float) }}

You also want to conditionalize the sensor to being available only when the three source sensors are available. This is generally done with the availability template and the Jinja function has_value('entity').

Set state class to total_increasing and device class to energy. I am not sure if these can be done via the UI. You may have to add them to configuration.yaml.