Energy Dashboard - add toggle to sum production and consumption across phases

Hi all

At home I have a 3-phase installation with solar panels hooked up to only 1 phase.
This means that I may be returning energy on 1 phase while consuming on the other 2.
To me personally, this doesn’t make a difference as the utility provider sums the phases together and will substract whatever return I have on the PV phase from the other phases.

However, in the Energy Dashboard this is seen as separate consumption and production, which has a few side-effects:

  • The self-consumption statistic doesn’t match with what I would calculate based on my electricity bill.
  • The visual with the grid, panels, and house shows lots of energy exported and practically the same number imported again (depending on my actual consumption at the time).
  • The cost calculations don’t match my bill as in HA injection tarrif would be granted for 1 phase and electricity would be purchased on the other 2, while my bill may have a zero-sum for that moment.

My request is for a toggle that would cause the consumption and production across phases to be summed.
This way – in the calculations – I’d have 1 number for consumption and 1 for production.
Whether or not the UI still shows this as 4 seperate (3 in, 1 out) blocks, doesn’t really matter for me personally.

Note that the calculations would have to be real-time, i.e. not the sum of 1 hour of data but as short of a time-period as possible.

Example

  • On Phase A I am consuming 250,2W
  • On Phase C I am consuming 3,4W
  • On Phase B (PV phase) I am returning 1.457,5W
  • Not shown here is the production of the PV, let’s assume 1.500W (cloudy day)

Assuming these numbers where static for 1 hour:

  • My utility provider would pay me injection tarrif for 1.203,9Wh. Their dashboard would not show consumption for that hour.
  • Energy Dashboard would show me 253,6Wh of energy consumed and 1.457,5Wh produced.
  • I would have 100% self-consumption according to my provider, while the Energy Dashboard would only show me 2,83% being ( [PV production] - [Phase B return] ) / [PV production] or (1.500 - 1.457,5 {= 42,5}) / 1.500

As I mentioned on Facebook, I think a few template sensors might help you. If you would add this to your config.yaml:

template:
  - sensor:
    - name: "Grid Import"
      unique_id: grid_import_w
      state: >
	    {% if (((states('sensor.phase_a_power')| float(0)) + (states('sensor.phase_b_power')| float(0)) + (states('sensor.phase_c_power')| float(0))) < 0) %}
          0
        {% else %}
          {{((states('sensor.phase_a_power')| float(0)) + (states('sensor.phase_b_power')| float(0)) + (states('sensor.phase_c_power')| float(0))) }}
        {% endif %}

    - name: "Grid Export"
      unique_id: grid_export_w
      state: >
	    {% if (((states('sensor.phase_a_power')| float(0)) + (states('sensor.phase_b_power')| float(0)) + (states('sensor.phase_c_power')| float(0))) > 0) %}
          0
        {% else %}
          {{((states('sensor.phase_a_power')| float(0)) + (states('sensor.phase_b_power')| float(0)) + (states('sensor.phase_c_power')| float(0))) }}
        {% endif %}

sensor: 
  - platform: integration
    source: sensor.grid_import_w
    method: left
    unit_prefix: k
    name: grid_import_kwh

  - platform: integration
    source: sensor.grid_export_w
    method: left
    unit_prefix: k
    name: grid_export_kwh
	

utility_meter:
  grid_import_yearly:
    source: sensor.grid_import_kwh
    name: Grid Import Yearly
    cycle: yearly	

  grid_export_yearly:
    source: sensor.grid_export_kwh
    name: Grid Export Yearly
    cycle: yearly	

It would give you a couple of sensors to work with. In your energy dashboard you would configure “sensor.grid_import_yearly” and “sensor.grid_export_yearly” as the sensors for your import and export. It should than start to give you the correct values.

The only thing which may be wrong is that import and export are inverted. I do not know if your meter gives positive or negative values for import and export. If a positive value on sensor.phase_a_power means you are IMporting power, the templates are correct. If it is the other way around you have to change the “bigger than” and “smaller than” symbols in the templates.

I hope this helps…