Utility meter/energy meter - How to ignore power generated by solar panels?

Hi there,

Don’t know what I am doing wrong anymore, but long story short: I have 3 energy lines (using P1 Meter integration) which is showing my current energy consumption on each line.
Problem starts when my solar panels are working as these are connected to line 2 and when panels are producing more energy than my current consumption is, it shows “negative” values equal to generated power minus my current usage which goes back to the grid.
I’ve created two sensors:

  1. line 1 + line 2 + line 3 (I can see usage on all three lines but as panels are connected to line 2 sometimes values are negative as it is producing more then I’m using.
  2. above sensor + energy produced by solar panels so in theory it should “ignore” values provided by solar panels production.

And the main issue is: still showing negative values (back to the grid) and I just want to see my current usage without energy from solar panels.

Am I missing something or doing wrong here? Thanks in advance for any tips!

#real usage minus solar panels

  • platform: template
    sensors:
    dom_real:
    friendly_name: “Realne zużycie prądu z solarami”
    value_template: “{{ (states(‘sensor.suma’)|float + >states(‘sensor.solaredge_current_power’)|float)|round(2) }}”
    unit_of_measurement: “W”
    #all three power lines together
  • platform: template
    sensors:
    suma:
    friendly_name: “Suma pobieranego prądu bez korekcji solarów”
    value_template: “{{ (states(‘sensor.p1_meter_active_power_l1’)|float + >states(‘sensor.p1_meter_active_power_l2’)|float + >states(‘sensor.p1_meter_active_power_l3’)|float)|round(2) }}”
    unit_of_measurement: “W”