Fronius SYMO Gen24 API to PVOutput Code (prefer python)

Hi all

Now I have searched and search this forum and others and githubs for my answer but I just can’t get it to work properly

I am not a programmer I am just bumbling around the code with some Chat GPT AI help

This the equipment I have
RPI3 - RPIOS 32bit
Symo GEN24 10.0 3 phase
A fronius Smartmeter
Solar API on and verified - see below

Connection to my inverter on IP
I can see the data from my inverter when I poll this address
I can see the data from the fronius smart meter when I poll this address

This inverter is a new type so no menu to push the data in the firmware just the solar API.

I have been trying to interface the solar API with the API with limited success

I have connected 3 times from a manual push using the below code but I don’t think I have all the right information.

I have been using this as my main code

Main Code

import requests
import json
from datetime import datetime
import pytz

Set the timezone to Melbourne, Australia

melbourne = pytz.timezone(‘Australia/Melbourne’)

Make the API call to get the data

url = “
response = requests.get(url)
data = json.loads(response.text)

Extract the relevant data from the response

power = data[“Body”][“Data”][“PAC”][“Value”]
energy = data[“Body”][“Data”][“DAY_ENERGY”][“Value”]

Get the current time in Melbourne

now =

Format the date and time in the required format

date_str = now.strftime("%Y%m%d")
time_str = now.strftime("%H:%M")

Set the headers for the PVOutput API call

