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

Error interacting via websockets #5

Open
filmackay opened this issue May 5, 2024 · 17 comments
Open

Error interacting via websockets #5

filmackay opened this issue May 5, 2024 · 17 comments

Comments

@filmackay
Copy link

filmackay commented May 5, 2024

On my inverter I am getting the following errors, when debugging SungrowMdbusWebClient in http mode. I have reduced it down to a websocat repro: (first JSON line is input to inverter, second line is output)

$ websocat ws://192.168.0.2:8082/ws/home/overview
{"lang": "en_us", "token": "**********", "service":"devicelist", "type": "0", "is_check_token": "0"}
{"result_code":401, "result_msg":"I18N_COMMON_INTER_ABNORMAL", "result_data":{"service":"devicelist"}}

I can't find any info on this error message - is this 401 error a HTTP status error standard, or something entirely different? Has anyone seen this before?

@kalaws
Copy link

kalaws commented May 22, 2024

Getting the same since I updated firmware in Winet-S module yesterday.

@bohdan-s
Copy link
Owner

Sorry guys. I know of this issue.
trying to put some time to look into it. But busy personal life.

@kalaws
Copy link

kalaws commented May 22, 2024

Great, thanks for the excellent work!

@kalaws
Copy link

kalaws commented May 22, 2024

main...caliph9k:SungrowModbusWebClient:main

Is this the solution?

@kalaws
Copy link

kalaws commented May 23, 2024

@bohdan-s I have confirmed the issue is authentication, and the fork linked above resolves it. I suppose SunGather users would have to fill in credentials somewhere other than the .py file, though. Especially with HA installations.

@gemx
Copy link

gemx commented May 24, 2024

Yep, can also confirm, that it's the login issue and solved by the fix

@kalaws
Copy link

kalaws commented May 24, 2024

It also seems that the service: connect call is redundant and/or can be substituted by service: login. But every service: login call registers a login event in the inverter log.

@danielHin
Copy link

main...caliph9k:SungrowModbusWebClient:main

Is this the solution?

I can confirm that this fixes the issue. I've tested with SH10.0RT-V112 + Winet-S and SH15T + Winet-S2

@filmackay
Copy link
Author

Thanks for this - can someone explain what the comparison is between MODBUS and websocket?

MODBUS is polling - does anyone know how often new values are available? ie. are they changing on a constant cadence, and then it's up to you how often you poll?

Websocket - does anyone have a feel for how often new values are pushed to you in general? Can you control this at all? Do you get all values, or all requested values, pushed over a single connection?

It feels like Websocket could be way better for high-granularity data, but depends on implementation 🤷🏻

@filmackay filmackay reopened this Jun 30, 2024
@bohdan-s
Copy link
Owner

From my testing websocket and modbus update the same time.
None of the values are “instant” but I’m not sure how often they update.
The web socket method actually just calls the modbus form in the dongles web interface. So all the values are mostly the same.

@filmackay
Copy link
Author

Thanks @bohdan-s - what about other aspects: universal subscription (give me every register) is this easier on Websocket? Does the websocket operate on a perpetual push stream (updated when value changes) - unlike Modbus which is request-response?

Wasn't it hard to determine they update at the same time because of the push / request-response mismatch?

I'll try and do some testing to get a feel for how often the underlying data does update..

@bohdan-s
Copy link
Owner

So modbus method reads each register via modbus protocol.
Web socket reads each register by logging into the web interface and using the modbus form to request the modbus registers.
Both are modbus in the end. The websocket way just worked around a number of firmware versions where modbus did not work at all.
As for the data. There should be no difference. Modbus method would be arguably better since it's not going through the extra websocket layer.

@filmackay
Copy link
Author

I see - I was hoping that the websocket protocol would at least push new values to you, meaning you did not to continue to re-request everything on a regular cadence. Is the websocket protocol still request-response (effectively) just inside a bi-directional protocol?

@bohdan-s
Copy link
Owner

“My” implementation is using modbus stack. So it’s all polling.
there are some community members using the websocket exposed by the dongle. But it’s not feature complete against the modbus.

@gemx
Copy link

gemx commented Jul 8, 2024

I wrote my own adapter using C# and the websocket only.
With recent versions of the Wininet Dongle, this method seemed more reliable.
Although i noticed the following while reverse engineering the protocol:

  • The websocket gets disconnect every 30 seconds - don't know why - doesn't happen when viewing the page in the browser
  • You need the "Connect" message before the "Login" otherwise it doesn't successfully reconnect sometimes saying that a user is already logged on
  • Although it's a websocket, you have to poll the services to get the values for them

@t-lund
Copy link

t-lund commented Sep 12, 2024

@bohdan-s Any progress on this issue or a guesstimate when you can work on it?

@monojk
Copy link

monojk commented Oct 17, 2024

main...caliph9k:SungrowModbusWebClient:main
Is this the solution?

I can confirm that this fixes the issue. I've tested with SH10.0RT-V112 + Winet-S and SH15T + Winet-S2

I did a fix on my side for my SH8.0RT-V112 replacing SungrowModbusWebClient/SungrowModbusWebClient.py with the same file from https://github.com/caliph9k/SungrowModbusWebClient

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

7 participants