Relaunching @edent_solar. Part 5 - Getting data out of Fronius Solarweb


Mostly notes to myself. My solar panels have an open API. But it's only available if I'm on the same network as the Fronius inverter. I can connect my system to https://www.solarweb.com/ so I can access it anywhere in the world - if I have the right password.

SolarWeb has an (optional) guest mode. You can view the panels' performance if you know the secret URl. It looks something like this:

https://www.solarweb.com/Home/GuestLogOn?pvSystemid=123-456-789

Visiting that URl sets some cookies and then redirects you to something like this:

https://www.solarweb.com/PvSystems/PvSystem?pvSystemId=abc-def-hij

And the live performance data is at:
https://www.solarweb.com/ActualData/GetCompareDataForPvSystem?pvSystemId=abc-def-hij

In order to make a request to the data URl, you need the cookies from the first URl. Here's some horrible PHP which will do just that.

<?php

$ch = curl_init();
//  Get the loging URl
curl_setopt($ch, CURLOPT_URL, "https://www.solarweb.com/Home/GuestLogOn?pvSystemid=123-456-789");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //  It redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//  Store and use cookies
curl_setopt($ch, CURLOPT_COOKIEJAR,  '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');

//  Get the page
curl_exec($ch);

//  Find redirect URL
$redirect_url    = curl_getinfo($ch)["url"];
//  It is in the form https://www.solarweb.com/PvSystems/PvSystem?pvSystemId=abc-def-hij
//  Get the System ID
$system_id_query = parse_url($redirect_url, PHP_URL_QUERY);
parse_str($system_id_query, $params);
$system_id = $params["pvSystemId"];

//  Finish up this request
curl_close($ch);

//  2nd request
$ch = curl_init();
//  URl of the data
curl_setopt($ch, CURLOPT_URL, "https://www.solarweb.com/ActualData/GetCompareDataForPvSystem?pvSystemId={$system_id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//  Use cookies
curl_setopt($ch, CURLOPT_COOKIEJAR,  '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
$output = curl_exec($ch);

//  Output JSON
// header("Content-Type: application/json");
echo $output;
//  Clean up
curl_close($ch);

And, hey presto, out pops a scrap of JSON:

{
   "Datasources":"n/a",
   "IsOnline":true,
   "P_PV":402.0
}

4 thoughts on “Relaunching @edent_solar. Part 5 - Getting data out of Fronius Solarweb

  1. Dear Terence,

    I have 2 solar roofs with a total of 8 converters (to be all newly wired up on 21st of April 2020), 4 existing functioning solarweb / Solarlog, plus 4 new Fronius (new 2nd solar roof). Plus considering a first Tesla Powerwall 2.

    I would live to use your code to get more insight on a daily base, we also working on BerlinElectric.com a plug for plug monitoring to link it all up within the house. my GitHub.com/alexanderstraub

    2 more guys from Berlin working also on it, both engineers like me. Would be appreciate if you get back.

    Best regards,
    Alexander

  2. Kaden says:

    Hi Terence,

    Do you know of a way to get the lifetime generation of the system programmatically? I can access it manually via https://www.solarweb.com/Chart/Chart?pvSystemId=abc-efg-hig -> Total (at the bottom of the chart), but I'm having trouble accessing it programmatically. Trying to replicate the POST request I find with Chrome DevTools leads to some anti-CRSF protections.

Leave a Reply

Your email address will not be published.

%d bloggers like this: