Wacky numbers on energy dashboard

Hi,

I’m new to Homeassistant (about 3 weeks in now) and am really struggling to get my energy usage dashboard working correctly.

I have Solar & Batteries which I believe is maybe where the problem lies as all was fine before when I tested HA with a clamp meter.

I’ve got the “Solarman” integration which monitors the inverter, this sends data from modbus registers to a sensor in homeassistant “Total Energy Imported” The data appears to be correct if I view the sensor state in HA and if I look at a graph of the values over time it looks ok, apart from dropping out a few times.

However, the energy numbers are all over the place. As an example, grid usage today has several spikes,

Sensor is set up as follows

      - name: "Total Energy Imported"
        class: "energy"
        state_class: "total_increasing"
        uom: "kWh"
        scale: 1
        rule: 3
        registers: [33170, 33169]
        icon: "mdi:home-import-outline"

Dashboard looks like this:

When I look at a graph of the sensor, I see it seems to be dropping out the odd time and wonder if that’s something to do with the crazy numbers, but none of the drop outs correspond to the big spikes showing on the dashboard.

Any suggestions on how to put this right?

Thanks!
Pete

Yes that is exactly the issue. Your sensor is reporting 0 rather than unavailable/unknown when it goes offline.

You need to add an availability template to your sensor to filter this out.

Ah, so simple when you know how :smiley: helps knowing the terminolgy for searching for a fix, I guess i’m picking that up as I go along.

Thanks for the help, it was getting very frustrating! Just need to wait ~ 2hrs now for my dashboard to update :crossed_fingers:

Pete

Just one final question on this, one of the values (for solar export) is dipping to 0 but also for some weird reason spikes to over 150 million kWh. So, I need to set availability to be between two values.

I’ve pasted the template below (it doesn’t work but just to illustrate what i’m trying to do), I just don’t understand the actual code I need to use.

    - name: "Filtered Total Energy Exported"
      icon: mdi-counter
      unit_of_measurement: "kWh"
      state: "{{ states('sensor.solis_total_energy_exported')|float(0) }}"
      availability: "{{ states('sensor.solis_total_energy_exported')|float(0) >10 & < 1000000  }}"
      device_class: energy
      state_class: "total_increasing"

availability: "{{ 10 < states('sensor.solis_total_energy_exported')|float(0) < 1000000  }}"
1 Like

Ah, ok, not very intuitive that one :joy:

Thanks again, really appreciate the help. :+1:

Pete