May 5, 20206 yr Ok, so I seem to have it working now in Python 3. After Gnome mentioned the encoding and I skimmed the articles above I looked at the encoding and changed my original code, which was based on nikitto's post from June 4, 2017 in same topic: ### code above removed, see nikitto's post from Posted June 4, 2017 in same topic ### calc_crc(comando) print('Command='), comando print('CRC='),crc crc1=crc[0:4] crc2=crc[0:2]+crc[4:6] crc1=int(crc1, base=16) crc2=int(crc2, base=16) scomm = comando+chr(crc1)+chr(crc2)+'\r' bcomm = sCommand.encode('ISO-8859-1') fd = open('/dev/hidraw0', 'rb+') fd.write(bcomm) r = fd.read(nbytes) j = r.decode('ISO-8859-1') s = j.split("\\") print s i = s[0][1:].split(" ") print i fd.close() So I open the connection to read/write bytes (not strings) and encode the string before passing it to the write and decode when reading (and removed the .encode('string-escape') from the original code). This seems much more reliable and I didn't see any errors when running this code. I hope this helps others that are trying to get it working in Python 3. Thanks again Gnome.
May 6, 20206 yr Author 22 hours ago, Lindsay said: This seems much more reliable and I didn't see any errors when running this code. I hope this helps others that are trying to get it working in Python 3. Nicely done
May 11, 20206 yr Attached is my full code for Python3 which will try to read from the inverter every 5 seconds and timeout if the read takes longer than 12 seconds (I've only tested the QPIGS, but you should be able to change the commando variable if you want to read other data). Enjoy! inv.py
May 11, 20206 yr Thank-you Lindsay. I have written my own crc function to take into account the Axpert's idiosyncrasies and have fewer dependencies. After spending some time fiddling with Node Red and node.js I have developed an aversion of libraries and dependencies unless they are well written and documented. It appears Voltronic use a chipset that masquerades as a Cypress Semiconductor chip. From a little saunter on the web Cypress seem to disown VID 0665 PID 5161 which leaves most of us fumbling in the dark. The Python 2/3 changes how strings are handled does not help either. I prefer how Python3 handles strings with text and bytes being discrete but does give one a headache when you trying to get an officially undocumented chipset to work. Thank-you Lindsay for rolling several large boulders out my way. In the mean time I have dusted off my 30 year old programming skills. I hear a cacophony of laughter coming down the ether. I cut my teeth on Basic, Cobol and eventually a little bit of Pascal and DOS doesn't stand for Dark Outer Space.😆 Since I am so rusty I usually write 2 lines of comments for every line of code. I cannot abide not understanding code I have written/copied and end up dissecting github code. This I suppose defeats the object of repositories but too many folk (myself included) borrow code from a different source with scant regard to its robustness. This is in no way a slight on Lindsay's contribution for which I am most grateful. Edited May 11, 20206 yr by Chris Hobson
May 11, 20206 yr Hey everyone. We've worked a lot with this code, so in this moment we're able to send large commands, over 8 bytes. Tested in Axpert and Infini. You can checkout the code here: https://sourceforge.net/p/pvcontrol/code/ci/master/tree/hibrido.py
May 12, 20206 yr 17 hours ago, nikitto said: Hey everyone. We've worked a lot with this code, so in this moment we're able to send large commands, over 8 bytes. Tested in Axpert and Infini. You can checkout the code here: https://sourceforge.net/p/pvcontrol/code/ci/master/tree/hibrido.py This looks very cool. I see it exposes the values on MQTT and builds graphs/meters. Are the graphs and data exposed on the local webserver on the Raspberry PI? Are there any English instructions for getting this running? Thanks.
May 12, 20206 yr 1 hour ago, Lindsay said: Are the graphs and data exposed on the local webserver on the Raspberry PI? Are there any English instructions for getting this running? Yes, we're using MariaDB (mySQL). Everything is in local, although it's ready to publish data to pvoutput.org We've got a page in FB if you want to know more things about this project: PVControl+ https://www.facebook.com/pvcontrolplus You can checkout the system, for example, in this web: http://jordi.ddns.net/ Or in my personal web: http://asako.sytes.net/ There is an image of the system here: https://adnsolar.eu/viewtopic.php?f=20&t=445 Allways look for the last update. If you've any doubt or question, please do not hesitate to contact us (in English, of course). We're interesting to have an English version. So, you can help us to get it. Greetings. P.S.: Now, it's ready to work with SONOFF relays with Tasmota, too. Edited May 12, 20206 yr by nikitto
May 13, 20206 yr 21 hours ago, nikitto said: Yes, we're using MariaDB (mySQL). Everything is in local, although it's ready to publish data to pvoutput.org We've got a page in FB if you want to know more things about this project: PVControl+ https://www.facebook.com/pvcontrolplus You can checkout the system, for example, in this web: http://jordi.ddns.net/ Or in my personal web: http://asako.sytes.net/ There is an image of the system here: https://adnsolar.eu/viewtopic.php?f=20&t=445 Allways look for the last update. If you've any doubt or question, please do not hesitate to contact us (in English, of course). We're interesting to have an English version. So, you can help us to get it. Greetings. P.S.: Now, it's ready to work with SONOFF relays with Tasmota, too. Well, nowadays we have incorporated on-grid inverters: Huawei -> Modbus TCP Fronius-> API SMA-> Modbus TCP All cases are available to divert and avoid feed in the grid.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.