sunsynk: Crash when changing battery charge settings

Issue related to

Sunsynk / mbusd Home Assistant Add-On

Describe the issue/bug

When requesting a change to the battery settings, the add-on crashes (using Dev add-on).

Expected behavior Setting changes are made

Your environment

  • Home Assistant version: 2023.7.1
  • Addon version: 2023.01.19b-0.2.9
  • Inverter make: Sunsynk
  • Inverter Model: 16k
  • Inverter Firmware: COMM:e424 - MCU:9013

Logs

2023-07-08 17:52:54,813 INFO    MQTT: Connecting to homeassistant@core-mosquitto:1883
2023-07-08 17:52:54,859 INFO    MQTT: Connection successful
2023-07-08 17:53:08,654 INFO    Writing sensor Prog1 Capacity: prog1_capacity=(40,) [old (15,)]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 489, in wait_for
    fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/app/./run.py", line 479, in <module>
    LOOP.run_until_complete(main(LOOP))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/src/app/./run.py", line 461, in main
    await write_sensors()
  File "/usr/src/app/./run.py", line 440, in write_sensors
    await SUNSYNK.write_sensor(  # pylint: disable=no-value-for-parameter
  File "/usr/local/lib/python3.9/site-packages/sunsynk/sunsynk.py", line 50, in write_sensor
    await self.write_register(address=sensor.reg_address[0], value=val1)
  File "/usr/local/lib/python3.9/site-packages/sunsynk/pysunsynk.py", line 88, in write_register
    w_r = await self.client.write_registers(
  File "/usr/local/lib/python3.9/site-packages/pymodbus/client/asynchronous/async_io/__init__.py", line 35, in execute
    resp = await asyncio.wait_for(req, timeout=self._timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 491, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
[cmd] ./run.py exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 30 (10 by maintainers)

Most upvoted comments

I’m using the rs485 port and writing is happening for me just fine. I have the WiFi dongle on the serial port, and used to have battery communication on canbus, but I removed that. Maybe you have a newer model, I don’t have the 2 in 1 port, everything is separate on my model.

Aug 30, 2023, 03:31 by @.***:

I’m not sure it will work with the 2-in-1 port, since that is still RS485 but just a different port.

According to the links you shared, you have to move it to the RS232 port. So no more RS485

https://user-images.githubusercontent.com/6756881/264263305-db21243b-7e77-4895-8d97-02ace1c31979.png

— Reply to this email directly, > view it on GitHub https://github.com/kellerza/sunsynk/issues/156#issuecomment-1698643969> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/A6GTYDH7EBEKZM5ZDT4BR53XX3T37ANCNFSM6AAAAAA2C6OFAA> . You are receiving this because you were mentioned.> Message ID: > <kellerza/sunsynk/issues/156/1698643969> @> github> .> com>

@kellerza All of those I tried to write to work. It shows an error in the logs when writing every time, but still proceeds with the write. It seems like the first try fails but then 2nd try works. To confirm, I have written to grid charge enabled, grid current, and battery charge current. All have this behavior.

However, what I said was that the grid charge enabled code is set to sensor, which is read only. I made a custom sensor using switchRWsensor for the same modbus register, and then it worked. So you may want to consider changing sensor to switchrwsensor for this register.