Issues in energy dashboard with accumulated solar production values

Hi, I just added solar production to the energy dashboard. Getting some weird accumulated value once every day in the energy dashboard graph. Any idea how to solve this?

I suppose the dip to zero at 2:27 explains it but how to mitigate that then… I guess there has to be some validity check on values coming in or?..

Using SunGather; GitHub - bohdan-s/SunGather

Well not the dip, the return from the dip. That is seen as accumulated energy.

Open an issue with the developer.

1 Like

Ok. Will do. In the meantime, would it be possible in HA to create a utility meter or similar and filter rapid changes like these out?

The utility meter will have the same issue. It will register the return from zero as actual use.

As this is a daily sensor it resets to zero at night so it is difficult to filter out the erroneous zeros with a template sensor, but I’ll give it a go.

configuration.yaml

template:
  - sensor:
      - name: Filtered Solar Generation
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: kWh
        availability: "{{ has_value('sensor.your_solar_gen_sensor_here') }}"
        state: >
          {% if [now().hour,now().minute] == [0,0] %}
            0
          {% else %}
            {% if states('sensor.your_solar_gen_sensor_here')|float(0) == 0 %}
              {{ this.state }}
            {% else %}
              {{ states('sensor.your_solar_gen_sensor_here') }}
            {% endif %}
          {% endif %}

This is untested and I suggest you run for a day or two and compare it to your solar generation sensor. If it follows the data well and removes the spikes then replace your energy dashboard pv sensor with the filtered version.

1 Like

Great, seems to do the trick. Thanks! Could you explain how this works? The “availability” reading is either true or false depending on if there is a value or not, makes sense. But the “state”… One check if time is 0:0 then state for filter_sensor is 0. Else if states of sensor piped (?) through float(0) is 0 then this.state?.. Realizing I know too little about this but it would be nice to understand =)

If it is midnight reset the value to 0.

If it is not midnight and the value is zero use the previous state.

Otherwise use the value of your pv sensor.

1 Like

Thanks! Appreciated!

Did a minor modification to avoid issues with unsynced Home Assistant and sun inverter clocks - only checking hour now. If hour 0 then there is no sun and output is 0.

template:
  - sensor:
      - name: "Filtered Solar Generation"
        icon: "mdi:counter"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {% if now().hour == 0 %}
            0
          {% else %}
            {% if states('sensor.your_solar_gen_sensor_here')|float(0) == 0 %}
              {{ this.state }}
            {% else %}
              {{ states('sensor.your_solar_gen_sensor_here') }}
            {% endif %}
          {% endif %}
        availability: "{{ has_value('sensor.your_solar_gen_sensor_here') }}"