Hi Gingerbeer, Nietschyl@Nietschy I also have a fronious inverter and smart meter - getting the real time excess current is only half the solution. Have you modified the rest of the code so that the amount of charge actually changes appropriately?
Working through the logic - assuming you are making 5kw of power from the panels and your house is consuming 2kw, then prior to charging you have 3kw of excess. On the first loop the excess mains current means the car charges at 3kw (as desired).
However on the second loop, the AC fed to the mains is now 0 (5kw solar = 2kw house + 3kw car + 0 excess). The Fronius can't distinguish between the house and the car, it simply reports a load = 5kw. If you base the charge current off the excess mains reading, 0 excess causes it to stop charging.
As written, CDragon's code doesn't store the current car current. I modified mine (very inelegantly) so that there is a persistent variable that stores "last_current_to_car", then there is a loop that says "new current to car = last_current_to_car + excess/240".
@CDragon it would be great if you could make this a toggle in the settings or similar, for everyone who has real time load monitoring capabilities as well as real time solar output monitoring.
I also have a Fronius based system (PV inverter + Smartmeter). I have programmed what you want to have in this way.
Set greenEnergyAmpsOffset = 0
and then calculate:
greenEnergyData = SmartMeterReading + self.reportedAmpsActual*HouseVoltage
1st loop the SmarMeterReading is equal to your current energy surplus (Photovoltaic - your house load). The car is allowed to charge with all this surplus. Ex. Phovotoltaic 5kW, house loads 2kW, surplus is 3kW. TWC set to 3kW
2nd loop. Once the car start charging, the surplus decreases as the self.reportedAmpsActual increase. So second loop example (assume TWC has not yet ramped up to 3kW, but instead 1.5kW) Photovoltaic 5kW - house loads 2kW - TWC 1.5kW surplus is 1.5kW add the self.reportedAmpsActual and you get again 3kW. TWC set to 3kW. Is looking good.
3rd loop. Charge ramping done (3kW actual). Example:
SmarMeter reads (Photovoltaik 5kW -house loads 2kW - TWC 3kW) = 0 kW plus TWC current 3kW means Surplus is 3kW. Set TWC to 3kW. All GOOD!
4th loop: Your wife starts the Washingmachine, takes 1kW suddenly. Example
SmarMeter reads (Photovoltaic 5kW - house loads 3 kW - TWC 3kW ) = -1kW plus TWC current 3kW means surplus is 2kW. Set TWC to 2kW. Now we have a dynamic house load algorithm.
Note this works properly if the information from smarmeter and self.reportedAmpsActual are not too out of phase. I could not find in the TWCManager.py the position where the greenEnergyData sample rate is defined. QUESTION TO EXPERTS: Does it poll it every 2s? 10s 60s? I have no idea. Our Smarmeter info gets updated once every 2s (I am using Modbus TCP, I do not like json API), so this *could* be read every 2 s as well, but whether it makes sense depence of how often the TWC commands the slaves with a current value (4s?)