Skip to content
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

Data errors with fast refresh. #37

Open
nerfherder opened this issue Sep 14, 2021 · 5 comments
Open

Data errors with fast refresh. #37

nerfherder opened this issue Sep 14, 2021 · 5 comments

Comments

@nerfherder
Copy link
Contributor

I have been facing some issues with nonsense data coming out of this integration on and off.

This wasn't an issue with https://github.com/erikarenhill/solaredge-modbus-hass and having a look their it looks like erikarenhill is using import pymodbusTCP whereas bisentsu is using pymodbus the pymodbusTCP implementation lets you keep the connection open with ModbusClient(host, port=port, unit_id=1, auto_open=True) whereas pymodbus appears to require a connect and close each read cycle.

My suspicion is that this open/close cycle can take longer than 5-10 seconds and cause errors if it hasn't run through properly. I would like to trial using pymodbusTCP to see if it makes any difference.

Originally posted by @nerfherder in #35 (comment)

@WillCodeForCats
Copy link

Does HA actually allow for holding the socket open between polling cycles? I don't really know the internals of how HA add ons work.

From my experience with libmodbus in C, ideally the socket would be opened when HA starts up and then never closed unless 1) connection drops and needs to be reopened (network failure, inverter loses power and reboots, whatever) or 2) HA shuts down.

@nerfherder
Copy link
Contributor Author

The changes in #39 introduce pymodbustcp which I believe lets the connection remain open. I set it to auto open so that if the connection drops for some reason it will open again.

https://pymodbustcp.readthedocs.io/en/latest/package/class_ModbusClient.html

@WillCodeForCats
Copy link

Wireshark would confirm if it's never intentionally closing the connection if someone has time to try that.

@nerfherder
Copy link
Contributor Author

I will have a look into monitoring with wireshark as I am already running on that fork.

@nerfherder
Copy link
Contributor Author

I've just run a wireshark capture on this. From what I can see neither libraries result in the connection closing between reads.
They do behave slightly differently though.
pymodbustcp
image

and modbustcpclient
image

The main difference seems to be that the pymodbustcp client triggers a TCP ACK from the solaredge (10.0.0.136 in my case) inverter back to my hassio instance (10.0.0.50) where teh modbustcp client doesn't.

I have very little knowledge in modbus and tcp so someone might be able to interpret what this means better than me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants