Push Fronius log data from the past into PV Output?

Hi @jonnoc

What output do you get if you put the following into a browser? Depending on your local DNS you may need to use the Fronius’ IP rather than ‘fronius’.

http://fronius/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System

It should return a ‘screenful’ of data.

Grannos

I’m not able to use ‘fronius’ as it does not seem to be registered on my router as such but if I enter the IP address in the URL link you requested I get the following output:

{
“Body” : {
“Data” : {
“0” : {
“Current_AC_Phase_1” : 4.1790000000000003,
“Current_AC_Sum” : 4.1790000000000003,
“Details” : {
“Manufacturer” : “Fronius”,
“Model” : “Smart Meter 63A-1”,
“Serial” : “2xxxxxxx”
},
“Enable” : 1,
“EnergyReactive_VArAC_Phase_1_Consumed” : 12216970,
“EnergyReactive_VArAC_Phase_1_Produced” : 47856630,
“EnergyReactive_VArAC_Sum_Consumed” : 12216970,
“EnergyReactive_VArAC_Sum_Produced” : 47856630,
“EnergyReal_WAC_Minus_Absolute” : 12911235,
“EnergyReal_WAC_Phase_1_Consumed” : 5069201,
“EnergyReal_WAC_Phase_1_Produced” : 12911235,
“EnergyReal_WAC_Plus_Absolute” : 5069201,
“EnergyReal_WAC_Sum_Consumed” : 5069201,
“EnergyReal_WAC_Sum_Produced” : 12911235,
“Frequency_Phase_Average” : 50,
“Meter_Location_Current” : 0,
“PowerApparent_S_Phase_1” : 988.33000000000004,
“PowerApparent_S_Sum” : 988.33000000000004,
“PowerFactor_Phase_1” : 0.78000000000000003,
“PowerFactor_Sum” : 0.78000000000000003,
“PowerReactive_Q_Phase_1” : -504.64999999999998,
“PowerReactive_Q_Sum” : -504.64999999999998,
“PowerReal_P_Phase_1” : 780.28999999999996,
“PowerReal_P_Sum” : 780.28999999999996,
“TimeStamp” : 1644925657,
“Visible” : 1,
“Voltage_AC_Phase_1” : 236.5
}
}
},
“Head” : {
“RequestArguments” : {
“DeviceClass” : “Meter”,
“Scope” : “System”
},
“Status” : {
“Code” : 0,
“Reason” : “”,
“UserMessage” : “”
},
“Timestamp” : “2022-02-15T21:47:38+10:00”
}
}

If I do a ping -a 192.168.1.200 via cmd on my system I don’t get a hostname back but I can ping the unit fine. If I do an nslookup on the same IP address I get the following back: *** UnKnown can’t find 192.168.1.200: Non-existent domain

I also checked my Asus router that gives out IP addresses and it lists the device as “u-blox AG” but that does not allow me to ping that name

If I login to my inverter directly and goto “System information”
I see the following details:

Inverter
No Device type PMC Serial number
1 Fronius Primo 8.2-1 31191001154400485|4,071,334|1.4D_I|RECERBO|R| 3xxxxxxx
Meter
No Device type Location of the meter Serial number
1 Smart Meter 63A-1 Feed-in point (Primary meter) 2xxxxxxx

Essentially the serial number listed in the PHP output file starts with a ‘2’ as does the API link you posted however I’ve noticed this is the serial number of the Smart Meter and not the inverter (is that correct or could that be the issue possibly?) I could possibly manually enter the serial number starting with ‘3’ being the inverters in the PHP file and try again ?

@jonnoc,

Well it took me a while to work out what’s going on… After doing some digging I’ve discovered that the API call to the Fronius inverter is returning the data in a slightly different format now. I have updated my

Fronius inverter’s firmware several times since I wrote the script and it has been quite some time since I used the script [ posted above ]. Clearly at some point Fronius have changed the formatting for whatever reason.

In the original version of the API call GetArchiveData.cgi the Data Meter’s serial number was returned as:

"meter: 17380***" :

but now it is returned as:

"meter:IME - Smart Meter 63A - 17380***"

The change in format caused the json_decode() function calls to fail.

To fix the script so that it works with the newer version of the Fronius inverter firmware two changes are required - see blow.