headers = {
‘X-Pvoutput-Apikey’: ‘THIS IS MY KEY - it is correct in my version’,
‘X-Pvoutput-SystemId’: ‘86587’

Make the API call to PVOutput

url = f"{date_str}&t={time_str}&v1={power}&v2={energy}"
response = requests.get(url, headers=headers)

Print the response to check for errors


But I don’t think it is getting all the data it should be as it is just over writing the last data sent to PVO instead of updating as per the table below.

Date Time Energy Efficiency Power Average Normalised Temperature Voltage Energy Used Power Used
28/01/23 5:45PM 6.910kWh 0.521kWh/kW - 0W 0.000kW/kW - - 0.000kWh -
28/01/23 5:40PM 6.910kWh 0.521kWh/kW 0W 0W 0.000kW/kW - 238.0V 0.000kWh -
28/01/23 4:30PM 6.910kWh 0.521kWh/kW 0W 0W 0.000kW/kW - 239.5V 0.000kWh -
28/01/23 2:05PM 6.910kWh 0.521kWh/kW - 0W 0.000kW/kW -1.0C - 0.000kWh -
28/01/23 2:00PM 6.910kWh 0.521kWh/kW - 0W 0.000kW/kW -1.0C - 0.000kWh -
28/01/23 1:30PM 6.910kWh 0.521kWh/kW 0W 0W 0.000kW/kW -1.0C - 0.000kWh -
28/01/23 1:10PM 6.910kWh 0.521kWh/kW - - - - - 0.000kWh -

Now I really want the following code to work that I found on GitHub from someone here in Melbourne and it has HA integration as well which I will also be investigating later on. So my question is help how can I install this code and have it upload to PVO every 5 mins. Remember you are talking to someone that is not tech savvy


The code should run on the RPI3 connected to your local network and the internet, the setup instructions are on the project page, but will be a steep learning curve if you don’t have any coding experience.

It would help if you posted your actual code and how you are calling it then we could see if there are any issues with it.

You have asked for a Python solution but the code snippets you have posted have syntax errors for python if that is how you are .

The Fronius GEN24 API and the API for the Symo and Primo are, unhelpfully, quite different to each other. The GEN24 API provides far less information.

You will need to ensure that any API calls that you make to your ( GEN24 ) inverter, using or derived from the linked GitHub script, are correct and return what you expect.

The GitHub script was last updated 2 years ago so is unlikely to work ‘out of the box’ on your GEN24.

Okay I think I am getting close I have got a php script working and now am working on the python version. You can get the php script here at my GitHub

And I have just setup a schedule on my Synology NAS to handle the uploads I hope it works :stuck_out_tongue: Will find out tomorrow for sure

Okay I can confirm that I am uploading data to PVO every 5 minutes from my synology NAS which is good. Now I am wondering how does the data line up with the live graphs? what information needs to be aligned with the live data on PVO

Energy => I dont know where this figure is coming from as I am not pushing v1 data
Efficiency => What is this figure
Power => PAC => v2 => Is been shown
Average => What is this figure
Normalised => What is this figure
Temperature => No Temperature monitoring in inverter
Voltage => I will add this to the system but will need to average it across 3 phases
Energy Used => EnergyReal_WAC_Sum_Consumed => v3 => Not been shown??? meter data
Power Used => PowerReal_P_Sum => v4 => Not been shown??? meter data

I suppose what I am asking is which figures go where for the tables in the graphs. Do I have to do some math to calculate these values?

I wish PV Beancounter worked with the new API from fronius my parents sunnyboy data has been going strong now for a week and is a god send for that old system.

@gregbath here is my code


// Inverter IP Address
$ipAddress = ‘’; // Add your IP Address of your Fronius Inverter here

// PVOutput API key
$pvoutputAPIKey = “”; // Add your PVOutput API key

// PVOutput System ID
$pvoutputSystemId = “”; // Add your PVOutput System ID

// Get current date and time
$date = date(“Ymd”);
$time = date(“H:i”);

// Get data from the inverter
$inverterData = file_get_contents(“http://$ipAddress/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=%%id%%&DataCollection=CommonInverterData”);
$inverterData = json_decode($inverterData, true);

// Get the power value from the inverter data
$power = $inverterData[“Body”][“Data”][“PAC”][“Value”];

// Get data from the meter
$meterData = file_get_contents(“http://$ipAddress/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=0”);
$meterData = json_decode($meterData, true);

// Get the energy consumption and power consumption values from the meter data
$energy_consumption = $meterData[“Body”][“Data”][“EnergyReal_WAC_Sum_Consumed”][“Value”];
$power_consumption = $meterData[“Body”][“Data”][“PowerReal_P_Sum”][“Value”];

// Add data to the request
$data = [
“d” => $date,
“t” => $time,
“v2” => $power,
“v3” => $energy_consumption,
“v4” => $power_consumption,

// Prepare and send the request to PVOutput
$url = “”;
$options = [
“http” => [
“header” => [
“X-Pvoutput-Apikey: $pvoutputAPIKey”,
“X-Pvoutput-SystemId: $pvoutputSystemId”,
“method” => “POST”,
“content” => http_build_query($data),
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

// Check the result
if ($result === false) {
echo “Request failed”;
} else {
echo “Data added successfully”;


Calculated from v2 uploaded.

Energy Generation (kWh) divided by system size (kW)

Calculated average power generation over 5 minutes from energy.

Power Generation (kW) divided by system size (kW)

Check that both values are positive and only increasing for v3 and reset back to 0 at the start of the day.

So I am trying to update my code to include a few more values is this correct?


// Inverter IP Address
$ipAddress = ‘’;

// PVOutput API key
$pvoutputAPIKey = “”; // Replace with your actual PVOutput API key

// PVOutput System ID
$pvoutputSystemId = “”; // Replace with your actual PVOutput System ID

// Get current date and time
$date = date(“Ymd”);
$time = date(“H:i”);

// Get data from the inverter
$inverterData = file_get_contents(“http://$ipAddress/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=1&DataCollection=CommonInverterData”);
$inverterData = json_decode($inverterData, true);

// Print the inverter data for debugging
echo “Inverter Data:\n”;

// Extract relevant inverter data
$pac = isset($inverterData[“Body”][“Data”][“PAC”][“Value”]) ? $inverterData[“Body”][“Data”][“PAC”][“Value”] : null;
$uac = isset($inverterData[“Body”][“Data”][“UAC”][“Value”]) ? $inverterData[“Body”][“Data”][“UAC”][“Value”] : null;
$idc = isset($inverterData[“Body”][“Data”][“IDC”][“Value”]) ? $inverterData[“Body”][“Data”][“IDC”][“Value”] : null;
$udc = isset($inverterData[“Body”][“Data”][“UDC”][“Value”]) ? $inverterData[“Body”][“Data”][“UDC”][“Value”] : null;
$total_energy = isset($inverterData[“Body”][“Data”][“TOTAL_ENERGY”][“Value”]) ? $inverterData[“Body”][“Data”][“TOTAL_ENERGY”][“Value”] : null;
$temperature = isset($inverterData[“Body”][“Data”][“FAC”][“Value”]) ? $inverterData[“Body”][“Data”][“FAC”][“Value”] : null; // Assuming temperature data is available
$voltage = isset($inverterData[“Body”][“Data”][“UAC”][“Value”]) ? $inverterData[“Body”][“Data”][“UAC”][“Value”] : null; // Voltage data

// Get data from the meter
$meterData = file_get_contents(“http://$ipAddress/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=0”);
$meterData = json_decode($meterData, true);

// Print the meter data for debugging
echo “\nMeter Data:\n”;

// Extract relevant meter data
$power_consumption = isset($meterData[“Body”][“Data”][“PowerReal_P_Sum”][“Value”]) ? $meterData[“Body”][“Data”][“PowerReal_P_Sum”][“Value”] : null;
$total_energy_consumed = isset($meterData[“Body”][“Data”][“EnergyReal_WAC_Sum_Consumed”][“Value”]) ? $meterData[“Body”][“Data”][“EnergyReal_WAC_Sum_Consumed”][“Value”] : null;

// Calculate the power self-consumed
$power_self_consumed = ($power_consumption !== null && $pac !== null) ? $power_consumption - $pac : null;

// Prepare the data to be sent to PVOutput
$data = [
“d” => $date,
“t” => $time,
“v1” => $total_energy, // Cumulative energy generation
“v2” => $pac,
“v3” => $total_energy_consumed,
“v4” => $power_consumption,
“v5” => $temperature,
“v6” => $voltage, // Voltage data
“v7” => $uac,
“v8” => $idc,
“v9” => $udc,
“v10” => null, // Placeholder for custom data (not used)
“v11” => null, // Placeholder for custom data (not used)
“v12” => $power_self_consumed, // Custom field for self-consumption

// Prepare the HTTP POST data
$postData = http_build_query($data);

// Set up options for the HTTP context
$options = [
‘http’ => [
‘header’ => “Content-type: application/x-www-form-urlencoded\r\n” .
“X-Pvoutput-Apikey: $pvoutputAPIKey\r\n” .
“X-Pvoutput-SystemId: $pvoutputSystemId”,
‘method’ => ‘POST’,
‘content’ => $postData,

// Create a stream context for the HTTP request
$context = stream_context_create($options);

// Send the data to PVOutput
$result = file_get_contents(‘’, false, $context);

if ($result === false) {
echo "Request failed. Error: " . print_r(error_get_last(), true);
} else {
echo “Data added successfully”;


I can’t get it to upload to pvoutput

The text editor that I use [ BBEdit ] very conveniently performs colour syntax highlighting of PHP code.

When I copied and pasted your code [ above ] into the text editor it didn’t ‘like’ the inverted commas / quotation marks that you have used to delimit strings. Both the single and double quotes in the code were an issue. Attempting the run the code as is resulted in many errors. When I replaced the offending punctuation the syntax errors went away.

What editor did you use to create / edit the script? Did the process you use to post the code to the PVO forum alter the code?

I’ve seen this happen in many forums. It’s usually the forum code that “coverts” quotes to the starting ones being inverted. Not sure if when pasting code on this one if it would leave it alone if you use the preformatted text button or maybe the blockquote. Some forums actually have a code block for pasting code so it will leave the formatting alone, etc.

Edit: Notice the quotes I entered above the opening quotes are inverted. I did not type them that way the forum code changed them when saved. It also did the same thing to your single quotes around the word like in your post.