wills106 / homeassistant-solax-modbus

SolaX Power Modbus custom_component for Home Assistant (Supports some AlphaESS, Growatt, Sofar, Solinteg, Solis, SRNE, Swatten)
317 stars 101 forks source link

Waveshare RS485 to ETH Stops Working #243

Closed J14111 closed 1 year ago

J14111 commented 1 year ago

Hi,

I have a Solis RHI-3.6K-48ES-5G and am using a Waveshare RS485 to ETH POE adapter

I have the settings for the Waveshare exactly as in the Wiki screenshot.

I find it works for anywhere from 5 mins to 1 hour then HA just stops updating, if I powercycle the Waveshare it starts to work again. just to note when this happens I can still ping the Waveshare and access the web UI.

I have tried some different baud rates and settings but I cant resolve any ideas on potential fixes?

J14111 commented 1 year ago

I have the update interval set to 15 I found it happend quicker when set to 5, so it seems like it could be a buffer filling up or something?

wills106 commented 1 year ago

You will need the baud to match the Inverter. There are these notes in the Wiki for Installation.

In "More Advanced Aettings...",

SolaX set Modbus Gateway Type to "Simple Modbus to TCP/IP mode" Sofar Solar set Modbus Gateway Type to "Auto query storage type"

It might be worth trying to see if the same helps with Solis?

J14111 commented 1 year ago

Thanks the baud matches the inverter it is changeable on the Solis so I have tried 9600 and 38400 both have the same issue.

I have changed it to Auto query storage type and it is currently working, I will let you know how it goes

J14111 commented 1 year ago

Still no joy with the Auto query storage type setting

J14111 commented 1 year ago

I have tried everything it still stops working, I tried sedding the query inverval higher at 30 sec and it worked for longer but still stopped, that has to be a buffer, register or some sort of limit being reached?

J14111 commented 1 year ago

This is defo the fault of the Waveshare if I power cycle it then it starts working again, im going to try a different adapter

J14111 commented 1 year ago

Im currently testing this device, working well so far, I will update how it goes, I found the Waveshare device very flakey:

USR-W610

image

J14111 commented 1 year ago

I am still seeing issues but they are slightly different, I have yet to have this interface totally stop working however I have my interval set to 30 seconds, it will do this for a few readings but then it will slow down, sometimes up to 5 or 6 mins, any ideas?

Here is a small section of data from the database showing the issue, you can see the interval is regularly 30 seconds then it takes longer then goes back to 30 again:

2022-12-15T19:03:40.000+00:00 | 588 2022-12-15T19:06:10.000+00:00 | 622 2022-12-15T19:06:30.000+00:00 | 626 2022-12-15T19:06:40.000+00:00 | 682 2022-12-15T19:07:00.000+00:00 | 694 2022-12-15T19:08:40.000+00:00 | 554 2022-12-15T19:10:50.000+00:00 | 610 2022-12-15T19:11:20.000+00:00 | 554 2022-12-15T19:11:50.000+00:00 | 517 2022-12-15T19:12:20.000+00:00 | 549 2022-12-15T19:12:50.000+00:00 | 550 2022-12-15T19:13:20.000+00:00 | 613 2022-12-15T19:13:50.000+00:00 | 548 2022-12-15T19:15:20.000+00:00 | 610 2022-12-15T19:15:50.000+00:00 | 548 2022-12-15T19:16:20.000+00:00 | 637 2022-12-15T19:16:50.000+00:00 | 587 2022-12-15T19:17:20.000+00:00 | 552 2022-12-15T19:17:50.000+00:00 | 585 2022-12-15T19:18:20.000+00:00 | 547 2022-12-15T19:18:50.000+00:00 | 543 2022-12-15T19:19:20.000+00:00 | 550 2022-12-15T19:20:20.000+00:00 | 504 2022-12-15T19:20:50.000+00:00 | 535

Could it be the solis is rate limiting the requests or is it something in your code?

Here are the settings for the adapter not sure if you can see anything I should change?

image

J14111 commented 1 year ago

This graph shows the gaps and inconsistancy of the timings well some of the gaps between reads are 6min!

image

wills106 commented 1 year ago

If you manually change 100 down to say 40 does this issue go away? https://github.com/wills106/homeassistant-solax-modbus/blob/3cff002deb9f4a6040e86d35e373adf962f74e62/custom_components/solax_modbus/sensor.py#L40

J14111 commented 1 year ago

Thanks, it seems to not work at all if I set that to 50, 100 or 200, I have found it works best about the same with that setting at 2000 (2 seconds) or totally off still seeing big gaps up to 7 mins.

I have done a quick bit of searching I found these not sure if they make more sense to you;

https://control.com/forums/threads/modbus-tcp-very-slow.22268/ https://www.controlengeurope.com/article/139766/Speeding-up-Modbus-TCP.aspx https://support.industry.siemens.com/forum/ww/en/posts/modbus-tcp-slow-response/158656

wills106 commented 1 year ago

Thanks, it seems to not work at all if I set that to 100, I have found it works best about the same with that setting at 2000 (2 seconds) or totally off still seeing big gaps up to 7 mins.

