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.


Required Sensors

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

Sensor Unit Required Description
Grid Import W Yes Power currently being drawn from the grid. Must be a non-negative value — the entity should read 0 when no import is occurring.
Grid Export W Yes Power currently being sent back to the grid. Must be a non-negative value — the entity should read 0 when no export is occurring.
Production W Yes Total solar (or wind) generation output. For most setups, this is the inverter output sensor.
Consumption W No Total household power consumption. If omitted, Hanergy derives this value automatically (see below).

Where to find your entities

Open Developer Tools > States in Home Assistant and filter by sensor.. Look for entities from your inverter or smart meter integration. Common patterns include sensor.solar_power, sensor.grid_power_import, and sensor.grid_power_export.


Derived Consumption

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.


Handling Signed Meters

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:

Template sensor example

Add the following to your Home Assistant configuration.yaml (or via the UI template sensor helper):

template:
  - sensor:
      - name: "Grid Power Import"
        unit_of_measurement: "W"
        state: "{{ max(0, states('sensor.grid_power') | float(0)) }}"

      - name: "Grid Power Export"
        unit_of_measurement: "W"
        state: "{{ max(0, -1 * states('sensor.grid_power') | float(0)) }}"

This splits sensor.grid_power (where positive = import, negative = export) into two non-negative sensors.


Multiple Sensors per Field

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.


Tips

Check unit consistency

All sensor values must be in watts (W). If your sensors report in kilowatts (kW), create a template sensor that multiplies by 1000 before mapping it in Hanergy.

Sensor update frequency

For best results, energy sensors should update at least every 10-30 seconds. Sensors that only update every few minutes will cause the engine to make decisions based on stale data, which can lead to unnecessary grid import.

Battery SOC sensor

If any of your devices use a feedback entity for threshold-based control (e.g., "charge EV to 80%"), the feedback sensor is configured on the device itself, not in the Energy Sensors section. See Devices for details.