Grid usage energy

Hey all,

recently we install solar plant. Until now, power consumption was shown correctly on energy dashboard.
But now, grid usage and solar production are both added as house power usage.
Problem is because shelly in not installed on inlet wires, but just for house usage, as shown on photo.
I know I have to do some calculations. So grid usage = house usage - solar production.
And return to grid should be solar production - house usage. This gives us negative number, since there was not production yet and shelly for house usage was installed for a while now.

My questions now are:

  • Will energy dashboard calculate return to grid energy correctly if there are negative numbers?
  • I did some calculations as below. I see “sensor.grid_usage_l1” sensor in developer tolls, but not in energy dashboard. Is that a problem because there is not state_class: total_increasing? I tried with that but HA says it can not be added to “sensors”. With new formating, there are some other errors…
- platform: template
  sensors:
    grid_usage_l3:
      friendly_name: Grid_usage_l3
      unit_of_measurement: "kWh"
      device_class: energy
      #state_class: total_increasing
      value_template: >-
        {{ (states('sensor.l3_energy')|float 
		  - states('sensor.shelly3em_elektrarna_channel_c_energy')|float) | round(2) }}

Any ideas here?

You could try to start with this and expand it according to your needs…