-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR 'ExceptionResponse' object has no attribute 'registers #13
Comments
Hey! Thanks for the thorough report. It really helps. Sorry you're having trouble. It looks as though the modbus interface isn't happy talking to your inverter. There can be a few reasons for this. Are you able to verify that the inverter is listening on port 502 at that IP and there's nothing blocking the connection? You could do this by doing a port scan with This test shows port 502 is open for connections on my inverter, and 501 is not.
Or if you don't have
(Press ctrl-c to terminate netcat if a connection is successful) Unfortunately Sungrow recently encrypted the modbus communication with their newer firmwares. v0.3.1 of modbus4mqtt supports the Unfortunately I don't have an inverter with the encrypted modbus, so I'm unable to test it myself. Could you also please confirm the versions of
Cheers! |
Sure thing!
and versions:
I will be happy to assist with any test you can come up with :-) |
Cheers! Tonight I'll put together a quick troubleshooting script that provides some additional information about what's going on inside the modbus connection attempts. It's possible that Sungrow have changed their crypto again, or different models of inverters have different private keys. Investigation needed. |
Could you please grab a network traffic log during a connection attempt to the inverter?
Leave that running in the background then launch Should do the trick. You'll probably need to change the ethernet interface name from Warning: The log will likely contain the serial number of your inverter. Feel free to email it directly to me if you want to keep it more private. |
Log in your email. |
Brilliant. I can see that the interface is correctly querying for your inverter's key on startup, and that your inverter is responding to that request, but then it goes off the rails. Do you mind if I share this packet log with @rpvelloso, the author of SungrowModbusTcpClient? |
OK. I think I might have cracked it. SungrowModbusTcpClient overrides the If this is correct then I think there are two options:
def connect(self):
self.close()
result = ModbusTcpClient.connect(self)
if not result:
self._restore()
else:
self._getkey()
self.close()
result = ModbusTcpClient.connect(self)
return result This would mean that or 2) Modify @rpvelloso What do you reckon? I'm happy to do the work for either approach. Cheers, |
As long as you do not make it public, go for it :-) And again, I am happy to run more tests if you need. |
Good job @tjhowse I think this is going to work o/ |
I haven't looked at the pcap file in detail yet, but it looks like communication is begin established correctly. I can see the key is exchanged and encrypted packets are sent from both sides. |
installed version 0.1.5 on my setup, it's working. |
Nope... Still not good.
still throwing:
|
Hmm. Strange. I threw together a very basic test script here: https://github.com/tjhowse/modbus4mqtt/blob/Basic_test/troubleshooting/basic_test.py Change the IP on line 6 to the IP of your inverter,
I fear that perhaps Sungrow have changed their encryption again. |
ReadRegisterResponse (10) |
Interesting. So that confirms that at least those smaller reads starting at 5000 work, which is great. I've pushed up a change to the test that reads a bigger range of registers with both basline
|
|
This is a sneaky bug! I've pushed up a minimal config file here: https://github.com/tjhowse/modbus4mqtt/blob/Basic_test/troubleshooting/test.yaml Subscribe to the test topic with Then start You should see something like this:
Note that the occasional modbus error thrown by Thanks for all your help pinning down this bug. I appreciate it! I really need to scrounge up another of these inverters for testing purposes. The only unit I have to test with runs my house, so I'm leery of breaking it with a firmware update 😟 |
test/modbus4mqtt hi No problem. We need to fix this :-) |
Righto. It looks like the SG5K-D rejects reads on some of registers that the SH5K-20 accepts. I'm afraid you're going to have to gradually add registers from Unfortunately Sungrow don't publish the register map, so it's going to be a process of elimination. My process was to add wide ranges of registers (13000-13300) to a config file without specific names, like this: - pub_topic: "13100"
address: 13100
- pub_topic: "13101"
address: 13101
- pub_topic: "13102"
address: 13102
- pub_topic: "13103"
address: 13103
- pub_topic: "13104"
address: 13104
- pub_topic: "13105"
address: 13105
- pub_topic: "13106"
address: 13106
- pub_topic: "13107"
address: 13107
- pub_topic: "13108"
address: 13108
- pub_topic: "13109"
address: 13109
- pub_topic: "13110"
address: 13110 Then I'd subscribe to For settings that I couldn't change via the LCD, such as Once you've got a set of known good registers that your inverter is happy to accept I'd love to add them to add that config file to this repo so people with your inverter have an easier time in the future. There's a starting point for register addresses and descriptions here: https://github.com/thomasfa18/solar-sungrow/blob/master/modbus-sungrow.py |
The above list generates same error. |
So, the problem is with register addresses??? I have this document I got from sungrow itself. According to sungrow this are the addresses for residential models (SG4K, SG5K, etc). I own a SG4K and I'm using the following registers without problem:
|
how can I use this with |
Ok, I have modified the test.yaml a bit to reflect above registers:
Now I get some values:
some of them are ok:
Same on the iSolarCloud: 0.7 but other are rubbish.
|
And some more updates: |
So I think the above PR might be helpful in making it easier to scan novel devices. In this case we could set |
Righto. Give v0.3.3 a try. Add |
My inverter has a default limit of 3 simultaneous connections. Does modbus4mqtt opens up simultaneous connections??? |
The wifi dongle, that is. |
Nope! It's a single-thread application. All comms are sequential. |
hmmmm.... @tjhowse soon you will hate me :-(
config.yaml:
published:
errors:
|
Not at all! Have you got anything else talking to your inverter at the same time? A web interface open? Another modbus connection? It seems like the inverter can handle certain combinations of requests but can quickly be overwhelmed. I'm also wondering if whether it having a connection to the web could also be a factor. Can your inverter access the internet? Is it reporting data to iSolarCloud at the moment? I've disabled that connection with a rule in my router. You can also give the inverter a bad gateway IP address to prevent it routing to the internet. |
In the manual these are "input" registers, not "holding". Maybe this is it? I'm reading them all as input registers and it is working just fine. |
If you don't specify the table type it defaults to 'holding', so all of the registers in the example that @plague-doctor just posted will be scanned as holding register tables. |
Ok, some more tests.
A lot less errors are thrown (still occasional hick-ups , though):
But finally I can see some outputs:
I have no idea how to interpret the output... Especially registers 5003 and 5004... |
Can you change the registers from "holding" to "input" and see what happens? |
all of them? |
All that are listed in the PDF I sent as "input". There are two tables in there: input and holding. |
Note the table field is register-specific. You'll need an entry per register that you want to read from the input table. The process of determining what a given register means, without a memory map from the manufacturer, is one of educated guessing. 😢 I'd say the ones that are 65535 are unused. 5002 is hours in 24-hour time, 5003 is minutes (Hey, fellow UTC+10 😉 ), 5004 is seconds. |
https://seafile.cryptohell.net/d/94398451f9b0492e897b/files/?p=%2FScreenshot_1.png |
The errors ceased? |
Not that good yet :-)
|
I'm afraid those screenshot links are timing out for me. Are you able to attach them to your post in this issue instead? |
still errors out from time to time:
|
That's to be expected. My inverter occasionally throws random errors, but overall it gets the job done. |
Closing this issue as the root cause is resolved, even if there are still other issues to handle. |
Hey @plague-doctor, do you have a final .yaml file? I've successfully got some numbers, using your sample configs above: test/seconds 44 |
@entropical We've started up a new issue here: #16 Can you please post your full inverter model number and firmware version in the new issue? I'm wondering if there might be something wrong with @plague-doctor's specific setup in some way, but I'm really not sure. If we have another point of comparison that is the same in every important respect we should have a better chance of pinning down the problem. |
I try to test your script (it would be soooo useful to me).
My Inverter: SG5K-D
With latest firmware: M_WIFI_RAK475_V31_V01_Q
modbus4mqtt --hostname mqttserver --port 1883 --username username --password password --mqtt_topic_prefix test --config ./modbus4mqtt/Sungrow_SH5k_20.yaml
and so on, and so on...
cat modbus4mqtt/Sungrow_SH5k_20.yaml
The text was updated successfully, but these errors were encountered: