kellerza / sunsynk

Deye/Sunsynk Inverter Python library and Home Assistant OS Addon
https://kellerza.github.io/sunsynk/
MIT License
198 stars 85 forks source link

Wave RS485 to Ethernet #96

Closed w1tw0lf closed 1 year ago

w1tw0lf commented 1 year ago

Looking at purchasing one of these, https://www.robotics.org.za/W16529?search=wave%20rs4 as mentioned here, https://github.com/kellerza/sunsynk/issues/60#issuecomment-1396526228. Would this be the best option as I can't seem to find the usb versions.

kellerza commented 1 year ago

I've never tested it, but would definitely try it if my USB Wave or old Pi stops working.

Let us know the outcome, or send me one and I'll test it for you 😉

w1tw0lf commented 1 year ago

Will be grabbing one today, sure we should be able to get it to work. Should work with this part, if correct, "Modbus TCP to Modbus RTU Gateway Add-on" ?

kellerza commented 1 year ago

Nope, that Wave IS the gateway, so you point the addon to it tcp://1.1.1.1:502

w1tw0lf commented 1 year ago

Ah okay, perfect. Thank you. Will keep posted.

w1tw0lf commented 1 year ago

Here is some screenshots from the interface.

image

image

image

Now just need to wait for the actual install to happen.

cods4 commented 1 year ago

To add to this for other users I started with this Waveshare unit https://www.waveshare.com/rs232-485-to-eth.htm I chose it because of the more flexible supply voltage range. (I run all my comms and some fans off a 48-12V converter). It worked fine, but when I discovered I would need 3 separate units, one for each of my inverters, I decided to swap it with 3 of these: https://www.pusr.com/products/din-rail-rs485-serial-to-ethernet-converter-usr-dr302.html which also works fine and seems to have almost exactly the same software as the waveshare. It was just much easier to fit into my small comms cabinet on a DIN rail.

w1tw0lf commented 1 year ago

Solar was installed today.

Trying to connect to the modbus.

Do I need to select one of these:

image

dowermyr commented 1 year ago

Solar was installed today.

Trying to connect to the modbus.

Do I need to select one of these:

image

I am wondering of this too. Why do I need to chose a Device when using TCP?

kellerza commented 1 year ago

If in doubt, pick c... or you can read the docs:

DEVICE allows you to select the USB port in the UI. It will only be used if PORT is empty.

w1tw0lf commented 1 year ago

I am getting this error if I don't select anything there:

Failed to save add-on configuration, Device '' does not exist in Sunsynk Inverter Add-on (4bb530c7_hass-addon-sunsynk). Got {'PORT': 'tcp://x.x.x.x.502', 'DEVICE': '', 'DRIVER': 'umodbus', 'SUNSYNK_ID': "'22xxxxxxx88'", 'SENSOR_PREFIX': 'ss', 'SENSORS': ['total_pv_power', 'total_battery_charge', 'total_battery_discharge', 'total_grid_export', 'total_grid_import', 'battery_soc'], 'READ_SENSORS_BATCH_SIZE': 60, 'NUMBER_ENTITY_MODE': 'auto', 'PROFILES': [], 'MODBUS_SERVER_ID': 1, 'MQTT_HOST': 'core-mosquitto', 'MQTT_PORT': 1883, 'MQTT_USERNAME': 'hass', 'MQTT_PASSWORD': 'shoh4uco1ahBaug', 'DEBUG': 0}

kellerza commented 1 year ago

Just select something

w1tw0lf commented 1 year ago

Getting this in the logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. 2023-02-22 15:11:45,162 INFO Loading HASS OS configuration 2023-02-22 15:11:45,169 DEBUG could not patch umodbus: numpy not found 2023-02-22 15:11:45,173 INFO ############################################################ 2023-02-22 15:11:45,173 INFO Sensor deprecated: total_pv_power -> total_pv_energy 2023-02-22 15:11:45,173 INFO ############################################################ 2023-02-22 15:11:45,173 INFO Filter *last used for battery_soc, total_battery_charge, total_battery_discharge, total_grid_export, total_grid_import, total_pv_power 2023-02-22 15:11:45,175 INFO Reading startup sensors serial, rated_power 2023-02-22 15:11:55,187 ERROR Timeout reading: 2023-02-22 15:11:55,187 INFO ############################################################ 2023-02-22 15:11:55,188 INFO No response on the Modbus interface, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc 2023-02-22 15:11:55,188 INFO ############################################################ 2023-02-22 15:11:55,188 CRITICAL This Add-On will terminate in 30 seconds, use the Supervisor Watchdog to restart automatically. [cmd] ./run.py exited 0 [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal.

