How to read data direct from Zeversolar Inverter


#4

Do you have the code to grab line 11 and 12?
And or the averaging of instant power.

Is it very difficult to get seperate string power?


#5

Yes.

No.

:rofl:

Sorry, couldn’t resist.

I’m using Node Red on a Raspberry Pi 3, wrote all the code, and set it up to both poll the inverters directly as well as to intercept the traffic between inverters and the Zeversolar cloud, perform the appropriate translations, calculations, & transformations, and then upload the data to both PVOutput as well as Thingspeak.

PVO provides the summary, whilst a bunch of HTML and Javascript I wrote pulls the data from Thingspeak and uses a Highcharts library to present a detailed breakdown.

It isn’t really (yet) a click-and-go type of solution.

What environment are you using?


#6

i have a raspberry pi running my consumption atm using the pvoutput integration service and looking to replace that with a flukso
but will still have the Raspberry Pi1
nothing doing the solar yet as il still trying to get the secret key to do auto uploads for the inverter until i get something going like your setup


#7

i have tried to modify my fronius.php code for the zeversolar

but having issues with opening the http://inverterip/home.cgi
“$inverterJSON = file_get_contents($inverterDataURL);”

its giving me a PHP Warning: file_get_contents(http://inverterip/home.cgi): failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported
in /home/pi/zeversolar/zever.php on line 33

when i type the url into the web browser it displays but i cant get it to open in php so i can grab the information

how do you grab the two lines?

any chance of sharing the code. i only want to grab the 2 lines and post them every 5 minutes


#8

#9

Looks like you’re using the wrong HTTP version (probably 1.0 instead of 1.1). The stackoverflow bankstownbloke points to should help with that.

$inverterJSON

…implies you are treating the result as JSON which will fail. The data returned is plain text which you will need to parse (ie - just extract lines 11 and 12) - and don’t forget to correct the kWh number…

any chance of sharing the code.

Sorry - I’ve written my solution in a completely different environment and language, so won’t help with your PHP method.


#10

if the code can be run on a Raspberry Pi im happy to change. im just editing the php file for the fronius as i have more chance of modifying it to work than coding something from scratch.
would like to get the other inverter data too but happy enough if i can get this running

unsure if im applying it wrong but i still can’t get it to work

<?php
//    /usr/bin/php /home/pi/zeversolar/zever.php
// Configuration Options
$dataManagerIP = "192.168.x.xx";							//Inverter IP Address
$pvOutputApiKEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
$pvOutputSID = "xxxxxx";
$country = "Australia";
$capitalCity ="Adelaide";			
//Settings that can be Used in V7-V12	
// Inverter					

$v7 = "phase1Volts";
$v8 = "phase2Volts";
$v9 = "phase3Volts";
$v10 = "phase1Amps";
$v11 = "phase2Amps";
$v12 = "phase3Amps";

// !!!!!!!!!!!!!!!! DONT EDIT BELOW HERE !!!!!!!!!!!!!!!!!!!
// Define Date & Time
date_default_timezone_set("$country/$capitalCity");
$system_time= time();
$date = date('Ymd', time());
$time = date('H:i', time());
// Inverter API URL
$pvOutputApiURL = "http://pvoutput.org/service/r2/addstatus.jsp?";
$inverterDataURL = "http://".$dataManagerIP."/home.cgi";

// Read Inverter Data
sleep(5);
//$inverterJSON = file_get_contents($inverterDataURL);
//$inverterData = json_decode($inverterJSON, true);


$context = stream_context_create(array('http'=>array('protocol_version'=>'1.1')));
file_get_contents($inverterDataURL, false, $context);

//Echo "$inverterJSON";





// Push to PVOutput
$pvOutputURL = $pvOutputApiURL
            . "key=" .  $pvOutputApiKEY
            . "&sid=" . $pvOutputSID
            . "&d=" .   $date
            . "&t=" .   $time
            . "&v1=" .  $inverterEnergyDayTotal
            . "&v2=" .  $inverterPowerLive
            . "&v6=" .  $inverterVoltageLive
            . "&v7=" .  $$v7
            . "&v8=" .  $$v8
            . "&v9=" .  $$v9
            . "&v10=" . $$v10
            . "&v11=" . $$v11
            . "&v12=" . $$v12;
file_get_contents(trim($pvOutputURL));													
//Print Values to Console
Echo "\n";
Echo "d \t $date\n";
Echo "t \t $time\n";
Echo "v1 \t $inverterEnergyDayTotal\n";
Echo "v2 \t $inverterPowerLive\n";
Echo "v6 \t $inverterVoltageLive\n";
Echo "v7 \t ${$v7}\n";
Echo "v8 \t ${$v8}\n";
Echo "v9 \t ${$v9}\n";
Echo "v10 \t ${$v10}\n";
Echo "v11 \t ${$v11}\n";
Print "v12 \t ${$v12}\n";
Echo "\n";
Echo "Sending data to PVOutput.org \n";
Echo "$pvOutputURL \n";
Echo "\n";


?>

this is the edited version of the fronius.php still messy and left in the same format.
but 1. I cant open the file as for the http error and 2. dont know how to extract the data once i get it open
anyone able to see what im doing wrong?
Im using php5 if that is causing any issues?

i havent been able to get the secret key or api key etc from zeversolar after nearly a month so this is the next step


#11

Oh. You might have to do a lot more Googling…

file_get_contents returns a string, and it also needs a properly formed address.

Try running the following code to get a feel for it:

<?php
    $context = stream_context_create(array('http'=>array('protocol_version'=>'1.1')));
    $result = file_get_contents('http://192.168.2.123/home.cgi', false, $context);
    echo $result;
?>

Replace 192.168.2.123 with the IP address of your inverter.

You should see a number of lines of data - line 11 giving watts and 12 the day’s kWh up to that point - or get an error (say, if you’ve got the wrong IP address, the inverter’s offline because it’s night time, etc)

You will then have to parse the $result string to extract lines 11 and 12, correct the kWh numbers as per my first post, and then submit that to PVOutput.


#12

that seems to work and gives the lines, now to get the data from those lines
cheers 1 more step left!


#13

while trying codes to extract each line the pi i use stopped responding to commands so i rebooted it
and now im getting

PHP Warning:  file_get_contents(http://192.168.x.xx/home.cgi): failed to open stream: HTTP request failed! 1
 in /home/pi/zeversolar/zever3.php on line 3

using the same code that worked beforehand.
has the inverter blacklisted the ip or something? i can ping the inverter but it is quite slow


#14

Can you get to the home.cgi with your web browser?

How complex is your WiFi setup (could the Pi, for instance, be connecting to another AP)?

Try power cycling the Pi.

This should get you on the right path…

$lines=explode("\n",$result);
$watts=$lines[10];
$kWh=$lines[11];

#15

Cheers i couldnt do any more until i got to the parents.

Im accessing the pi from my vpn . Even after a reboot it still wouldnt work.
I can access fine when im there and connect locally. So something has gone wrong over the vpn.
Will have to test that out when i get there next


#16

Use remote.it instead of a VPN - works perfectly in this scenario.


#17

strange it started working again when i got home

that code was perfect. i was actually trying a similar copy of that code but that’s when things went wrong.

i had to times the eTotal ( kwh by 1000 to get it into watts for pvoutput as it displayed 35.2kwh as .035) but by the time i done that the inverter had shut down so will have to see how it goes tomorrow

i have setup cron and appears to be working great
will have to check how it all goes and tidy the code up then will post it up for others wanting to do the same…

one thing i haven’t done is fix the single digit for kwh, Unsure how to do that or if i need to at this stage.

my combox is

Software Version: 17A31-727R
Hardware Version: M11

Thanks for both of your help saved me about 100 days of stuffing around


#18

Just log the numbers & see if they go up in a sensible fashion. PVOutput doesn’t accept reducing kWh numbers (drops them) so your graph ends up with strange jumps.

Also, I strongly suggest you compare the numbers you see on the inverter’s web pages (ie the human readable form) with what you pull off home.cgi to make sure you’re picking up the right numbers.

something like this might help:

$kWh_parts=explode('.', $kWh);
if (strlen($kWh_parts[1]) == 1) {
	$kWh_parts[1] = '0' . $kWh_parts[1];
	$kWh=join('.',$kWh_parts);
}
echo $kWh;

#19

Im not logging any data locally just grabbing it and uploading straight to pvoutput

https://pvoutput.org/intraday.jsp?id=29186&sid=61410
I have noticed sometimes its not displaying/uploading the data and wondering if that is because the energy total is wrong (needs ur fix) or some other issue
Will add the fix when i can and see if it fixes the rest.

Ignore consumption its net metered but havent worked out how to deal with that yet

im thinking its getting this error when its doesnt upload to pvoutput as it errors out before it can do anything. seems to be hit and miss if it works or not.

PHP Warning: file_get_contents(http://192.168.x.xx/home.cgi): failed to open stream: HTTP request failed! 1

is there an easy way to write a log file of each result whether its everything or just if there’s that error and the results and echos so i can view whats breaking it?

i found some code to retry on error but i have other errors that don’t stop it working but if i ran that it would.


#20

Anyone got any tips?
Still missing logs randomly then when it does pick it up its a huge spike as its logging the total.

Does anyone have a reliable way that i can use?


#21

Just got some free time to look back into this

It appears once every so often it errors trying to call the home.cgi
I get this warning below

PHP Warning: file_get_contents(http://192.168.1.12/home.cgi): failed to open stream: HTTP request failed! 1

i have added a retry loop so hopefully that fixes that part.

now just need to work on getting the zero added in.
Adding a zero in front doesn’t work, I get an undefined variable for $kwh

EDIT:
ok so not really sure what’s going on but i retyped the adding a zero code all out manually (rather than copy paste) into a new script and works fine so pasted it into my script and it works fine… there is no difference in code that i can see…
im guessing it has some character issue that has copied across.

will have to see how it goes now.
looks promising

if all goes well i would love to add a log feature so i can see what its doing and what went wrong if there is an issue.

EDIT2:
Ok first day was good apart from the morning. Alot less dropouts during the day but worse in the morning.

I got it logging the outputs to a file aswell but now i know how it works i probably didnt need to. As it literally doesnt connect to the inverter so wont output anything… atleast i have a local copy. Just need to tidy that up aswell

Im thinking the wifi is probably a bit far away and sometimes it just wont connect and thats causing the problems. Just tidy up my code and can put it up somewhere for someone else to test if they want.

For some reason i cant connect to my wifi AP so have to go direct to my router and its not as good a signal

EDIT:3

so here’s my log file. the number on the left is how many retries it had before being successful. It stops after 5 so if it has 5 it means it didn’t connect. strange it is mostly always first go a few 2,3 and 4 yet after a 5 it can go back to first go… I figured if after 50 seconds if it hasn’t connected I’ll let it drop it.

1,20190519,07:45,80,290
1,20190519,07:50,110,317
2,20190519,07:55,130,311
3,20190519,08:00,160,194
1,20190519,08:05,170,164
1,20190519,08:10,180,157
1,20190519,08:15,200,147
1,20190519,08:20,210,194
1,20190519,08:25,230,282
1,20190519,08:30,260,386
3,20190519,08:35,330,549
1,20190519,08:40,370,541
2,20190519,08:45,410,452
2,20190519,08:50,450,483
1,20190519,08:55,500,561
2,20190519,09:00,540,587
2,20190519,09:05,600,786
4,20190519,09:10,650,689
1,20190519,10:35,2600,992
1,20190519,10:40,2690,1181
1,20190519,10:45,2790,1158
1,20190519,10:50,2900,2181
1,20190519,10:55,3040,3520
2,20190519,11:00,3190,1510
1,20190519,11:05,3300,1171
1,20190519,11:10,3380,829
1,20190519,11:15,3440,579
1,20190519,11:20,3480,374
1,20190519,11:25,3510,365
1,20190519,11:30,3540,364
1,20190519,11:35,3570,361
3,20190519,11:40,3610,496
1,20190519,11:45,3650,558
2,20190519,11:50,3700,547
1,20190519,11:55,3740,612
1,20190519,12:00,3790,605
1,20190519,12:05,3850,672
1,20190519,12:10,3910,766
1,20190519,12:15,3970,623
1,20190519,12:20,4020,623
1,20190519,12:25,4080,837
1,20190519,12:30,4160,1036
5,20190519,12:35, ,
1,20190519,12:40,4290,469
1,20190519,12:45,4320,398

anyone else have any ideas other than maybe poor wifi why its dropping out?

https://pvoutput.org/intraday.jsp?id=29186&sid=61410&dt=20190517&gs=3&m=1


#22

Hi B-Man,

It’s possible that the inverter, or at least the WiFi module within it, goes into some sort of low power state to conserve energy(?) after a certain timeout. Could you script in some ping(s) to generate some ICMP traffic before you try to pull data from the inverter. Logging the ICMP traffic might also reveal some other pattern ( of interference ) that is forcing the retries.


#23

G’day MrFusion,

Did you get any further with intercepting the data that goes to the cloud?
I am interested in doing this as well.