Which entity stores the net grid consumption?

So I am using an Iammeter module to monitor my grid. It provides me two sensors which I have configured in the Energy dashboard:

sensor.imeter_xxxxxxxx_importenergy_x
sensor.imeter_xxxxxxxx_exportenergy_x

The energy dashboard uses these to calculate and display the “Grid Total”.

Is that value available to use via an entity?

I have created a template sensor which I use as input for daily, weekly, etc… Utility Meter helpers, but I regularly get spikes which basically makes these helpers unusable.

  # Grid net energy
  - sensor:
      - name: "Grid Net Energy"
        unique_id: grid_net_energy
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        state: >
          {% set import = states('sensor.imeter_613677eb_importenergy_x') | float(0) %}
          {% set export = states('sensor.imeter_613677eb_exportenergy_x') | float(0) %}
          {{ import - export }}

Apparently, the built-in “Grid Total” does not have this issue so I’d like to build mob helpers on that value.

You need to add an availability template to the above sensor:

# Grid net energy
  - sensor:
      - name: "Grid Net Energy"
        unique_id: grid_net_energy
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        availability: >
          {{ has_value('sensor.imeter_613677eb_importenergy_x') and 
             has_value('sensor.imeter_613677eb_exportenergy_x') }}
        state: >
          {% set import = states('sensor.imeter_613677eb_importenergy_x') | float(0) %}
          {% set export = states('sensor.imeter_613677eb_exportenergy_x') | float(0) %}
          {{ import - export }}

If you don’t, when one or more of the base sensors are available, they are counted as 0, creating weird values that lead to the spikes.

2 Likes

Hi Edwin,

Thnx for the help :sunglasses:. I’ll give it a shot right away.

JF