ollo69 / ha-samsungtv-smart

📺 Home Assistant SamsungTV Smart Component with simplified SmartThings API Support configurable from User Interface.
Apache License 2.0
471 stars 60 forks source link

Samsung TV Smart causing HA Core Crash (I think) #121

Closed ChirpyTurnip closed 2 years ago

ChirpyTurnip commented 2 years ago

Hi,

Whenever I'm not home for 24+ hours HA crashes. I can restart it remotely by connecting to the SSH console and running "ha core restart" and then everything runs again just fine for about 24 hours and then it dies again.

In contrast when I'm home HA doesn't crash it just keeps running, rock solid with no crashes. In the error log when I look after a crash I can see a whole lot of references to the Samsung integration. Pretty much the same messages show up after every crash.

The only difference between being home and away is that I don't turn on either of my two Samsung Smart TVs... So I suspect that the act of turning them on at least once a day keeps something working that subsequently falls over we are away for a few days.

If you could look at the log below and tell me if I'm on the right track that would be appreciated! Of course it would be even better if this was a bug that could be fixed... :-)

2021-12-31 23:53:28 WARNING (MainThread) [homeassistant.components.websocket_api.http.connection] [139976213419152] Disconnected: Did not receive auth message within 10 seconds 2022-01-01 00:23:58 ERROR (MainThread) [pyenvisalink.dsc_client] The previous command resulted in a checksum failure. 2022-01-01 00:46:04 ERROR (MainThread) [pyenvisalink.dsc_client] The previous command resulted in a checksum failure. 2022-01-01 01:09:37 ERROR (MainThread) [pyenvisalink.dsc_client] The previous command resulted in a checksum failure. 2022-01-01 01:20:01 ERROR (MainThread) [pyenvisalink.dsc_client] The previous command resulted in a checksum failure. 2022-01-01 01:32:43 ERROR (MainThread) [pyenvisalink.envisalink_base_client] Received invalid message. Skipping. 2022-01-01 01:47:40 ERROR (MainThread) [pyenvisalink.dsc_client] The previous command resulted in a checksum failure. 2022-01-01 01:56:39 WARNING (MainThread) [homeassistant.runner] Task could not be canceled and was still running after shutdown: <Task pending name='Task-500' coro=<BaseIoT.connect() running at /usr/local/lib/python3.9/site-packages/hass_nabucasa/iot_base.py:108> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f4ee73cb970>()]>> 2022-01-01 01:56:39 WARNING (MainThread) [homeassistant.runner] Task could not be canceled and was still running after shutdown: <Task pending name='Task-11287' coro=<BaseIoT.connect() running at /usr/local/lib/python3.9/site-packages/hass_nabucasa/iot_base.py:108> wait_for=<Future pending cb=[shield.._outer_done_callback() at /usr/local/lib/python3.9/asyncio/tasks.py:905, <TaskWakeupMethWrapper object at 0x7f4ecc1ff5e0>()]>> 2022-01-01 01:56:39 WARNING (Thread-17) [homeassistant.util.executor] Thread[SyncWorker_1] is still running at shutdown: File "/usr/local/lib/python3.9/threading.py", line 930, in _bootstrap self._bootstrap_inner() File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, self._kwargs) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 77, in _worker work_item.run() File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, *self.kwargs) File "/config/custom_components/samsungtv_smart/media_player.py", line 463, in _ping_device result = self._ws.ping_device() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 680, in ping_device result = self._ping.ping() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 114, in ping out = pinger.communicate() File "/usr/local/lib/python3.9/subprocess.py", line 1134, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/local/lib/python3.9/subprocess.py", line 1979, in _communicate ready = selector.select(timeout) File "/usr/local/lib/python3.9/selectors.py", line 416, in select fd_event_list = self._selector.poll(timeout) 2022-01-01 01:56:39 WARNING (Thread-17) [homeassistant.util.executor] Thread[SyncWorker_7] is still running at shutdown: File "/usr/local/lib/python3.9/threading.py", line 930, in _bootstrap self._bootstrap_inner() File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(self._args, self._kwargs) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 77, in _worker work_item.run() File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, *self.kwargs) File "/config/custom_components/samsungtv_smart/media_player.py", line 463, in _ping_device result = self._ws.ping_device() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 680, in ping_device result = self._ping.ping() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 114, in ping out = pinger.communicate() File "/usr/local/lib/python3.9/subprocess.py", line 1134, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/local/lib/python3.9/subprocess.py", line 1979, in _communicate ready = selector.select(timeout) File "/usr/local/lib/python3.9/selectors.py", line 416, in select fd_event_list = self._selector.poll(timeout) 2022-01-01 01:56:39 ERROR (SyncWorker_7) [concurrent.futures] exception calling callback for <Future at 0x7f4ecbdbaca0 state=finished raised SystemExit> Traceback (most recent call last): File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(self.args, **self.kwargs) File "/config/custom_components/samsungtv_smart/media_player.py", line 463, in _ping_device result = self._ws.ping_device() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 680, in ping_device result = self._ping.ping() File "/config/custom_components/samsungtv_smart/api/samsungws.py", line 114, in ping out = pinger.communicate() File "/usr/local/lib/python3.9/subprocess.py", line 1134, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/local/lib/python3.9/subprocess.py", line 1979, in _communicate ready = selector.select(timeout) File "/usr/local/lib/python3.9/selectors.py", line 416, in select fd_event_list = self._selector.poll(timeout) SystemExit

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 329, in _invoke_callbacks callback(self) File "/usr/local/lib/python3.9/asyncio/futures.py", line 398, in _call_set_state dest_loop.call_soon_threadsafe(_set_state, destination, source) File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:39 ERROR (Thread-17) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/runner.py", line 173, in _do_shutdown loop.call_soon_threadsafe(future.set_result, None) File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, self._kwargs) File "/usr/src/homeassistant/homeassistant/runner.py", line 175, in _do_shutdown loop.call_soon_threadsafe(future.set_exception, ex) File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:41 ERROR (Thread-3) [paho.mqtt.client] Caught exception in on_message: Event loop is closed 2022-01-01 01:56:41 ERROR (Thread-3) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, self._kwargs) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3591, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3327, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message on_message(self, self._userdata, message) File "/usr/src/homeassistant/homeassistant/components/mqtt/init.py", line 897, in _mqtt_on_message self.hass.add_job(self._mqtt_handle_message, msg) File "/usr/src/homeassistant/homeassistant/core.py", line 333, in add_job self.loop.call_soon_threadsafe(self.async_add_job, target, args) File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:43 ERROR (stream_worker) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(self._args, self._kwargs) File "/usr/src/homeassistant/homeassistant/components/stream/init.py", line 298, in _run_worker stream_worker( File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 537, in stream_worker muxer.mux_packet(packet) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 221, in mux_packet self.flush(packet, last_part=True) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 293, in flush self._hass.loop.call_soon_threadsafe( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:44 ERROR (stream_worker) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, self._kwargs) File "/usr/src/homeassistant/homeassistant/components/stream/init.py", line 298, in _run_worker stream_worker( File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 537, in stream_worker muxer.mux_packet(packet) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 221, in mux_packet self.flush(packet, last_part=True) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 293, in flush self._hass.loop.call_soon_threadsafe( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:44 ERROR (stream_worker) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, *self._kwargs) File "/usr/src/homeassistant/homeassistant/components/stream/init.py", line 298, in _run_worker stream_worker( File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 537, in stream_worker muxer.mux_packet(packet) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 221, in mux_packet self.flush(packet, last_part=True) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 293, in flush self._hass.loop.call_soon_threadsafe( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed 2022-01-01 01:56:44 ERROR (stream_worker) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(self._args, **self._kwargs) File "/usr/src/homeassistant/homeassistant/components/stream/init.py", line 298, in _run_worker stream_worker( File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 537, in stream_worker muxer.mux_packet(packet) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 221, in mux_packet self.flush(packet, last_part=True) File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 293, in flush self._hass.loop.call_soon_threadsafe( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 791, in call_soon_threadsafe self._check_closed() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

This is the last line in the log....and then she's dead Jim.....

Cheers, CP.

ollo69 commented 2 years ago

This seems more related to a general error and integration error is just a consequence. But I suggest you to disable integration next time that you will be away for more than 24h and check if ha fail anyway.

ollo69 commented 2 years ago

I take an additional look to this and probably you are right. I need to find a different way to manage ping, e.g using icmplib, but I need to do some test for this.

ChirpyTurnip commented 2 years ago

That would be nice.....all I can say from my end is that the net result is the same (crash) but the error messages have changed. We did turn one of the Samsung TVs on while we were still away (can do it remotely obviously) and left it running for 20 minutes before turning it off again. We thought that might 'reset' the crash clock to give us another 24 hours (from that point) but about 10 hours later the system had crashed again....so it is not a simple case of the TV needing to be one every so often....

CP.

On Mon, 10 Jan 2022 at 04:11, ollo69 @.***> wrote:

I take an additional look to this and probably you are right. I need to find a different way to manage ping, e.g using icmplib, but I need to do some test for this.

— Reply to this email directly, view it on GitHub https://github.com/ollo69/ha-samsungtv-smart/issues/121#issuecomment-1008315645, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIP7ZUXLBUNF6YDKRWK4FTUVGQRTANCNFSM5LDMWOVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ollo69 commented 2 years ago

