kellerza / sunsynk

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

Connection reset by peer #170

Closed e1ace closed 1 year ago

e1ace commented 1 year ago

Issue related to

Sunsynk Home Assistant Add-On

Describe the issue/bug

Every few minutes I receive [Errno 104] Connection reset by peer. _Read Error (poll_need_toread): <class 'Exception'>: (1,59,1) [Errno 104] Connection reset by peer

This may be normal.

Expected behavior If these occur often and nothing can be done, perhaps this should be a warning? Unless there is something wrong with my setup?

Your environment

Logs

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun sunsynk (no readiness notification)
s6-rc: info: service legacy-services successfully started
13:00:58 INFO    Loading HASS OS configuration
13:00:58 INFO    Replaced Schedule(key='w', read_every=5, report_every=60, change_by=80, change_percent=0, change_any=False)
13:00:58 INFO    Default  Schedule(key='date_time', read_every=60, report_every=60, change_by=0, change_percent=0, change_any=True)
13:00:58 INFO    Default  Schedule(key='rated_power', read_every=0, report_every=0, change_by=0, change_percent=0, change_any=False)
13:00:58 INFO    Default  Schedule(key='serial', read_every=0, report_every=0, change_by=0, change_percent=0, change_any=False)
13:00:58 INFO    Default  Schedule(key='rw', read_every=5, report_every=300, change_by=0, change_percent=0, change_any=True)
13:00:58 INFO    Default  Schedule(key='kwh', read_every=300, report_every=300, change_by=0, change_percent=0, change_any=False)
13:00:58 INFO    Default  Schedule(key='any_unit', read_every=15, report_every=300, change_by=0, change_percent=0, change_any=False)
13:00:58 INFO    Default  Schedule(key='no_unit', read_every=15, report_every=300, change_by=0, change_percent=0, change_any=True)
13:00:58 INFO    Using Single phase sensor definitions.
13:00:58 INFO    Connecting to tcp://homeassistant.local:502
13:00:58 INFO    Reading startup sensors Prog2 Time, Battery Low Capacity, Prog5 Time, Prog1 Time, Prog6 Time, Prog3 Time, Serial, Rated power, Prog4 Time
13:00:58 INFO    ############################################################
13:00:58 INFO                Inverter serial number 'xxx'
13:00:58 INFO    ############################################################
13:00:58 INFO    MQTT: Connecting to mqtt_user@core-mosquitto:1883
13:00:58 INFO    MQTT: Connection successful
13:01:10 ERROR   Read Error (poll_need_to_read): <class 'Exception'>: (1,169,10) [Errno 104] Connection reset by peer
13:05:00 ERROR   Read Error (poll_need_to_read): <class 'Exception'>: (1,59,1) [Errno 104] Connection reset by peer
kellerza commented 1 year ago

To improve things you can consider tuning down the read intervals (especially for Watt sensors) to 2 seconds or 5 seconds.

Keep an eye on the callback stats (it gives you an idea how long it takes to read from the inverter

image

From mine you can see in the last 2 minutes I executed a read 97 times. 15 of these calls took longer than 1 second (my interval)

There were 21 seconds that a read start slipped

Changing to read every 2 seconds might improve it.

image
e1ace commented 1 year ago

Thanks. Mine was set to 5. Interestingly I've actually set it to 2 and I have not seen any errors for around 12 hours.

Is there a reason the Read Errors were always (1,169,10) and (1,59,1) - I think there ended up being around 30 of them over the course of a couple hours - no other errors.

kellerza commented 1 year ago

169 is grid power and should be read every 2 seconds, not sure why it would error. It might be during a longer read (i.e. when you also read config). You can try change the batch_size / allow gap

What HW do you read with?

e1ace commented 1 year ago

FTDI Cable with shielded CAT6 (about 4m long).

I'll play around with the settings - I'm sure it isn't a bug, so I'll close the issue.