Push Fronius log data from the past into PV Output?

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