A problem that I foresee is that the change that I have made will work only if the installed meter is a ‘Smart Meter 63A’. The data that you posted above shows that you have a ‘Smart Meter 63A-1’.

I will modify my script ( & repost it to PVO ) so that it extracts the ‘Model’ from GetMeterRealtimeData.cgi and uses that value to generate the function call that parses the returned Archive Data. You will need to append ‘-1’ to the model number.

REPLACE
$EnergyReal_WAC_Minus_Absolute = $arr["Body"]["Data"]["meter:" . $meterSerial]["Data"]["EnergyReal_WAC_Minus_Absolute"]["Values"][$x];

WITH
$EnergyReal_WAC_Minus_Absolute = $arr["Body"]["Data"]["meter:IME - Smart Meter 63A - " . $meterSerial]["Data"]["EnergyReal_WAC_Minus_Absolute"]["Values"][$x];

REPLACE
$EnergyReal_WAC_Plus_Absolute = $arr["Body"]["Data"]["meter:" . $meterSerial]["Data"]["EnergyReal_WAC_Plus_Absolute"]["Values"][$x];

WITH
$EnergyReal_WAC_Plus_Absolute = $arr["Body"]["Data"]["meter:IME - Smart Meter 63A - " . $meterSerial]["Data"]["EnergyReal_WAC_Plus_Absolute"]["Values"][$x];

Grannos

All,

Fronius appear to have changed the format of the data returned by the API call GetArchiveData.cgi. I have downloaded the latest version of the API documentation from Fronius’ website to check. The API documentation does NOT appear to have been updated. I have emailed Fronius some questions relating to the change. Watch this space.

If I query http://fronius/solar_api/GetAPIVersion.cgi I see:

{
“APIVersion” : 1,
“BaseURL” : “/solar_api/v1/”,
“CompatibilityRange” : “1.8-1”
}

I have altered the script [ shown inline above ] to extract the Smart Meter’s model number and use it in the JSON parsing. In theory it should work correctly with different model meters. I cannot however test it against older versions of the Fronius in which case the older version of the PHP script should still work. I will post a copy of my updated script after some further testing.

I do not know which firmware update broke the script.

Grannos

Thanks very much for that with the changes mentioned it seems to be working now, eg, snips from morning, midday and evening :slight_smile:

Time Energy Generated Power Generated Energy Consumed
2:00 0 0 891
2:05 0 0 914
2:10 0 0 939
2:15 0 0 977
2:20 0 0 1021
2:25 0 0 1064
2:30 0 0 1107
2:35 0 0 1150
2:40 0 0 1188
2:45 0 0 1220
2:50 0 0 1252
2:55 0 0 1277
3:00 0 0 1310
12:00 21427.55111 5404.016556 9468.551111
12:05 21946.20861 6286.757576 9570.208611
12:10 22423.79139 5693.039735 9681.791389
12:15 22948.13722 6355.707071 9791.137222
12:20 23486.02361 6411.890728 9919.023611
12:25 24021.57472 6491.52862 10041.57472
12:30 24569.65056 6533.354305 10173.65056
12:35 25107.46861 6519.006734 10295.46861
12:40 25633.77139 6358.020134 10426.77139
12:45 26079.42583 5294.90429 10552.42583
12:50 26355.09889 3341.491582 10661.09889
12:55 26878.86028 6243.513245 10774.86028
20:00 42566.14361 0 25697.14361
20:05 42566.14361 0 25848.14361
20:10 42566.14361 0 26152.14361
20:15 42566.14361 0 26484.14361
20:20 42566.14361 0 26695.14361
20:25 42566.14361 0 26845.14361
20:30 42566.14361 0 26999.14361
20:35 42566.14361 0 27151.14361
20:40 42566.14361 0 27301.14361
20:45 42566.14361 0 27437.14361
20:50 42566.14361 0 27563.14361
20:55 42566.14361 0 27651.14361
21:00 42566.14361 0 27724.14361

Sorry this might be a silly question but is it at all possible to also include in the data ‘exported’ and ‘consumption’ as it seems the current ‘energy consumed’ is a total of something? I might have a read through your script and try understand how it all works to get a better idea of what’s possible and how it matches up to the Fronius API…etc…

Appreciate all your work and help!
Cheers!

Hi @jonnoc.

The exported columns were chosen to be in the correct format for the PVO LIveLoader Bulk Loading — PVOutput documentation. Both Energy values are cumulative and PVO expects cumulative figures.

If you’d like to see the 5 minutely interval figures it would be a fairly straightforward exercise to subtract one 5 minutely figure from its successor.

The script achieves a similar thing by preserving the starting MIDNIGHT figure and subtracting it from each of the successive amounts. You could simply subtract adjacent cumulative figures.

The $EnergyReal_WAC_Minus_Absolute and $EnergyReal_WAC_Plus_Absolute values represent the energy flowing through the Smart Meter.

	if ( $x == 0 ) 
		{
		$startMinus = $EnergyReal_WAC_Minus_Absolute;
		$startPlus =  $EnergyReal_WAC_Plus_Absolute;
		}	

The meter itself reports cumulative lifetime figures whereas the script is designed to generate daily cumulative figures. The script generated energy fields therefore start at 0Wh each day.

grannos

1 Like

All worked great, thanks for all your help… :slight_smile:

Now the next project trying to export all the daily data as far back as I can to add it to my profile as I already hit the 14-day limit but at least I have a little more history in the system now… :slight_smile:

Thank you grannos much appreciated and saved yours of manual entry

Hi Grannos, just wanted to say thanks for your script, as I’ve used it to recover and upload a couple of days of missing data. Cheers, Tim

Hi Tim,

Thanks for the feedback. I’m glad see that it’s still getting some use.

Grannos

1 Like

I tried adding Voltage to the printout, but I am doing something wrong:

Voltage_AC_Phase_1 248.9

The above is what I see when I interrogate the inverter for the channel.

I added it to the URL Grab as:
…lute&Channel=PowerReal_PAC_Sum&Channel=Voltage_AC_Phase_1";

Added the extra label:
echo “Time,Energy Generated,Power Generated,Energy Consumed, Voltage\n”;

But I am not sure how to format it in the array section:

$Voltage_AC_Phase_1 = $arr[“Body”][“Data”]["meter:IME - Smart Meter 63A-1 - " . $meterSerial][“Data”][“Voltage_AC_Phase_1”][“Values”][$x];

AS it is not happy when it tries to pull as it does not seem to find a voltage value:

Warning: Undefined array key “Voltage_AC_Phase_1” in D:\Data\Documents\Solar\getFroniusArchiveData.php on line 45

Warning: Trying to access array offset on value of type null in D:\Data\Documents\Solar\getFroniusArchiveData.php on line 45

Warning: Trying to access array offset on value of type null in D:\Data\Documents\Solar\getFroniusArchiveData.php on line 45
00:40,0,0,281

Hi,

I just tested the CURRENT version of my script against my Symo. I ran it on my iMac using PHP 8.2.12. Both my inverter and Fronius Smart Meter have the latest firmware. I had to make and modifications to the script for quite some time. The same rules apply regarding altering the IP address and required extraction date.

I will re-post the entire script below. The CURRENT script extracts and reports Voltage_AC_Phase_1 AND Temperature_Powerstage by default as I log both of these to PVO.

16:30,29300.149722222,1615.734006734,5351.1497222222,1016.366,640.489,1656.855,50,241.3

16:35,29430.321944444,1577.8451178451,5391.3219444445,962.25,652.176,1614.426,49,241.2

[EDIT]I was able to extract data from the 1st of May 2023 but not the 1st of April 2023 so it is possible to go back quite a few months.[/EDIT]

<?php
/*

{
   "APIVersion" : 1,
   "BaseURL" : "/solar_api/v1/",
   "CompatibilityRange" : "1.8-1"
}
*/

$dataManagerIP = "fronius";
	
// $dataManagerIP = "192.168.78.125";
							
$country = "Australia";
$capitalCity ="Perth";

date_default_timezone_set("$country/$capitalCity");

$date = date('Y-m-d', time());
$pushDate = date('Ymd', time());

// Overide Date for Manual Extract
$date = "2023-08-01";

$time = date('H:i', time());

// Overide Time for Manual Extract
// $time = "23:59";

$inverterDataURL = "http://".$dataManagerIP."/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System";
$inverterJSON = file_get_contents($inverterDataURL);

echo $inverterDataURL . "\n";

$arr = json_decode($inverterJSON, true);

$meterSerial = $arr["Body"]["Data"]["0"]["Details"]["Serial"];
$meterModel = $arr["Body"]["Data"]["0"]["Details"]["Model"];

