Terence Eden. He has a beard and is smiling.
Theme Switcher:

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

· 5 comments · 400 words · Viewed ~682 times


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<?php

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

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

//  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}&quot;);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//  Use cookies
curl_setopt($ch, CURLOPT_COOKIEJAR,  &#039;/tmp/cookies.txt&#039;);
curl_setopt($ch, CURLOPT_COOKIEFILE, &#039;/tmp/cookies.txt&#039;);
$output = curl_exec($ch);

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

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

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

Share this post on…

5 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

    Reply

  2. 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.

    Reply

  3. Thanks, you saved my day (and some grey hair) - could not figure out to properly calculate the current consumption between 2 inverters and a battery, now I do have a somehow good value to go with.

    Reply

What links here from around this blog?

  1. How many connected devices do you have at home?
  2. 8000 on a generation meter.Eight MegaWatt Hours, baby!

What are your reckons?

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

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

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.