Help Required Uploading Growatt Inverter To PVOutput

I found the problem, now looking when I missed it (merge maybe). Will come back with solution in a few minutes.

Thanks

Ok, I think I got it.

@lampra please try latest dev branch (tag multi-inv-rc3). To document, the commit that caused errors is c50704f88

My system is working because I have only one inverter on the code, the line altered does not matter for single inverter.

Regarding your suggestions I will put commit them.

Note

Forgot to say, this might be

systemID='12345','67890'

FYI: I was uploading 2 systems with the multi-inverter version and 1 system with the single inverter version and both stopped the day after the time change.

:open_mouth: wow that does sound complicated! Here in the UK it’s always the last Sunday in March and October. If it was up to me though I’d just leave it alone :slight_smile:

Bob.

Too complicated, imagine the nightmare for the IT guys… Another curiosity: there is a second exception (at least this one can be foreseen): Brazilian Carnaval date are based on Easter dates (Christian calendar), hence it floats between February and March depending on the Easter dates. If the end of daylight happens to be in the same weekend of the Carnaval it will be postponed to next weekend.

Man, it would be so simple to keep this thing fixed! Even worst: nowadays the energy saving (main reason to have daylight here) is marginal, it doesn´t worth the hassle.

However, I personally like the daylight saving time because I can enjoy daylight after work. But I am an exception, most people don´t like it because early in morning is still too dark.

Hi,
Just to let you know that I encountered the issue reported here again today but only for the multi inverter version after yet another power outage last night.
Luckily I had my box collecting tcpdump output (let me know if you need it) and I can see that the first post this morning includes the production of the past day. I used the deletestatus api to delete the first status of the day and everything is ok on pvouput.
Perhaps we/you could reproduce this issue by killing the process once after the end of the day and see what happens during the next morning with the first status of the day (I will do this test and report back here).

Hi @jrbenito it’s been a while, I hope you are well.

I have been running your script for months now without any problems however today I updated my Pi (apt-get update etc.), rebooted and now it is no longer working :frowning:. I have changed nothing except for updating Raspbian on my Pi.

If I ssh into my Pi and run /home/pi/canadianSolar-pvoutput-master/pvoutput.sh from the command line then everything works ok. However I have been running pvoutput.sh from cron with the following entry in the crontab:

@reboot /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1

This has been working for months but from today I get no uploads to PVOutput. The processes appear to be running:

pi@Solar-2:~/canadianSolar-pvoutput-master $ ps ux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
pi 407 0.0 0.0 1888 368 ? Ss 16:38 0:00 /bin/sh -c /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1
pi 410 0.0 0.2 4584 2532 ? S 16:38 0:00 /bin/bash /home/pi/canadianSolar-pvoutput-master/pvoutput.sh
pi 465 0.0 0.6 9760 5884 ? Ss 16:38 0:00 /lib/systemd/systemd --user
pi 468 0.0 0.1 11320 1412 ? S 16:38 0:00 (sd-pam)
pi 473 0.0 1.1 51012 11320 ? Ssl 16:38 0:00 /usr/bin/lxsession -s LXDE-pi -e LXDE
pi 482 0.0 0.3 6516 2964 ? Ss 16:38 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation
pi 611 0.0 0.0 3788 220 ? Ss 16:38 0:00 /usr/bin/ssh-agent x-session-manager
pi 618 0.0 0.6 39652 5984 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfsd
pi 623 0.0 0.5 54268 4816 ? Sl 16:38 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
pi 636 0.0 1.5 53780 14784 ? S 16:38 0:00 openbox --config-file /home/pi/.config/openbox/lxde-pi-rc.xml
pi 640 0.0 0.9 43332 8772 ? Sl 16:38 0:00 lxpolkit
pi 643 0.3 2.4 132112 23652 ? Sl 16:38 0:02 lxpanel --profile LXDE-pi
pi 646 0.1 2.0 92204 19512 ? Sl 16:38 0:00 pcmanfm --desktop --profile LXDE-pi
pi 653 0.0 0.0 3788 220 ? Ss 16:38 0:00 /usr/bin/ssh-agent -s
pi 661 0.0 0.0 1888 408 ? S 16:38 0:00 sh -c zenity --info --width=400 --text="Raspbian has been updated. Some configuration files have been overwritten, so your desktop configuration
pi 662 0.1 5.2 232508 49640 ? Sl 16:38 0:01 zenity --info --width=400 --text=Raspbian has been updated. Some configuration files have been overwritten, so your desktop configuration may hav
pi 679 0.0 1.0 92876 9660 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
pi 682 0.0 0.5 26072 4984 ? Ssl 16:38 0:00 /usr/lib/menu-cache/menu-cached /run/user/1000/menu-cached-:0
pi 701 0.0 0.5 38836 5024 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi 702 0.0 0.0 0 0 ? Z 16:38 0:00 [sh]
pi 710 0.0 0.4 37272 4632 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
pi 718 0.0 0.6 50980 6540 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
pi 723 0.0 0.4 37348 4436 ? Ssl 16:38 0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
pi 763 0.0 0.6 49108 6276 ? Sl 16:38 0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.4 /org/gtk/gvfs/exec_spaw/0
pi 783 0.4 2.3 26308 22116 ? S 16:39 0:03 python /home/pi/canadianSolar-pvoutput-master/canadian_reads.py
pi 797 0.0 0.3 11660 3440 ? S 16:39 0:00 sshd: pi@pts/0
pi 800 0.0 0.4 6188 4260 pts/0 Ss 16:39 0:00 -bash
pi 888 0.0 0.3 7740 2924 pts/0 R+ 16:52 0:00 ps ux

but I’m getting the following errors in the log file:

pi@Solar-2:~/canadianSolar-pvoutput-master $ cat canadianSolar.log
(‘2019-04-14 16:39’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:39’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:39’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:39’, ‘Failed to call PVOutput API after 2 attempts.’)
(‘2019-04-14 16:40’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:40’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:40’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:40’, ‘Failed to call PVOutput API after 2 attempts.’)
(‘2019-04-14 16:45’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:45’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:45’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:45’, ‘Failed to call PVOutput API after 2 attempts.’)
(‘2019-04-14 16:50’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:50’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:50’, ‘Error Connecting:’, SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘pvoutput.org’, port=443): Max retries exceeded with url: /service/r2/addstatus.jsp (Caused by SSLError(SSLError("bad handshake: Error([(’’, ‘osrandom_rand_bytes’, ‘getrandom() initialization failed.’)],)",),))’,),))
(‘2019-04-14 16:50’, ‘Failed to call PVOutput API after 2 attempts.’)

Have you any idea what might be causing the problem?

Many thanks - Bob.

I’ve spent a bit of time on this today but not really got anywhere. Things I tried:

Confirmed that it works ok running from the command line (ssh) - it does.

Amended the crontab line to @reboot /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1 & (i.e. added & to the end of the line). This worked for the first reboot but not for subsequent reboots!

Amended the crontab line to include a 60s delay @reboot sleep 60 && /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1 &. This made no difference.

Amended the crontab line to 30 14 15 4 * /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1 & (i.e start the script at 14:30 on the 15 April). This worked but will not restart the script on reboot which is what I want. It does seem to point to a problem with the @reboot command though.

Modified /etc/rc.local - inserted the line /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1 & and commented the equivalent line out of the crontab. This runs the script as root but I then get the error:

Traceback (most recent call last):
File “/home/pi/canadianSolar-pvoutput-master/canadian_reads.py”, line 6, in
from pytz import timezone
ImportError: No module named pytz
python script erro, sleeping few seconds and call it again

I also get this error if I run pvoutput.sh as root from the command line.