w1tw0lf commented 1 year ago

got a feeling either one of these 2 screens is where my issue is on the wave share

Doesn't seem like any traffice is flowing on below. image

image

w1tw0lf commented 1 year ago

Running out of ideas.... Double check connections, redone as well. Tested the cable with rj45 on both ends as well.

Anything on this page: image that needs to change ?

w1tw0lf commented 1 year ago

Some more info if it helps

2023-02-22 17:32:58,048 DEBUG open connection (#1) 2023-02-22 17:32:58,053 DEBUG <asyncio.TransportSocket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.30.33.5', 37268), raddr=('192.168.31.6', 502)> connected to 192.168.31.6:502: (<_SelectorSocketTransport fd=8 read=polling write=<idle, bufsize=0>>, <sockio.aio.StreamReaderProtocol object at 0x7fd7d7111c10>) 2023-02-22 17:33:08,059 ERROR Timeout reading: 2023-02-22 17:33:08,059 INFO ############################################################ 2023-02-22 17:33:08,060 INFO No response on the Modbus interface, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc 2023-02-22 17:33:08,060 INFO ############################################################ 2023-02-22 17:33:08,060 CRITICAL This Add-On will terminate in 30 seconds, use the Supervisor Watchdog to restart automatically.

cods4 commented 1 year ago

Here's the configuration of my 485-ETH device, hope this helps. image image image image

w1tw0lf commented 1 year ago

I am just missing the "modbus tcp" like on last screenshot. Everything else exactly like yours, still no luck.

w1tw0lf commented 1 year ago

Think that is why it isn't working, https://www.waveshare.com/wiki/RS485_TO_ETH

image

Spoke to support and was advice that an engineer might have firmware to enable it. Waiting on feedback.

w1tw0lf commented 1 year ago

Exchanged the https://www.robotics.org.za/W16529?search=wave%20rs4 for a https://www.robotics.org.za/USR-TCP232-410S?search=usr as it doesn't seems like the wave one is working.

But still no luck... unless I am completly missing something. image

[s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. 2023-02-23 12:04:32,390 INFO Loading HASS OS configuration 2023-02-23 12:04:32,401 DEBUG could not patch umodbus: numpy not found 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_active_energy 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_grid_export 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_grid_import 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_pv_energy 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_load_energy 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_battery_charge 2023-02-23 12:04:32,407 DEBUG last unit:kWh, id:total_battery_discharge 2023-02-23 12:04:32,407 INFO Filter *last used for total_active_energy, total_battery_charge, total_battery_discharge, total_grid_export, total_grid_import, total_load_energy, total_pv_energy 2023-02-23 12:04:32,408 DEBUG Using selector: EpollSelector 2023-02-23 12:04:32,410 INFO Reading startup sensors rated_power, serial 2023-02-23 12:04:32,416 DEBUG open connection (#1) 2023-02-23 12:04:32,423 DEBUG <asyncio.TransportSocket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.30.33.5', 35680), raddr=('192.168.31.6', 502)> connected to 192.168.31.6:502: (<_SelectorSocketTransport fd=8 read=polling write=<idle, bufsize=0>>, <sockio.aio.StreamReaderProtocol object at 0x7f489e13b1f0>) 2023-02-23 12:04:42,428 ERROR Timeout reading: 2023-02-23 12:04:42,429 INFO ############################################################ 2023-02-23 12:04:42,429 INFO No response on the Modbus interface, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc 2023-02-23 12:04:42,429 INFO ############################################################ 2023-02-23 12:04:42,429 CRITICAL This Add-On will terminate in 30 seconds, use the Supervisor Watchdog to restart automatically.

Used a new cable as well.....

w1tw0lf commented 1 year ago

All sorted... changed stop bit to 1 and works.

Sorry for being a pain.

w1tw0lf commented 1 year ago

Seems like the original device is a no go, unless some code is change and if even possible.

Response from waveshare:

Xin (Waveshare)

Feb 24, 2023, 14:23 GMT+8

Hi,sorry for replying late! 1 No, this is not a firmware problem, but a hardware problem.There is currently no latest firmware, and upgrading the firmware will not solve this problem. 2 This module does not support TCP Modbus, if you need to use this function, please purchase RS232/RS485 TO ETH Best wish!!

vexersa commented 1 year ago

I know the thread is closed but figured I'd post here for others looking to solve the same thing.

It looks like the DIEWU gateway also doesn't support Modbus TCP properly. I can send requests to the unit and the TX/RX light flashes but that's about all the (usable/interpretable) feedback I can get out of this thing.

I'll need to get a USR unit and try again.

vexersa commented 1 year ago

Hey @w1tw0lf,

I've purchased the same USR unit you have and I was hoping you could share your wiring pinout with me? I'm getting the same issue as before:

2023-02-28 09:35:11,332 ERROR Timeout reading: 2023-02-28 09:35:11,332 INFO ############################################################ 2023-02-28 09:35:11,332 INFO No response on the Modbus interface, try checking the wiring to the Inverter, the USB-to-RS485 converter, etc 2023-02-28 09:35:11,332 INFO ############################################################

w1tw0lf commented 1 year ago

On the screenshot in, https://github.com/kellerza/sunsynk/issues/96#issuecomment-1441487084 make sure stop bit is set to 1 and the rest as per the screenshot. Wiring is done exactly like in the readme.

vexersa commented 1 year ago

On the screenshot in, #96 (comment) make sure stop bit is set to 1 and the rest as per the screenshot. Wiring is done exactly like in the readme.

@w1tw0lf Thanks. Turns out my wiring was indeed faulty. One of the the wires had broken off.

Looks to be working now!

I might be missing something but I can't seem to add new sensors to the config. Adding the desired sensor into the SENSORS input box doesn't work. Do you know where the config file is located?

w1tw0lf commented 1 year ago

when in the add-on, configuration, click on the 3 dots, top right, select edit as yaml and add it manually.

vexersa commented 1 year ago

Awesome thanks.

On Wed, 1 Mar 2023 at 09:43, w1tw0lf @.***> wrote:

when in the add-on, configuration, click on the 3 dots, top left, select edit as yaml and add it manually.

— Reply to this email directly, view it on GitHub https://github.com/kellerza/sunsynk/issues/96#issuecomment-1449495537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB47W47X3SZMKCIKON37BALWZ343JANCNFSM6AAAAAAUUAQ44Y . You are receiving this because you commented.Message ID: @.***>

vexersa commented 1 year ago

@w1tw0lf

Would you happen to know what sensor is responsible for current (real time) PV output?

jabezz commented 1 year ago

You can look at config in: https://github.com/kellerza/sunsynk/issues/77#issue-1498540997

pv comes from:

You can combine them based on this thread: https://github.com/kellerza/sunsynk/issues/102#issuecomment-1446607039

kellerza commented 1 year ago

You can also use filter modifiers, i.e. pv1_power:now for immediate values

vexersa commented 1 year ago

Thanks very much

On Wed, 1 Mar 2023 at 11:56, Johann Kellerman @.***> wrote:

You can also use filter modifiers, i.e. pv1_power:now for immediate values

— Reply to this email directly, view it on GitHub https://github.com/kellerza/sunsynk/issues/96#issuecomment-1449741220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB47W4ZTTHMVONVDHDMU3JLWZ4MLHANCNFSM6AAAAAAUUAQ44Y . You are receiving this because you commented.Message ID: @.***>

vexersa commented 1 year ago

Another question please 🙏

Is the below correct? image

I have added the pv1_power:now, but it isn't available for reference as an entity, etc.

image

Is it possible for pv1_power and pv1_power:now to exist in the config simultaneously?

kellerza commented 1 year ago

Not possible. The log will show you what happened

jabezz commented 1 year ago

You cannot have -pv1_power and pv1_power:now They are the same sensor ... the :now just specifies how often it should refresh. I just use pv1_power as is. If it has a certain amount of change, it reflects. Already pretty real-time without the:now attribute.

vexersa commented 1 year ago

Great thanks very much for the clarification. Much appreciated.

zit501 commented 1 year ago

On the screenshot in, #96 (comment) make sure stop bit is set to 1 and the rest as per the screenshot. Wiring is done exactly like in the readme.

@w1tw0lf Thanks. Turns out my wiring was indeed faulty. One of the the wires had broken off.

Looks to be working now!

I might be missing something but I can't seem to add new sensors to the config. Adding the desired sensor into the SENSORS input box doesn't work. Do you know where the config file is located?

Hey @vexersa and/or @w1tw0lf,

Can you kindly do me a favour and check your logs in the addon? I have the same USR device, and it appears to be working fine, however when one checks the logs you can see there are timeouts happening every minute or so. Upon closer inspection of the data one notices that there is indeed a dead spot during this reconnection period.

Here's what I mean: ''' [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done. 2023-05-18 18:05:45,665 INFO options Loading HASS OS configuration 2023-05-18 18:05:45,700 INFO Using Single phase sensor definitions. 2023-05-18 18:05:45,703 INFO Connecting to tcp://192.168.88.14:502 2023-05-18 18:05:45,709 INFO Reading startup sensors rated_power, serial 2023-05-18 18:05:45,825 INFO ############################################################ 2023-05-18 18:05:45,825 INFO Inverter serial number '2301069881' 2023-05-18 18:05:45,826 INFO ############################################################ 2023-05-18 18:05:45,837 INFO MQTT: Connecting to sunsynkmqtt@core-mosquitto:1883 2023-05-18 18:05:45,873 INFO MQTT: Connection successful 2023-05-18 18:06:48,168 ERROR Read Error: <class 'Exception'>: (1,190,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:07:07,621 ERROR Read Error: <class 'Exception'>: (1,172,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:08:07,837 ERROR Read Error: <class 'Exception'>: (1,166,2) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:09:12,228 ERROR Read Error: <class 'Exception'>: (1,175,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:09:27,602 ERROR Read Error: <class 'Exception'>: (1,190,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:09:37,640 ERROR Read Error: <class 'Exception'>: (1,79,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:10:02,731 ERROR Read Error: <class 'Exception'>: (1,79,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:10:37,140 ERROR Read Error: <class 'Exception'>: (1,190,1) readexactly call timeout on '192.168.88.14:502' 2023-05-18 18:10:56,356 ERROR Read Error: <class 'Exception'>: (1,172,1) readexactly call timeout on '192.168.88.14:502' '''

Wondering if yours is fine, or doing the same thing. As I said above, it all appears to be working fine, data is updating the sensors. However when looking at the logs there seems to be something causing these regular timeouts.

vexersa commented 1 year ago

Hey @zit501,

I get a similar set of ERROR Read Error lines in my log, but my config seems to be working fine also.

2023-05-19 09:32:49,847 INFO Load power:step:mean: 723->624, 13 samples 2023-05-19 09:32:49,848 INFO Load L1 power:step:mean: 723->624, 13 samples 2023-05-19 09:35:39,991 ERROR Read Error: <class 'Exception'>: (1,187,1) readexactly call timeout on '192.168.0.201:502' 2023-05-19 09:36:17,549 ERROR Read Error: <class 'Exception'>: (1,175,4) readexactly call timeout on '192.168.0.201:502' 2023-05-19 09:36:35,750 ERROR Read Error: <class 'Exception'>: (1,109,4) readexactly call timeout on '192.168.0.201:502' 2023-05-19 09:36:47,839 ERROR Read Error: <class 'Exception'>: (1,61,1) readexactly call timeout on '192.168.0.201:502' 2023-05-19 09:36:48,604 INFO Inverter power:step:mean: 570.1->662, 20 samples 2023-05-19 09:36:49,614 INFO Load power:step:mean: 582.9->675, 21 samples

kellerza commented 1 year ago

Why do you have 2 stop bits configured here? Should it not be 1?

w1tw0lf commented 1 year ago

In the comment just below, https://github.com/kellerza/sunsynk/issues/96#issuecomment-1441544075, change to 1 and solve it.

w1tw0lf commented 1 year ago

Same on my side as well @zit501

Everything working 100s.

zit501 commented 1 year ago

Thanks guys,

Yes, everything working perfectly, except upon closer inspection in the logs. The delay during the reconnection every ~45s is a minor inconvenience, I'm more just intrigued about where this is coming from.