Fronius and PVoutput
I've been playing around with PVoutput.org - it's a community site which lets you quickly and easily publish live details of your solar panels.
I couldn't see a pre-built library for my model of Solar Power Inverter - the Fronius - so I thought I'd build one.
Important: the PVoutput API doesn't run over HTTPS. All of your communications with it are in the clear. While there's a limit to the amount of damage a malicious party could do, be aware that your API key isn't secure.
The API is fairly simple. You need to register for an API key and add a system.
http://pvoutput.org/service/r2/addstatus.jsp? key=ABC123 //API Key &sid=123456 //System ID &d=20141107 //YYYYMMDD &t=14:37 //HH:mm &v2=1337 //Watts being generated
Requests can be sent once every five minutes. You can bulk upload the day's data in CSV format - but where's the fun in that?
Getting The Data
If your Fronius inverter is connected to your network, and you know the IP, getting data is really simple:
http://192.168.1.99/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=1&DataCollection=CommonInverterData
This will give you a JSON file which should look something like this:
{
"Head" : {
"RequestArguments" : {
"DataCollection" : "CommonInverterData",
"DeviceClass" : "Inverter",
"DeviceId" : "1",
"Scope" : "Device"
},
"Status" : {
"Code" : 0,
"Reason" : "",
"UserMessage" : ""
},
"Timestamp" : "2014-11-06T11:40:32+00:00"
},
"Body" : {
"Data" : {
"DAY_ENERGY" : {
"Value" : 3000,
"Unit" : "Wh"
},
"FAC" : {
"Value" : 50,
"Unit" : "Hz"
},
"IAC" : {
"Value" : 1.36,
"Unit" : "A"
},
"IDC" : {
"Value" : 1.05,
"Unit" : "A"
},
"PAC" : {
"Value" : 334,
"Unit" : "W"
},
...
The value of live generation is "PAC".
Putting It All Together
$apiURL = "http://".$dataManagerIP."/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=1&DataCollection=CommonInverterData";
// Get the raw JSON
$jsonData = file_get_contents($apiURL);
// Decode into an object
$solar = json_decode($jsonData, true);
// Real time AC being fed into the mains
$solarPower = $solar["Body"]["Data"]["PAC"]["Value"];
// Send to PVoutput.org
$pvOutputURL = "http://pvoutput.org/service/r2/addstatus.jsp?"
. "key=ABC123"
. "&sid=12345"
. "&d=" . date('Ymd', time())
. "&t=" . date('H:i', time())
. "&v2=" . $solarPower;
file_get_contents(trim($pvOutputURL));
That's pretty much it. Call the script every 5 minutes and enjoy your lovely live graphs.
Terence Eden says:
skozzy says:
@edent says:
B-man says:
@edent says:
cron
. There's documentation for it at https://www.raspberrypi.org/documentation/linux/usage/cron.mdB-man says:
@edent says:
B-man says:
B-Man says:
@edent says:
Wafa'a says: