nikshriv / cync_lights

Home Assistant Integration for controlling Cync switches, plugs, and bulbs
164 stars 57 forks source link

Error in 2024.5.0 where connection to Cync server reset #94

Closed nschimme closed 3 months ago

nschimme commented 5 months ago

I've been noticing the following and odd light behavior since upgrading to 2024.5.0

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:106 integration: Cync Lights (documentation) First occurred: May 2, 2024 at 8:37:35 PM (1588 occurrences) Last logged: 8:16:03 AM

RuntimeError: Detected that custom integration 'cync_lights' calls async_write_ha_state from a thread at custom_components/cync_lights/cync_hub.py, line 638: self._update_callback(). Please report it to the author of the 'cync_lights' custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:110 integration: Cync Lights (documentation) First occurred: May 2, 2024 at 8:37:35 PM (1592 occurrences) Last logged: 8:17:48 AM

Connection to Cync server reset, restarting in 15 seconds

mmstano commented 5 months ago

I’m also experiencing this after upgrading to 2024.5. I’m also getting other warnings, like disabling SSL verification and skipping corrupted packets.

`This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:451 integration: Cync Lights (documentation) First occurred: May 2, 2024 at 9:49:45 PM (1681 occurrences) Last logged: 11:07:11 AM

Connection problem, disabling SSL verification Traceback (most recent call last): File "/config/custom_components/cync_lights/cync_hub.py", line 451, in _connect self.reader, self.writer = await asyncio.open_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in openconnection transport, = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1147, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1180, in _create_connection_transport await waiter File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 578, in _on_handshake_complete raise handshake_exc File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 560, in _do_handshake self._sslobj.do_handshake() File "/usr/local/lib/python3.12/ssl.py", line 917, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'cm.gelighting.com'. (_ssl.c:1000) `

and

`This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:535 integration: Cync Lights (documentation) First occurred: May 2, 2024 at 9:50:00 PM (22120 occurrences) Last logged: 11:06:52 AM

Skipping corrupted packet, 1019 is not 995 Skipping corrupted packet, 1459753091 is not 72 Skipping corrupted packet, 1493307563 is not 975 Skipping corrupted packet, 1459753131 is not 975 Skipping corrupted packet, 1593970859 is not 975 `

GreggTom commented 5 months ago

Same problem since upgrade to 2024.5.0. RuntimeError: Detected that custom integration 'cync_lights' calls async_write_ha_state from a thread at custom_components/cync_lights/cync_hub.py, line 638: self._update_callback(). Please report it to the author of the 'cync_lights' custom integration.

GreggTom commented 5 months ago

Same problem with 2024.5.1

jkjunk42 commented 5 months ago

Same here. Tried to restore backup but couldn't get it working again

aserper commented 5 months ago

Same

nschimme commented 5 months ago

Related discussion for another plugin: https://community.home-assistant.io/t/how-to-fix-custom-integration-brematic-calls-async-write-ha-state/722238

mmstano commented 5 months ago

@nschimme Thanks for the fix! Though, by the looks of it the original author isn’t responding to issues. I’m not too familiar with how GitHub works when it comes to commits/merges/PR/ etc, but there’s a fork that’s already 17 commits ahead of the original at https://github.com/kylev/cync_lights. Would we be better off submitting the request there?

nschimme commented 5 months ago

Probably best @kylev do the same change there as it wasn't complex.

GreggTom commented 5 months ago

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:535 integration: Cync Lights (documentation) First occurred: 11:36:24 AM (40 occurrences) Last logged: 11:39:55 AM

Skipping corrupted packet, 1019 is not 995

GreggTom commented 5 months ago

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:451 integration: Cync Lights (documentation) First occurred: 11:36:46 AM (8 occurrences) Last logged: 11:39:41 AM

Connection problem, disabling SSL verification Traceback (most recent call last): File "/config/custom_components/cync_lights/cync_hub.py", line 451, in _connect self.reader, self.writer = await asyncio.open_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in openconnection transport, = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1147, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1180, in _create_connection_transport await waiter File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 578, in _on_handshake_complete raise handshake_exc File "/usr/local/lib/python3.12/asyncio/sslproto.py", line 560, in _do_handshake self._sslobj.do_handshake() File "/usr/local/lib/python3.12/ssl.py", line 917, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'cm.gelighting.com'. (_ssl.c:1000)

GreggTom commented 5 months ago

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:507 integration: Cync Lights (documentation) First occurred: 11:36:31 AM (8 occurrences) Last logged: 11:39:26 AM

Connection to Cync server reset, restarting in 15 seconds

GreggTom commented 5 months ago

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:501 integration: Cync Lights (documentation) First occurred: 11:36:31 AM (8 occurrences) Last logged: 11:39:26 AM

Detected that custom integration 'cync_lights' calls async_write_ha_state from a thread at custom_components/cync_lights/cync_hub.py, line 1452: self._update_callback(). Please report it to the author of the 'cync_lights' custom integration. Traceback (most recent call last): File "/config/custom_components/cync_lights/cync_hub.py", line 501, in _connect result = task.result() ^^^^^^^^^^^^^ File "/config/custom_components/cync_lights/cync_hub.py", line 824, in _update_state dev.publish_update() File "/config/custom_components/cync_lights/cync_hub.py", line 1452, in publish_update self._update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state self.hass.verify_event_loop_thread("async_write_ha_state") File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread frame.report( File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report _report_integration(what, integration_frame, level, error_if_integration) File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration raise RuntimeError( RuntimeError: Detected that custom integration 'cync_lights' calls async_write_ha_state from a thread at custom_components/cync_lights/cync_hub.py, line 1452: self._update_callback(). Please report it to the author of the 'cync_lights' custom integration.