Why is my energy dashboard not displaying the 'sensor.teruglevering_net' entity?

I am experiencing an issue where my sensor.teruglevering_net entity does not appear in Home Assistant’s Energy Dashboard. Other sensors are functioning correctly, but this particular one is missing.

Configuration Details:

I have defined several template sensors and utility meters in my YAML configuration as follows:

# Template sensors
template:
  - sensor:
      - name: "Netto Energieverbruik"
        unique_id: "netto_energieverbruik_sensor"
        unit_of_measurement: "kWh"
        state: >
          {{ states('sensor.youless_verbruik_totaal') | float(0) - states('sensor.youless_opwek_totaal') | float(0) }}
        state_class: total
        device_class: energy

      - name: "Direct Verbruik Zonnepanelen"
        unique_id: "direct_verbruik_zonnepanelen_sensor"
        unit_of_measurement: "kWh"
        state: >
          {{ states('sensor.youless_opwek_totaal') | float(0) - states('sensor.youless_verbruik_totaal') | float(0) if states('sensor.youless_opwek_totaal') | float(0) > states('sensor.teruglevering_net') | float(0) else 0 }}
        state_class: total
        device_class: energy

      - name: "Teruglevering aan het Net"
        unique_id: "teruglevering_net_sensor"
        unit_of_measurement: "kWh"
        state: >
          {{ (states('sensor.youless_opwek_totaal') | float(0) - states('sensor.youless_verbruik_totaal') | float(0)) if states('sensor.youless_opwek_totaal') | float(0) > states('sensor.youless_verbruik_totaal') | float(0) else 0 }}
        state_class: total_increasing
        device_class: energy

# Utility meters
utility_meter:
  netto_energieverbruik:
    source: sensor.netto_energieverbruik
    cycle: daily
    name: "Netto Energieverbruik Dagelijks"
    unique_id: "utility_meter_netto_energieverbruik"

  direct_verbruik_zonnepanelen:
    source: sensor.direct_verbruik_zonnepanelen
    cycle: daily
    name: "Direct Verbruik Zonnepanelen Dagelijks"
    unique_id: "utility_meter_direct_verbruik_zonnepanelen"

  teruglevering_net:
    source: sensor.teruglevering_net
    cycle: daily
    name: "Teruglevering aan het Net Dagelijks"
    unique_id: "utility_meter_teruglevering_net"

  opwek_per_dag:
    source: sensor.youless_opwek_totaal
    cycle: daily
    name: "Opwek Zonnepanelen Dagelijks"
    unique_id: "utility_meter_opwek_zonnepanelen"

  verbruik_per_dag:
    source: sensor.youless_verbruik_totaal
    cycle: daily
    name: "Verbruik Dagelijks"
    unique_id: "utility_meter_verbruik_totaal"

Troubleshooting Steps Taken:

  1. Verified state_class and device_class: Ensured that sensor.teruglevering_net has state_class: total_increasing and device_class: energy.
  2. Checked Source Sensors: Confirmed that sensor.youless_opwek_totaal and sensor.youless_verbruik_totaal are providing valid data.
  3. Restarted Home Assistant: Performed multiple restarts after making configuration changes.
  4. Monitored Sensor Values: Observed that sensor.teruglevering_net occasionally reports negative values, which might be causing the issue.

Need help

I am seeking guidance on the following:

  • Negative Values: Could the negative readings from sensor.teruglevering_net be preventing it from appearing in the Energy Dashboard? If so, how can I adjust the template to ensure only positive, cumulative values are reported? But on the other hand, it doesn’t seem a problem for al the other utilitymeters I have made.
  • Collecting It seems the status of sensor.teruglevering_net keeps hanging on collecting. Can’t find the reason.
    To difficult Am I using a to difficult methode to do this?

Thanks in advance.

One more thing to check is developer-tools/statistics. Sometimes an issue reported there prevents a statistic from being usable.

No issues there.

Before figuring out why you cannot pick a certain calculated value: it seems like you are misunderstanding what enitites the energy dashboard requires.

The solar entity should be what is produced, regardless of what of that is consumed by the home. The value should come straight from the inverter.

Import from grid and export to grid should come directly from the energy meter, and literally what is exported and imported.

The energy dashboard will then calculate what the home consumed, either from sun or grid. It is unlikely that you ned to do any calculations at all. It is fine you want to have entitiees for home use, self use etc too, just don’t feed them in the dashboard.

These entities can be totals, they do not need to be hourly dayly or monthly either. They just need state class total or total_increasing, device class energy and a suitable unit of measurement. So in that sense it is weird they cannot be picked.

It seems very weird that you should calculate grid export from home use because self use, and thus home use cannot be measured directly, it can only be inferred. Sho why do you need to undo those calculations?

The reason things may not always be what you expect is that these measurements are probably not taken at the same time, leading to weird effects in the calculations and totals seeming to go backwards if measurements from a couple of minutes ago from solar are compared to what is consumed right now.

Did you also take info account it can take up to an hour to see results pop up when a sensor was added to the dashboard? The bars are calculated once an hour, and not exactly on the our but a bit later. There will only be a bar if the total changed since the presious hour.

Well, I don’t have that. I don’t have a digital meter that tracks exported and imported energy. My inverter is too old to have a usable interface, so I can’t use it for that purpose.

I have one Youless device connected to a kWh meter that monitors the total energy consumption of the entire house (regardless of the source).
I also have another Youless device connected to a kWh meter that monitors the solar panels’ production.

The energy panel isn’t designed for this setup, so I have to rely on calculations to configure it. There’s no way for me to directly measure grid energy (I tried using the old Ferraris meter with a Youless, but it’s not reliable—been there, done that). And it can’t make any distinction between import and export of energy.

Okay, I didn’t actually need to calculate the daily solar panel output, but I was exploring how the system works.