How to configure Energy with Solar + Consumption-only monitor

I have the basics of energy monitoring for my house flowing into Home Assistant, but I’m not sure how to derive the right figures necessary for the Energy monitoring dashboard.

I have:

  • Solar inverter generation sensors (Wh and W, polled from SolarEdge integration)
  • Power Utilization sensors (Wh and W, from an ESPHome node with a CT Clamp sensor attached to the main load on my circuit breaker box and Total Daily Energy derived by the node)

My daily “net” usage data (SolarEdge Wh - Power Utilization Wh) matches up with what my energy company calculates.

Inspired by this other forum post, here’s a little diagram which explains my setup:

How do I derive the right numbers for Grid Consumption and Grid Return? I’m not directly measuring grid in/out, so I need to write some templates.

I managed to write a template which calculates my net Wh:

template:
  - sensor:
      - name: "Grid Consumption Today Derived"
        unit_of_measurement: "Wh"
        state: >
          {{ float(states("sensor.total_daily_energy")) - float(states("sensor.solaredge_energy_today")) }}
        device_class: energy
        state_class: total

But I think I need to calculate Grid Consumption and Grid Return as separate sensors. Can I do this in Wh, or do I need to do it in W and then calculate Wh again?

Any advice on how to keep this simple? Thanks!