Skip to content

Energy Sensors

Energy sensors are the foundation of Hanergy’s surplus calculation. They tell the engine how much power is being produced, consumed, and exchanged with the grid at any given moment.


Hanergy needs the following Home Assistant sensor entities mapped in order to calculate surplus:

SensorUnitRequiredDescription
Grid ImportWYesPower currently being drawn from the grid. Must be a non-negative value — the entity should read 0 when no import is occurring.
Grid ExportWYesPower currently being sent back to the grid. Must be a non-negative value — the entity should read 0 when no export is occurring.
ProductionWYesTotal solar (or wind) generation output. For most setups, this is the inverter output sensor.
ConsumptionWNoTotal household power consumption. If omitted, Hanergy derives this value automatically (see below).

When the Consumption sensor is left empty, Hanergy calculates it automatically using the standard energy balance formula:

consumption = production + grid_import - grid_export

This works correctly in the vast majority of residential setups. Only provide an explicit consumption sensor if your Home Assistant installation already exposes a dedicated whole-home energy monitor (such as a Shelly EM or Fronius Smart Meter on the main breaker) and you want to use it as the authoritative source.


Some smart meters and inverters report grid power as a single signed value — positive for import, negative for export (or vice versa). Hanergy requires separate, non-negative entities for import and export.

If your meter works this way, create two template sensors in Home Assistant:


If your system has multiple production sources (e.g., two inverters on different roof arrays), you can use a Home Assistant template sensor to sum them before mapping the result in Hanergy:

template:
- sensor:
- name: "Total Solar Production"
unit_of_measurement: "W"
state: >
{{ (states('sensor.inverter_east') | float(0))
+ (states('sensor.inverter_west') | float(0)) }}

Map the combined sensor.total_solar_production entity in Hanergy’s Production field.