Virtual Feed logic based on comparison of two Feeds?

I have a self-hosted emoncms, setup with inputs from various sensors covering electricity, hot water, central heating.

Recently i’ve had solar PV installed on the house, which has 2 separate inverters due to the system size. The outputs from these inverters goes through a junction box, and from there a single wire goes to my distribution board (consumer unit) - so essentially a solar type-2 arrangement.
I also have a Solar iboost, which diverts excess solar to the hot water immersion heater (and so far it’s working very effectively; 200L heated by 11 C yesterday afternoon).

I have 4 CTs as follows (feed names in " ")
1 “GRID” in the meter cupboard, between the main supply meter and the henley block (from there the cable goes to the consumer distribution board).
2 for the PV, “PV1” and “PV2” - one after each inverter, before they merge in the junction box.
…i want to track them separately to better understand how each solar string gets the sun.
1 “DIVERT” on the mains supply spur that goes to the solar iboost.

Now, the challenge I have is that the CTs i’m using are not directional, so i’m trying to figure out how to determine what is import and what is export.
So instead of showing negative values, my GRID CT shows a +ve for export, and a +ve for import (and an eerie near-zero figure if current PV and House Usage are balanced!)

At this point I don’t want to purchase more CTs, especially when in theory the CT data I do have should be enough to perform the sums for the outputs I want.

I can work through the logic, but am struggling to implement this within emoncms, so far.

Here’s my logic:

  1. virtual feed PVgen = PV1 + PV2…to show total PV generation.
    I have created this and it’s working fine.

  2. house usage/consumption “HOUSE” is:
    2a) If PVgen > GRID, house use is PVgen - GRID - DIVERT

  • this covers when there is excess PV, or no PV.

2b) if PVgen <= GRID, house use is PVgen + GRID

  • this is the awkward middle period, when the PV is producing something but not enough to power the house - i.e. the house is running from a mixture of PV+GRID.

I can then do
NETuse = PVgen - HOUSE
…this will give a -ve value if we’re currently using more than the PV is producing, or a +ve value if the PV is producing more than we’re using.
I realise this excludes anything used by the iboost “DIVERT”, that will have a separate dial-gauge on my dashboard :slight_smile:

So, my question (finally). How do I do the IF logic within a Virtual Feed (or another method if that’s better)

Re: Night time PVgen. I know that overnight my solar CTs report 32W (total), so my assumption is that is the power draw by the inverters (or rather, the CT measurement - I realise they are inaccurate at low readings). So at some point in the logic i’m going to minus 32 from the PVgen figure to account for this.

Edit: I think the logic for 2a isn’t quite right, e.g. if PVgen is 150 and my GRID is 50, is that consumption=100 or consumption=200 ??

Probably need to have some logic for if PVgen>0 somewhere, and use that to then determine which calculation to perform.

Can emoncms do nested IFs (or IF’s with a ‘skip section’ rather than ‘skip next’ process?)

After a bit of pondering and more research, i’ve found the solution.

The OWL sensors i’m using can be used with a Y-cable to join 2 sensors together to a single input.
By placing these sensors 1 between PV and Dist board, and 1 between dist board and grid meter, the net result is the input shows house consumption only.

If PV is generating, and Grid is Exporting, the sensors are a + and a -, so the remainder is what is used in the house.

If PV is generating, and Grid is Importing, the sensors are a + and a +, and that sums is the house usage.

If PV is not generating, then Grid is Importing, and the sensors are 0 and a +, giving the house usage.

Now, I understand how the sensors work like that technically (i;e. the physics behind it) - my new problem is that i cannot physically fit the 2 sensors onto the necessary cables due to the way my distribution board is flush up against the ceiling inside, and the grid meter is in a box outside.
(so can connect the PV CT sensor, but not the grid one).

With the mains fully off (shut off outside, and at PV) i’ve had a good try on 2 separate occasions, but there is no way my CT will fit on the tiny bit on incoming cable (which itself has zero slack) with all the other cables snug up against it…might be time to shop for a smaller sensor…
(new thread for that).

a. Is there room inside the consumer unit for a c.t?
b. How big (or small) is “a tiny bit”?

If you cannot source a suitable split-core c.t. then I think you’re looking at something like CWT Mini, Rogowski, Rogowski Coil, Rogowski sensor, Powertek I’ve never used one, but it’s the only solution that I can think of. The downsides are the price is eye-watering, and it requires an auxiliary power supply.