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.

PVoutput chart

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.


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

14 thoughts on “Fronius and PVoutput”

  1. says:

    Thanks for the brilliant write up on your solar project, it's helped me understand solar data capture tremendously. I have a Fronius 12 kwatt inverter and 48 panels, and have been running the system for a year with near zero visibility into actual production. The solar installers will add the data capture card for $1000, but I really like the idea of using PVoutput, and not being wholly captive to the inverter manufacturer. I've seen others using the Raspberry Pi to run scripts or even as a data probe(?), so I am wondering whether running this script renders the Raspberry extraneous, or whether it might be still be useful either connected directly to the board or to the router, if nothing else to simply run the script on a dedicated schedule. Thanks again! Joe

    Reply
    1. Terence Eden says:

      I use a dedicated small server - like a Raspberry Pi - to run the script. Go for it 🙂

      Reply
  2. skozzy says:

    If I copy your code to a text editor, change the key and sid, what do I save the file as, and how do I run the script.

    Reply
  3. B-man says:

    i have a pi that's doing data collecting for a solar hot water system

    is this basically as easy as putting it on the pi and running some command to upload every 5 minutes? other than changing the api system id etc?

    how do i run it every 5 minutes on the pi?

    Reply
      1. B-man says:

        ok cheers. is there a download of the file or do i just copy the Putting It All Together code?

        do i replace ".$dataManagerIP." with the ip address of the inverter? and add my key and sid to below . "key=ABC123" . "&sid=12345"

        Reply
        1. @edent says:

          Just copy and paste. You then add your IP and other details as you described.

          Reply
  4. B-Man says:

    any chance of getting other data from the inverter? Say MPP1 and MPP2 power and voltage?

    Reply
  5. Wafa'a says:

    Thanks so much for sharing the script! I am trying to access Fronius inverter API via the internet. I already have the access credentials( API key ID and the key-value). The API documentation refers to the access via the local network and mentions nothing about using the WAN(Internet). I will appreciate any comments or advice about how I can write GET requests to get solar data using the WAN network.

    Reply

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">