borft / py-goodwe

Python lib to query Goodwe inverters
GNU General Public License v3.0
15 stars 2 forks source link

First query works, but then nothing #3

Closed jimo4242 closed 1 year ago

jimo4242 commented 1 year ago

Hello, I have a problem and wanted to check if there is any idea to proceed. I have GoodWe inverter HF_E20, with LAN module (not wifi). PV master app from mobile phone works (wifi bridged to the same network), inverter also sends data to semsportal.

When I try the first phase manually using netcat, I succeed: $ nc -u 192.168.42.150 48899 WIFIKIT-214028-READ

192.168.42.150,34:ea:e7:98:25:96,HF_E20

However, when trying with py-goodwe, I am not getting any response.

$ python3 run.py Retrying 2 timed out Retrying 1 timed out Retrying 0 timed out failed: Could not get proper data after retrying

I have in config.ini [goodwe] ip =192.168.42.150 port = 8899

I think the inverter doesn't react to the message \x7f\x03\x75\x94\x00\x49\xd5\xc2. I've tried to put there a test msg \xAA\x55\xC0\x7F\x01\x02\x00\x02\x41 instead, which has produced some response apparently, as the message changed to Retrying 1 Invalid data (unexpected length: 85

I've tried to send these two manually as well: $ echo -e "\x7f\x03\x75\x94\x00\x49\xd5\xc2" | nc -u 192.168.42.150 8899 (no response)

$ echo -e -n "\xAA\x55\xC0\x7F\x01\x02\x00\x02\x41" | nc -u 192.168.42.150 8899 �U��L0707CGW10K-ET 9010KETU21BW442302041-19-S0C�

So the communication works and probably just the default command to get data is not working for this type.

More info - I have scanned the inverted with nmap, I can see I have opened TCP 80 and 502 and UPD 8899 and 48899. When tried to discover more about modbus on TCP502, I didn't get anything more detailed.

$ nmap -sU -p0-65535 192.168.42.150 Starting Nmap 7.80 ( https://nmap.org ) at 2022-10-18 19:16 CEST Stats: 0:02:00 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan UDP Scan Timing: About 3.89% done; ETC: 20:08 (0:49:26 remaining) Nmap scan report for 192.168.42.150 Host is up (0.0013s latency). Not shown: 65534 closed ports PORT STATE SERVICE 8899/udp open|filtered ospf-lite 48899/udp open|filtered unknown MAC Address: 34:EA:E7:98:25:96 (Shanghai High-Flying Electronics Technology)

Nmap done: 1 IP address (1 host up) scanned in 3293.26 seconds

$ nmap -sT -p0-65535 192.168.42.150 Starting Nmap 7.80 ( https://nmap.org ) at 2022-10-20 13:47 CEST Nmap scan report for 192.168.42.150 Host is up (0.037s latency). Not shown: 65534 closed ports PORT STATE SERVICE 80/tcp open http 502/tcp open mbap MAC Address: 34:EA:E7:98:25:96 (Shanghai High-Flying Electronics Technology)

Nmap done: 1 IP address (1 host up) scanned in 129.75 seconds

$ nmap --script modbus-discover -p 502 192.168.42.150 Starting Nmap 7.80 ( https://nmap.org ) at 2022-10-22 14:12 CEST Nmap scan report for 192.168.42.150 Host is up (0.0012s latency).

PORT STATE SERVICE 502/tcp open mbap MAC Address: 34:EA:E7:98:25:96 (Shanghai High-Flying Electronics Technology)

Nmap done: 1 IP address (1 host up) scanned in 688.56 seconds

Any hint what/how to change, please? Thank you, jimo4242

borft commented 1 year ago

I think you're probably right that your inverter requires a different magic string (I've only tested it on mine ;). If you're specifically looking for a python implementation, have a look at the home assistant goodwe integration,that's python and I think it has support for a wide range of Goodwe inverters.

jimo4242 commented 1 year ago

Hello borft, thank you for the kick. I went to https://github.com/mletenay/home-assistant-goodwe-inverter and from there, to its mentioned source https://github.com/marcelblijleven/goodwe. The second one worked almost instantly, getting the data in text form. So now I have just to find out how to feed them to prometheus, but that's different chapter. So if anyone will see my question - the second link to Marcel Blijeven's project in this post leads to python library which can get data from MANY (not only XS as in description) GoodWe inverters.