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 192.168.0.76
I can see the data from my inverter when I poll this address
http://192.168.0.76/solar_api/v1/GetInverterRealtimeData.cgiScope=Device&DeviceId=1&DataCollection=CommonInverterData
I can see the data from the fronius smart meter when I poll this address
http://192.168.0.76/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=0

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 pvoutput.org 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 = “http://192.168.0.76/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=1&DataCollection=CommonInverterData
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 = datetime.now(melbourne)

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"https://pvoutput.org/service/r2/addstatus.jsp?d={date_str}&t={time_str}&v1={power}&v2={energy}"
response = requests.get(url, headers=headers)

Print the response to check for errors

print(response.text)

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

Cheers

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

<?php

// 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 = “https://pvoutput.org/service/r2/addstatus.jsp”;
$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.