I don’t know where to go next. Searching for the error Error Connecting:’, SSLError(MaxRetryError suggests that it something to do with security certificates but I’m out of my depth here.

Any suggestions greatfully received :slight_smile:

Bob.

Hi, to me it seems like an ssl error. Until the author replies, I suggest the following:

  1. Install openssl and check if it works
  2. If 1 does not work, change the code to send http and not https requests and test.
    canadian_reads.py v0.7.2 file, at line 175, change https to http
    Beware that your data may be sniffed (though if only sending production it is also available on pvoutput.org !!!)

Edit: You should first install the missing pytz module and test (i use pip to install python modules)

Hi lampra and thanks for your reply.

It seems to me that this must be an environment issue as the script runs fine from the command line and also through cron as a timed job. In both these cases the script is running as user pi. It does not work using the cron @reboot command (SSLError(MaxRetryError) or running as root using /etc/rc.local (ImportError: No module named pytz). Prior to this I had been using the @reboot command for months with no problems. The only thing that has changed are the regular Raspbian updates which I do every few weeks.

I a bit reluctant to start changing things until I understand what might have happened, I think I’ll wait for jrbenito to reply before I do anything else.

Just as a matter of interest, now are you running your version of the script?

Bob.

Hi @bobboulby,

I see your point now. If I remember well, @reboot can be used only in root crontab (at least in debian).
In my case I use openwrt (on an espressobin). I start the python script with rc.local and a bash script always as root (there is no other user on the system). As you will see below, I use the one inverter version of the python script as the multiinverter script has a bug and the author did not have time so far to look at it.

cat start_growatt.sh 
#!/bin/sh
cd /root/canadianSolar-pvoutput-0.7.2/
sleep 5
/usr/bin/nohup /bin/sh /root/canadianSolar-pvoutput-0.7.2/pvoutput1.sh </dev/null >/dev/null 2>&1 &
sleep 10
/usr/bin/nohup /bin/sh /root/canadianSolar-pvoutput-0.7.2/pvoutput2.sh </dev/null >/dev/null 2>&1 &
sleep 10
/usr/bin/nohup /bin/sh /root/canadianSolar-pvoutput-0.7.2/pvoutput3.sh </dev/null >/dev/null 2>&1 &
sleep 10

ps: You could also, like in my case, try including the starting command in a script. Put this script (eg sh /root/start_growatt.sh) in rc.local or in crontab. If needed maybe you could try to change the user in the script using su.

Just made a manual to upload Growatt data with the wifi module to PVoutput with a Raspberry Pi: https://tech.ligthartnet.nl/upload-growatt-data-to-pvoutput-with-raspberry-pi/

1 Like

I also found this for collecting data from the wifi dongle.

Hi

I am new to this, but have had a go at implementing the script on an old raspberry pi 1. I am getting a load of script errors when running the following

I get this:
pi@solarpi:~/canadianSolar-pvoutput-master $ sudo ./pvoutput.sh
Traceback (most recent call last):
File “./canadian_reads.py”, line 6, in
from pytz import timezone
ModuleNotFoundError: No module named ‘pytz’
python3 script erro, sleeping few seconds and call it again

I am very much just copying and pasting what I think I need to do here, but I know I have configured the pvoutput.txt correctly, having renamed it and added my timezone.

Any help would be very useful.

Cheers

Phill

These are the instructions I followed when I originally got it working although it’s quite a while ago now.

1. On my Pi I created the folder canadianSolar-pvoutput-master under /home/pi/
2. Downloaded canadianSolar-pvoutput-master.zip from GitHub, unzipped and copied contents to /home/pi/canadianSolar-pvoutput-master
3. From canadianSolar-pvoutput-master folder ran pip install -r requirements.txt
4. Renamed pvoutput.txt.rename to pvoutput.txt
5. Edited pvoutput.txt with System Id, API Key, OWM variables and TimeZone=Europe/London
6. Connected Pi to inverter with USB to RS232 interface lead and rebooted Pi.
7. $ chmod +x pvoutput.sh
8. $ ./pvoutput.sh

Data then started being uploaded to my system :slight_smile: I added two extended data variables to my PVOutput system settings - AC Volts and Inverter Temperature (I didn’t include ‘v10’: inv.wh_total).

I’d been doing all this from a ssh session on my laptop and I wanted to get the script to start automatically when the Pi restarts so I created a cron job for user pi with the entry “@reboot /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1”. To get this to work I also had to modify pvoutput.sh as follows:

#!/bin/bash
cd /home/pi/canadianSolar-pvoutput-master/ # Needs to be run from the directory where code is #
while true; do
python /home/pi/canadianSolar-pvoutput-master/canadian_reads.py
echo “python script erro, sleeping few seconds and call it again”
sleep 60s
done

I’m not executing as sudo, not sure if that will make any difference. If this doesn’t help, could you publish the contents of pvoutput.sh.

Bob.

1 Like

Hi Bob

Really appreciate you getting back to me. The contents of my pvoutput.sh file was exactly the same as the output I was getting previously:

#!/bin/bash
while true; do
	python3 ./canadian_reads.py
	echo "python3 script erro, sleeping few seconds and call it again"
	sleep 60s
done

I have since changed it to your updated script and now I get the following:

    pi@solarpi:~/canadianSolar-pvoutput-master $ ./pvoutput.sh
      File "/home/pi/canadianSolar-pvoutput-master/canadian_reads.py", line 332
        print('\nExiting by user request.\n', file=sys.stderr)
                                                  ^

I have not attempted to create a cron job as yet, as I would like to at least see if there is any ouptut to pvoutput website.

One thing that I think might be an issue here is that clearly since this script was created there have been updates in the os for raspberry pi. I am using the latest version as of writing which is buster. I can see you had issues when doing an os update and I am wondering if they are related and if I should try and flash an older version of RP OS to test if the script was compatible. Before I do I suppose I should ask the question what version were you using when it worked for you and did you ever manage to fix yours after your previous update of saying it had stopped working?

Cheers

Phill

Edit: just to confirm running as sudo does nothing to change this outcome.

Looks like I’m running stretch

pi@Solar-2:~ $ cat /etc/os-release
PRETTY_NAME=“Raspbian GNU/Linux 9 (stretch)”
NAME=“Raspbian GNU/Linux”
VERSION_ID=“9”
VERSION=“9 (stretch)”
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL=“http://www.raspbian.org/
SUPPORT_URL=“http://www.raspbian.org/RaspbianForums
BUG_REPORT_URL=“http://www.raspbian.org/RaspbianBugs

I’ve always kept my system up to date using apt-get update & apt-get dist-upgrade but it looks like this doesn’t update the core version.

The issue I had back in April 2009 was resolved by putting a 180 second delay in the @reboot comand in the cron job

@reboot sleep 180 && /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1 &

so I guess that it was something to do with the speed of loading of some modules on reboot. Note that executing /home/pi/canadianSolar-pvoutput-master/pvoutput.sh from the command line always worked.

I don’t think the script works with python3 so try using just python. Also are all your files in the same folder structure as mine i.e. /home/pi/canadianSolar-pvoutput-master/?

Finally did you make pvoutput.sh executable (chmod +x pvoutput.sh)?

Sorry but I’m not really much of a pi expert and unfortunately the developer is no longer active in supporting this code. Maybe someone with more experience can contribute or it might be better to look for a supported alternative (if one exists).

Bob.

Just noticed that @lampra has made some changes on GitHub to update to python3. If they are around, maybe they can help.

Bob.

Hi, just regular user here not expert. From the output it seems that pytz is not installed. If you have installed the requirements as described in github probably something went wrong.

So I propose to use pip (or any other tool) to install pytz.
Check also the rest of the requirements, if they are not installed go ahead and install them using pip.
If this does not solve your problem, paste here the output of the script in order to help you.

Hi

Thanks for getting back to me. I have tried to install pytz, but it appears it is already installed. I get the following when I try to install:

pip install pytz
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pytz in ./.local/lib/python2.7/site-packages (2018.7)