echo "Meter Serial Number: ", $meterSerial, "\n";
echo "Meter Model Number: ", $meterModel, "\n";

// $inverterDataURL = "http://".$dataManagerIP."/solar_api/v1/GetArchiveData.cgi?Scope=System&StartDate=".$date."&EndDate=".$date."&Channel=EnergyReal_WAC_Sum_Produced&Channel=EnergyReal_WAC_Minus_Absolute&Channel=EnergyReal_WAC_Plus_Absolute&Channel=PowerReal_PAC_Sum";

$inverterDataURL = "http://".$dataManagerIP."/solar_api/v1/GetArchiveData.cgi?Scope=System&StartDate=".$date."&EndDate=".$date."&Channel=EnergyReal_WAC_Sum_Produced&Channel=EnergyReal_WAC_Minus_Absolute&Channel=EnergyReal_WAC_Plus_Absolute&Channel=PowerReal_PAC_Sum&Channel=Voltage_DC_String_1&Channel=Current_DC_String_1&Channel=Voltage_DC_String_2&Channel=Current_DC_String_2&Channel=Temperature_Powerstage&Channel=Voltage_AC_Phase_1";
    
$inverterJSON = file_get_contents($inverterDataURL);

echo $inverterDataURL, "\n";

$inverterJSON = file_get_contents($inverterDataURL);
$arr = json_decode($inverterJSON, true);

$x = 0;

$EnergyReal_WAC_Sum_Cumulative = 0;

echo "Time,v1,v2,v3,MPP1,MPP2,MPPT,InvTemp,v6\n";

while ( $x < 86400 && gmdate("H:i", $x) <= $time )
	{
	$EnergyReal_WAC_Sum_Produced = $arr["Body"]["Data"]["inverter/1"]["Data"]["EnergyReal_WAC_Sum_Produced"]["Values"][$x];
	$EnergyReal_WAC_Minus_Absolute = $arr["Body"]["Data"]["meter:IME - " . $meterModel . " - " . $meterSerial]["Data"]["EnergyReal_WAC_Minus_Absolute"]["Values"][$x];
	$EnergyReal_WAC_Plus_Absolute = $arr["Body"]["Data"]["meter:IME - " . $meterModel . " - " . $meterSerial]["Data"]["EnergyReal_WAC_Plus_Absolute"]["Values"][$x];
	$PowerReal_PAC_Sum = $arr["Body"]["Data"]["inverter/1"]["Data"]["PowerReal_PAC_Sum"]["Values"][$x];
	$EnergyReal_WAC_Sum_Cumulative += $EnergyReal_WAC_Sum_Produced;
	
	$Voltage_AC_Phase_1 = $arr["Body"]["Data"]["inverter/1"]["Data"]["Voltage_AC_Phase_1"]["Values"][$x];
	
	$i1 = $arr["Body"]["Data"]["inverter/1"]["Data"]["Current_DC_String_1"]["Values"][$x];
	$i2 = $arr["Body"]["Data"]["inverter/1"]["Data"]["Current_DC_String_2"]["Values"][$x];
    $V1 = $arr["Body"]["Data"]["inverter/1"]["Data"]["Voltage_DC_String_1"]["Values"][$x];
    $V2 = $arr["Body"]["Data"]["inverter/1"]["Data"]["Voltage_DC_String_2"]["Values"][$x];
    $InverterTemperature = $arr["Body"]["Data"]["inverter/1"]["Data"]["Temperature_Powerstage"]["Values"][$x];

    $P1 = $V1 * $i1;
    $P2 = $V2 * $i2;
    $PTOTAL = $P1 + $P2;
	
	if ( $x == 0 ) 
		{
		$startMinus = $EnergyReal_WAC_Minus_Absolute;
		$startPlus =  $EnergyReal_WAC_Plus_Absolute;
		}	
	
	$deltaMinus = $EnergyReal_WAC_Minus_Absolute - $startMinus;
	$deltaPlus = $EnergyReal_WAC_Plus_Absolute - $startPlus;
	
	$consumed = $deltaPlus - $deltaMinus + $EnergyReal_WAC_Sum_Cumulative;
	$time_value = gmdate("H:i", $x);
	echo gmdate("H:i", $x) . "," . $EnergyReal_WAC_Sum_Cumulative . "," . $PowerReal_PAC_Sum . "," . $consumed . "," . $P1 . "," . $P2 . "," . $PTOTAL . "," . $InverterTemperature . "," . $Voltage_AC_Phase_1 . "\n";
	// echo gmdate("H:i", $x) . "," . $EnergyReal_WAC_Sum_Cumulative . "," . $PowerReal_PAC_Sum . "," . $consumed . "," . $deltaMinus . "," . $deltaPlus . "\n";
    $x += 300;
	
	}	
