# Using Utility Meter with Long Term Statistics for Energy Dashboard

Good Morning all,
Is it possible to use a Utility Meter entity as a source for Power Consumption in the new Energy Panel?

The reason for this is that I have a Shelly 3EM clamped over the 3 phases of a home’s Distribution Board. This was working well as I simply used the total_consumption sensor to create Daily/Weekly/Monthly utility meters. However things went a bit strange when trying to integrate Solar Panels.

I have just setup the SolarEdge integration, which gives readings regarding Solar Power Generation (a sensor with total_production).

The problem is with the way the Solar Panels are hard wired into the house. I believe both the Solar Energy and the Grid Energy are connected to the Distribution Board before the Shelly 3EM, so the Shelly is in fact only able to detect how much current the house is using, and not able to tell me simply how much is coming from the grid. To clarify, here is an awfully rough diagram:

This results in wrong values coming from the Energy tab. This is the current setup:

And these are the results :

So as you can see, the Home circle is showing a total consumption of 211.8 kWh, which I believe is incorrect as Grid energy is also counting the Solar Energy that is passing through the Shelly.

So my solution would be to somehow ‘Net Off’ the Solar Production from the Grid Usage by simply subtracting the Solar Production from the Grid energy. Do you think this would work?

So far I have this in my configuration.yaml:

``````template:
sensor:
state: "{{ (states('sensor.solaredge_lifetime_energy') | float / 1000) | round(2) }}"
unit_of_measurement: 'kWh'
- name: Consumption minus Production

utility_meter:
name: Utility All Phases Lifetime Consumption
source: sensor.all_phases_total_consumption
utility_consumption_minus_production:
name: Utility Energy Consumption Minus Solar Production
source: sensor.consumption_minus_production
``````

So question 1) Will this idea work?!

1. If so, how can I get this ‘sensor.utility_consumption_minus_production’ to be used as a source for the Power Consumption in the energy panel? I’ve tried adding the below customization to the sensor in an attempt to get HA to accept is as a long term statistic sensor, but it’s still not showing up in the drop down
``````sensor.utility_energy_consumption_minus_solar_production:
device_class: "energy"
state_class: "total_increasing"
``````

Any help much appreciated!

Did this work for you in the end? I am in a similar situation, the “difference sensor” works and reports in the table, but the utility meter for it does not follow the difference but the bigger sensor.