Jump to content

Sunsynk Monitoring - USB to RS485 - 'Serial' object has no attribute 'host'


Sparkz0629

Recommended Posts

Hey Everyone, 

 

I hope you guys can help.

Ive recently setup a pi with the addon (https://github.com/kellerza/sunsynk) installed. @kellerza

This is connected to my Sunsynk 8kw inverter using the following dongle:

https://www.robotics.org.za/RS485-3P

The idea is it will publish to my main HA install on a seperate NUC via MQTT.

I managed to get it speaking to the inverter, however it throws the following error when trying to get the sensor info:

 

Quote
2023-04-14 16:57:46,246 ERROR   Read ErrorTotal Grid Import: <class 'Exception'>: (1,80,1) 'Serial' object has no attribute 'host'
2023-04-14 16:57:46,345 WARNING Total Grid Import:last: should not be None
2023-04-14 16:58:56,565 ERROR   Read Error: <class 'Exception'>: (1,72,4) 'Serial' object has no attribute 'host'
2023-04-14 17:00:05,914 ERROR   Read Error: <class 'Exception'>: (1,80,1) 'Serial' object has no attribute 'host'
2023-04-14 17:02:15,366 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'
2023-04-14 17:03:24,602 ERROR   Read Error: <class 'Exception'>: (1,72,4) 'Serial' object has no attribute 'host'
2023-04-14 17:04:33,915 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'
2023-04-14 17:05:43,246 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'

 

 

Here are the full logs:

 

Quote
[services.d] starting services
[services.d] done.
2023-04-14 16:57:24,580 INFO    options Loading HASS OS configuration
2023-04-14 16:57:24,631 INFO    Using Single phase sensor definitions.
2023-04-14 16:57:24,632 INFO    Added hidden sensors as other sensors depend on it: 
2023-04-14 16:57:24,635 INFO    Connecting to serial:///dev/ttyUSB0
2023-04-14 16:57:24,674 INFO    Reading startup sensors serial, rated_power
2023-04-14 16:57:24,812 INFO    ############################################################
2023-04-14 16:57:24,813 INFO                Inverter serial number '22x71x7x2x'
2023-04-14 16:57:24,814 INFO    ############################################################
2023-04-14 16:57:24,832 INFO    MQTT: Connecting to [email protected]:1883
2023-04-14 16:57:25,102 INFO    MQTT: Connection successful
2023-04-14 16:57:35,926 ERROR   Read Error: <class 'Exception'>: (1,72,4) 'Serial' object has no attribute 'host'
2023-04-14 16:57:35,948 INFO    Retrying individual sensors: ['total_battery_charge', 'total_battery_discharge', 'total_grid_import', 'battery_soc']
2023-04-14 16:57:46,246 ERROR   Read ErrorTotal Grid Import: <class 'Exception'>: (1,80,1) 'Serial' object has no attribute 'host'
2023-04-14 16:57:46,345 WARNING Total Grid Import:last: should not be None
2023-04-14 16:58:56,565 ERROR   Read Error: <class 'Exception'>: (1,72,4) 'Serial' object has no attribute 'host'
2023-04-14 17:00:05,914 ERROR   Read Error: <class 'Exception'>: (1,80,1) 'Serial' object has no attribute 'host'
2023-04-14 17:02:15,366 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'
2023-04-14 17:03:24,602 ERROR   Read Error: <class 'Exception'>: (1,72,4) 'Serial' object has no attribute 'host'
2023-04-14 17:04:33,915 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'
2023-04-14 17:05:43,246 ERROR   Read Error: <class 'Exception'>: (1,78,1) 'Serial' object has no attribute 'host'
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/base.py", line 103, in wrapper
    reply = await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/base.py", line 82, in wrapper
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/base.py", line 449, in read
    return await self._read(size=size)
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/posix.py", line 281, in _read
    buf = await self._read1(size)
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/posix.py", line 38, in _read1
    await read_event.wait()
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
    await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
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/local/lib/python3.9/site-packages/serialio/aio/base.py", line 67, in wrapper
    return await coro
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 491, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/sunsynk/sunsynk.py", line 86, in read_sensors
    r_r = await asyncio.wait_for(
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 478, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.9/site-packages/sunsynk/usunsynk.py", line 61, in read_holding_registers
    return await self.client.read_holding_registers(self.server_id, start, length)
  File "/usr/local/lib/python3.9/site-packages/async_modbus/core.py", line 181, in read_holding_registers
    return await self._send_message(request)
  File "/usr/local/lib/python3.9/site-packages/async_modbus/core.py", line 142, in _send_message
    return await self.protocol._async_send_message(
  File "/usr/local/lib/python3.9/site-packages/async_modbus/core.py", line 74, in send_message_rtu
    response_remainder = await reader.readexactly(
  File "/usr/local/lib/python3.9/site-packages/serialio/aio/base.py", line 69, in wrapper
    msg = "{} call timeout on '{}:{}'".format(name, self.host, self.port)
AttributeError: 'Serial' object has no attribute 'host'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/app/./run.py", line 241, in read_sensors
    await inv.read_sensors(sensors)
  File "/usr/local/lib/python3.9/site-packages/sunsynk/sunsynk.py", line 94, in read_sensors
    raise Exception(  # pylint: disable=raise-missing-from,broad-exception-raised
Exception: (1,78,1) 'Serial' object has no attribute 'host'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/app/./run.py", line 373, 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 356, in main
    await polltask
  File "/usr/src/app/./run.py", line 346, in poll_sensors
    if await read_sensors(SS[0], [s.sensor for s in states if s.sensor]):
  File "/usr/src/app/./run.py", line 253, in read_sensors
    raise IOError(f"Multiple Modbus read errors: {err}") from err
OSError: Multiple Modbus read errors: (1,78,1) 'Serial' object has no attribute 'host'
[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.

 

 

Configs are as follows:

 

Quote

DRIVER: umodbus
INVERTERS:
  - SERIAL_NR: "22x71x7x2x"
    HA_PREFIX: SS
    MODBUS_ID: 1
    PORT: serial:///dev/ttyUSB0
SENSOR_DEFINITIONS: single-phase
SENSORS:
  - total_battery_charge
  - total_battery_discharge
  - total_grid_import
  - battery_soc
SENSORS_FIRST_INVERTER: []
MANUFACTURER: Sunsynk
READ_SENSORS_BATCH_SIZE: 60
NUMBER_ENTITY_MODE: auto
MQTT_HOST: 192.168.1.20
MQTT_PORT: 1883
MQTT_USERNAME: xxxx
MQTT_PASSWORD: xxxx
DEBUG: 0
DEBUG_DEVICE: /dev/ttyAMA0

 

Not quite sure where i need to look to get the issue sorted?

 

Thanks a mil

Link to comment
Share on other sites

I amended my config to set READ_SENSORS_BATCH_SIZE = 8 instead of 60.

 

Now it connects, however it only runs for around 25-45 minutes, with many "Unavailable" status inbetween, and then eventually it disconnects completely and the addon needs to be restarted. 

 

I still see the same error being spammed: 

2023-04-15 21:23:05,493 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
Link to comment
Share on other sites

Now it seems to be a little more stable. Only hard crashes every 8-10 hours.

Quite a few instances of "Unavailable" in the sensor history, but atleast appears to recover. (Until the hard crash mentioned above)

Still seeing a ton of the below errors in the logs:

Quote
2023-04-17 20:18:09,598 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:18:23,719 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:18:33,809 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:18:44,984 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:18:55,138 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:19:09,257 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:19:20,352 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:19:30,505 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:19:45,631 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:19:55,721 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:20:10,846 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:20:20,936 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:20:34,105 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:20:44,192 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:20:57,312 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:21:07,467 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:21:22,592 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'
2023-04-17 20:21:32,742 ERROR   Read Error: <class 'Exception'>: (1,172,1) 'Serial' object has no attribute 'host'
2023-04-17 20:21:49,869 ERROR   Read Error: <class 'Exception'>: (1,169,1) 'Serial' object has no attribute 'host'

 

Link to comment
Share on other sites

Just started to get this same issue after starting to use the new version of the addon. Seems to have been resolved now after a full restart of the system and ensuring the original version of the addon does not restart to conflict with my new (multi) version

Edited by Koad
Link to comment
Share on other sites

The error you show @Sparkz0629 seems to be related to the umodbus driver

There are some options here - https://github.com/kellerza/sunsynk/issues/131

Personally, I use this via mbusd all the time and gave away one of my Pi's that I used to test the direct serial interface. So unless someone helps out with some testing its not something easily solved by just looking at the code.

Btw, the pymodbus driver seems to be a lot more stable these days, they have done some significant updates

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

I am installing the @kellerza Sunsynk Inverter Add-on (Multi) and I get this error message when I click on 'Install'.

Failed to install add-on

The command '/bin/ash -o pipefail -c pip3 install --no-cache-dir --disable-pip-version-check paho-mqtt==1.6.1 mqtt-entity==0.0.3 sunsynk[pymodbus,umodbus]==0.3.6 pyyaml==5.4.1' returned a non-zero code: 1

Can anyone help me work out what I have done wrong? 
I have followed the instructions - the repository has been added to HA. I installed a MQTT Broker.
Thanks, Ken

Edited by Ken I
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...