What exactly are you referring to? Polling timeout on your Ethernet adaptor?

I was asking if you could make a change to sensor.py

I think the problem is Solis didn't design these Inverters to be fully compliant with the Modbus specs. Modbus over RTU is meant to be able to return 125 16bit registers at once and Modbus over TCP 123.

I noticed a comment in the Solis docs that it's recommended to only read 100 bytes / 50 16bit registers.

To put less load on the Inverters we group the registers up into blocks of upto 100, this allows us to poll the Inverter quicker than would be possible if we read each register individually. I was asking if you could drop the max block size down to 40 to see if your errors go away.

I am guessing the Inverter is overflowing it's internal buffer as it was never designed with enough storage space to be fully Modbus compliant?

J14111 commented 1 year ago

ah ok sorry I was changing the setting on my adapter:

image

I will try the sensor.py

J14111 commented 1 year ago

You sir are a genius, I have never got this many consistant results in a row before:

image

Thats with 40 is it worth me trying some higher settings or what do you think a good setting would be?

Thanks so much

wills106 commented 1 year ago

50 should be the max. You should also be able to drop your polling rate back down to something like 5 - 15s as well assuming it can keep up.

J14111 commented 1 year ago

ok will leave it at 40 to be honest it works the same if that modbus polling setting is on or off so I have it off for now, I think I may leave it at 30 or im going to end up with a huge influxdb, I will have a think

J14111 commented 1 year ago

You can also add the two following to the working/tested devices wiki if you wish

USR-W610 and PoE adpater

https://www.amazon.co.uk/gp/product/B07DNWM62H with https://www.amazon.co.uk/gp/product/B07ZH5V89T/

Having used the Waveshark and the USR I think I prefer the USR seems a bit better quality and more reliable. I wish I had got the USR first I could have taken the power from the inverter serial port and used wifi, then i wouldnt have needed to run cat5 to the loft lol

wills106 commented 1 year ago

polling rate back down to something like 5 - 15s

I meant on the Integration itself. If you remove the Integration from the Integration page, restart HA and reconfigure it with a lower poll rate (quicker)

I wish I had got the USR first I could have taken the power from the inverter serial port and used wifi, then i wouldnt have needed to run cat5 to the loft lol

It's always a gamble with new untested equipment. Like we didn't know the Waveshare Wifi wasn't compatible until someone tried it.

J14111 commented 1 year ago

polling rate back down to something like 5 - 15s

I meant on the Integration itself. If you remove the Integration from the Integration page, restart HA and reconfigure it with a lower poll rate (quicker)

I wish I had got the USR first I could have taken the power from the inverter serial port and used wifi, then i wouldnt have needed to run cat5 to the loft lol

It's always a gamble with new untested equipment. Like we didn't know the Waveshare Wifi wasn't compatible until someone tried it.

Yeah sorry I got that after I reread your message, im using the USR-W610 over ethernet so cant confirm if the Wifi works properly on it but I suspect it should do

Will you update the code with the Solis config for sensor.py otherwise its going to get overwritten on an update?

wills106 commented 1 year ago

Yea I am trying to build an if statement based on which plugin a user is using.

J14111 commented 1 year ago

Excellent thanks so much

wills106 commented 1 year ago

Just so you know 2022.12.8 does not contain the working if statement for block size and the update is only for Sofar Inverters anyway. So no need to upgrade.

J14111 commented 1 year ago

Thanks for the heads up i will skip that one

Its been working perfectly thanks again

wills106 commented 1 year ago

I have just released 2022.12.8.1 as a prerelease with the adjustable block_size (amount of registers read at once)

I have set it to 50 which is the max according to the docs. Could you give it a go and let me know if it still works ok compared to the manually set 40.

J14111 commented 1 year ago

It worked fine for 2 or 3 mins then stopped updating possibly a bit close to the limit, is 40 a better value?

wills106 commented 1 year ago

Probably to be on the safe side. You could try dropping it to 48 and 46 etc.

J14111 commented 1 year ago

Ok i will have a play and let you know

wills106 commented 1 year ago

It's line 40

https://github.com/wills106/homeassistant-solax-modbus/blob/a8f2a518fc1b1f693dc91cca30f2e8234af7eacd/custom_components/solax_modbus/sensor.py#L33-L41

wills106 commented 1 year ago

Ideally you want it as high as possible then you can poll the Inverter quicker.

Although I doubt you could poll the inverter quicker than every 5s anyway due to the baud rate these Solis run at. I know the SolaX X3 Mic won't work at less than 5 and they run at the same speed. It could also be down to the CPU doing the work load and not the actual baud rate.

J14111 commented 1 year ago

48 seems to be fine even with a 5sec update

Thanks i will let you you know if it proves otherwise 🙂

wills106 commented 1 year ago

Yea there is no rush to push out the stable release. So just keep an eye on it for a day or so and let me know.

J14111 commented 1 year ago

I can confirm it workes perfectly, thanks

wills106 commented 1 year ago

Thanks for the feedback.