I just released a new version (v0.4.11) that could fix this error, but I suspect that this will not solve the HA shutdown issue but just eliminate the error that is a consequence of the shutdown, because probably the ping process hangs. Anyway please let me know result installing new release.👍

ChirpyTurnip commented 2 years ago

Installed. It will be a while again before we are away from home again....but we'll just keep an eye on it....patience is the key! :p

On Wed, 12 Jan 2022 at 08:48, ollo69 @.***> wrote:

I just released a new version (v0.4.11) that could fix this error, but I suspect that this will not solve the HA shutdown issue but just eliminate the error that is a consequence of the shutdown, because probably the ping process hangs. Anyway please let me know result installing new release.👍

— Reply to this email directly, view it on GitHub https://github.com/ollo69/ha-samsungtv-smart/issues/121#issuecomment-1010306448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIP7ZWN63PGUY5QFSELSMDUVSCSTANCNFSM5LDMWOVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ChirpyTurnip commented 2 years ago

Hi,

We have just come back from being away from home for the weekend. Home assistant didn't crash when we were away... Which I think it's the first time it has run for 36+ hours in our absence....

So based on a sample size on 1 we've got definite improvements!

:-)

CP.

On Wed, 12 Jan 2022, 12:08 Bart Teekman, @.***> wrote:

Installed. It will be a while again before we are away from home again....but we'll just keep an eye on it....patience is the key! :p

On Wed, 12 Jan 2022 at 08:48, ollo69 @.***> wrote:

I just released a new version (v0.4.11) that could fix this error, but I suspect that this will not solve the HA shutdown issue but just eliminate the error that is a consequence of the shutdown, because probably the ping process hangs. Anyway please let me know result installing new release.👍

— Reply to this email directly, view it on GitHub https://github.com/ollo69/ha-samsungtv-smart/issues/121#issuecomment-1010306448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIP7ZWN63PGUY5QFSELSMDUVSCSTANCNFSM5LDMWOVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ollo69 commented 2 years ago

Any news? Can we close this issue?

ChirpyTurnip commented 2 years ago

I wish I had news...that would mean I would have had more weekends away! :-)

So far so good from my side - I say close it.....and if it comes back we will just start again from scratch.

Thanks for all your help!

On Mon, 31 Jan 2022 at 07:05, ollo69 @.***> wrote:

Any news? Can we close this issue?

— Reply to this email directly, view it on GitHub https://github.com/ollo69/ha-samsungtv-smart/issues/121#issuecomment-1025196969, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUIP7ZSWOOTGVL3OMOGLFJDUYV4WHANCNFSM5LDMWOVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

ollo69 commented 2 years ago

That's fine, I close for now. I think you can also re-open if issue comes again, or just open a new one and add a reference to this.👍