?>

Thank you for that. This is my clipped output from my Fronius Primo 5K inverter.
I just used my fixed IP and set teh date and time as usual.:

some_ip_value/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System
Meter Serial Number: xxxxxxxx
Meter Model Number: Smart Meter 63A-1
http://some_ip_value/solar_api/v1/GetArchiveData.cgi?Scope=System&StartDate=2023-11-17&EndDate=2023-11-17&Channel=EnergyReal_WAC_Sum_Produced&Channel=EnergyReal_WAC_Minus_Absolute&Channel=EnergyReal_WAC_Plus_Absolute&Channel=PowerReal_PAC_Sum&Channel=Voltage_DC_String_1&Channel=Current_DC_String_1&Channel=Voltage_DC_String_2&Channel=Current_DC_String_2&Channel=Temperature_Powerstage&Channel=Voltage_AC_Phase_1
Time,v1,v2,v3,MPP1,MPP2,MPPT,InvTemp,v6

05:25,0.87416666666667,10.420529801325,2974.8741666667,43.979,22.864,66.843,22,225.5
05:30,5.8625,60.464646464646,3054.8625,61.758,25.09,86.848,24,244.6
05:35,13.366944444444,89.456953642384,3127.3669444444,81.673,32.835,114.508,27,244.9
05:40,22.786388888889,114.17508417508,3195.7863888889,94.122,43.568,137.69,29,245
05:45,34.263055555556,136.80794701987,3269.2630555556,112.064,48.18,160.244,31,244.6

Exactly what I need. Appreciate the quick response.
The header is not working right, but can work out the columns fine.

Hi. Glad it works. I extract and upload the DC power values of both strings and upload them to my PVO account. You can either amend the script so that it does not output the extra column headers and fields or simply not upload them to PVO.

Yep, I will just disable the additional columns for PVO upload. They make that nice and simple. Thanks again

Thanks for the script grannos, your work on it is greatly appreciated.
I noticed a few issues for my setup stemming from a different smart meter:
“CCS WattNode WND-3D-480-MB”
My simple fix was to change IME > CCS on lines ~64 + 65 from memory. Worked a treat after that.

Hi thanks for the feedback. I am glad that the script was of use to you.

@grannos - Just gave this a go and it worked. Awesome! Much easier than the manual Excel route.

Some feedback:

Could be worth adding an example rather than ‘fronius’ and how you can find this. For me it was via the home network. Probably a simplier way.

$dataManagerIP = “192.168.68.XXX”;

I found it a little confusing to know exactly what to comment out or not on dates and time. Once I got it working I added the two lines below so it is clear on the range.

echo "Date: ", $date, “\n”;
echo "Time: ", $time, “\n”;

One last thing.

I am now trying to upload the output to PVO via the Live Loader. I only need Time, Energy Generation (Wh), Power Generation (W), Energy Consumption (Wh) and Power Used (W).

Is this right?

Date Format = CSV
Output Daye = yyyy-mm-dd
Energy Values = Daily Cumulative or daily interval?
Fields:
Time = 1 HH24:mm
Power Generation = 2 W
Power Consumption = 3 W

echo "Time,v1,v2,v3,MPP1,MPP2,MPPT,InvTemp,v6\n";
// EnergyReal_WAC_Sum_Cumulative . "," . $PowerReal_PAC_Sum . "," . $consumed . "," . $P1 . "," . $P2 . "," . $PTOTAL . "," . $InverterTemperature . "," . $Voltage_AC_Phase_1 
// 1 = Time (HH24:mm)
// 2 = EnergyReal_WAC_Sum_Cumulative
// 3 = PowerReal_PAC_Sum
// 4 = consumed
// 5 = P1 
// 6 = P2 
// 7 = PTOTAL 
// 8 = InverterTemperature
// 9 = Voltage_AC_Phase_1