Invalid Energy consumption in HA due to glitch in inverter data from SAJ Inverter?



Hi everyone,

I’m facing an issue with my SAJ inverter setup in Home Assistant, which is connected over the local network. While the setup works fine most of the time, there’s a recurring glitch where Home Assistant briefly records 0 kWh for produced energy when the inverter starts producing energy in the morning. This happens approximately every 10–14 days.

The bigger issue is that after this brief 0 kWh reading, the inverter jumps back to the correct value. However, Home Assistant interprets this sudden difference as the day’s production. Since we don’t export energy during that time, HA assumes we’ve consumed all the energy, which skews the consumption data.

I’ve tried to address this by filtering out the erroneous values using a template sensor, but it hasn’t resolved the problem.

- sensor:
    - name: "SAJ Total Yield filtered"
      unique_id: 2a9a148e-3b91-49fc-b471-cf3439c7a440
      state: >
        {% set previous_value = states('sensor.saj_total_yield_filtered') | float(0) %}
        {% set current_value = states('sensor.saj_total_yield') | float(previous_value) %}
        {% if current_value > previous_value %}
          {{ current_value }}
        {% else %}
          {{ previous_value }}
        {% endif %}
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing

I’d greatly appreciate any advice or insights from the community on:

  1. How to prevent Home Assistant from logging this brief 0 kWh glitch.
  2. Properly filtering or correcting these anomalies to ensure accurate energy production and consumption tracking.

Has anyone else experienced similar behavior with SAJ inverters or other setups? Any suggestions or guidance would be a huge help.

Thanks in advance!

You can fix this historical errant value in developer-tools/statistics.

Typically the way to write a template to not glitch like this is to use an availability template to make the sensor unavailable when the inputs are not valid, instead of using float(0).

A sensor going to/from unavailable will not mess up your statistics in the way that a sensor going to/from 0 will mess up the statistics.