Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samsung tv remote fails on timeout from ON to OFF #28842

Closed
fermulator opened this issue Nov 18, 2019 · 3 comments · Fixed by #28849
Closed

samsung tv remote fails on timeout from ON to OFF #28842

fermulator opened this issue Nov 18, 2019 · 3 comments · Fixed by #28849

Comments

@fermulator
Copy link

fermulator commented Nov 18, 2019

Home Assistant release with the issue:
0.98

Last working Home Assistant release (if known):
unknown

Operating environment (Hass.io/Docker/Windows/etc.):
virtual env, python3, linux

Integration:
https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/samsungtv

Description of problem:

Tonight I turned off the samsungtv, shortly after, it caused a crash in the system

LOGS:

Nov 17 21:15:17 hass hass[2044]: 2019-11-17 21:15:17 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.samsung_tv_remote fails
Nov 17 21:15:17 hass hass[2044]: Traceback (most recent call last):
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_socket.py", line 81, in recv
Nov 17 21:15:17 hass hass[2044]:     bytes_ = sock.recv(bufsize)
Nov 17 21:15:17 hass hass[2044]: socket.timeout: timed out
Nov 17 21:15:17 hass hass[2044]: During handling of the above exception, another exception occurred:
Nov 17 21:15:17 hass hass[2044]: Traceback (most recent call last):
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
...
(snip) - so full traceback below
...
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_socket.py", line 84, in recv
Nov 17 21:15:17 hass hass[2044]:     raise WebSocketTimeoutException(message)
Nov 17 21:15:17 hass hass[2044]: websocket._exceptions.WebSocketTimeoutException: timed out
Nov 17 21:15:27 hass hass[2044]: 2019-11-17 21:15:27 INFO (SyncWorker_4) [root] Sending control command: KEY

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

media_player:
  - platform: samsungtv
    host: 192.168.0.xx
    port: 8001

Traceback (if applicable):

Nov 17 21:15:17 hass hass[2044]: Traceback (most recent call last):
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
Nov 17 21:15:17 hass hass[2044]:     await self.async_device_update()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 441, in async_device_update
Nov 17 21:15:17 hass hass[2044]:     await self.hass.async_add_executor_job(self.update)
Nov 17 21:15:17 hass hass[2044]:   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Nov 17 21:15:17 hass hass[2044]:     result = self.fn(*self.args, **self.kwargs)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/samsungtv/media_player.py", line 151, in update
Nov 17 21:15:17 hass hass[2044]:     self.send_key("KEY")
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/samsungtv/media_player.py", line 171, in send_key
Nov 17 21:15:17 hass hass[2044]:     self.get_remote().control(key)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/samsungtv/media_player.py", line 157, in get_remote
Nov 17 21:15:17 hass hass[2044]:     self._remote = self._remote_class(self._config)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/samsungctl/remote.py", line 11, in __init__
Nov 17 21:15:17 hass hass[2044]:     self.remote = RemoteWebsocket(config)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/samsungctl/remote_websocket.py", line 30, in __init__
Nov 17 21:15:17 hass hass[2044]:     self._read_response()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/samsungctl/remote_websocket.py", line 67, in _read_response
Nov 17 21:15:17 hass hass[2044]:     response = self.connection.recv()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_core.py", line 310, in recv
Nov 17 21:15:17 hass hass[2044]:     opcode, data = self.recv_data()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_core.py", line 327, in recv_data
Nov 17 21:15:17 hass hass[2044]:     opcode, frame = self.recv_data_frame(control_frame)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_core.py", line 340, in recv_data_frame
Nov 17 21:15:17 hass hass[2044]:     frame = self.recv_frame()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_core.py", line 374, in recv_frame
Nov 17 21:15:17 hass hass[2044]:     return self.frame_buffer.recv_frame()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_abnf.py", line 361, in recv_frame
Nov 17 21:15:17 hass hass[2044]:     self.recv_header()
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_abnf.py", line 309, in recv_header
Nov 17 21:15:17 hass hass[2044]:     header = self.recv_strict(2)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_abnf.py", line 396, in recv_strict
Nov 17 21:15:17 hass hass[2044]:     bytes_ = self.recv(min(16384, shortage))
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_core.py", line 449, in _recv
Nov 17 21:15:17 hass hass[2044]:     return recv(self.sock, bufsize)
Nov 17 21:15:17 hass hass[2044]:   File "/srv/homeassistant/lib/python3.6/site-packages/websocket/_socket.py", line 84, in recv
Nov 17 21:15:17 hass hass[2044]:     raise WebSocketTimeoutException(message)
Nov 17 21:15:17 hass hass[2044]: websocket._exceptions.WebSocketTimeoutException: timed out

Additional information:
(back-ref as related possibly see #28831)

@probot-home-assistant
Copy link

Hey there @escoand, mind taking a look at this issue as its been labeled with a integration (samsungtv) you are listed as a codeowner for? Thanks!

@escoand
Copy link
Contributor

escoand commented Nov 18, 2019

@fermulator Could you please test my PR above?

@fermulator
Copy link
Author

Hey @escoand , I did a review of the PR (lgtm!), and patched my local instance. However note that testing/reproduction locally is going to be slow to verdict. I've been running this for over a year and this was the first time I noticed it. Must be getting that exception w/ precise timing/conditions on the websocket timeout.

As we can see, historically it has only happened about ~10x times this year:

fermulator@hass:~$ sudo journalctl --since 2019-01-01 -u home-assistant@homeassistant   | grep WebSocketTimeoutException
Jun 27 13:04:41 hass hass[16115]:     raise WebSocketTimeoutException(message)
Jun 27 13:04:41 hass hass[16115]: websocket._exceptions.WebSocketTimeoutException: timed out
Jul 12 17:00:11 hass hass[28616]:     raise WebSocketTimeoutException(message)
Jul 12 17:00:11 hass hass[28616]: websocket._exceptions.WebSocketTimeoutException: timed out
Jul 13 19:10:50 hass hass[12613]:     raise WebSocketTimeoutException(message)
Jul 13 19:10:50 hass hass[12613]: websocket._exceptions.WebSocketTimeoutException: timed out
Aug 06 16:09:26 hass hass[15884]:     raise WebSocketTimeoutException(message)
Aug 06 16:09:26 hass hass[15884]: websocket._exceptions.WebSocketTimeoutException: timed out
Aug 08 19:46:27 hass hass[15884]:     raise WebSocketTimeoutException(message)
Aug 08 19:46:27 hass hass[15884]: websocket._exceptions.WebSocketTimeoutException: timed out
Aug 08 22:42:49 hass hass[15884]:     raise WebSocketTimeoutException(message)
Aug 08 22:42:49 hass hass[15884]: websocket._exceptions.WebSocketTimeoutException: timed out
Aug 12 13:46:50 hass hass[15884]:     raise WebSocketTimeoutException(message)
Aug 12 13:46:50 hass hass[15884]: websocket._exceptions.WebSocketTimeoutException: timed out
Aug 15 14:29:36 hass hass[15884]:     raise WebSocketTimeoutException(message)
Aug 15 14:29:36 hass hass[15884]: websocket._exceptions.WebSocketTimeoutException: timed out
Sep 12 18:28:21 hass hass[1084]:     raise WebSocketTimeoutException(message)
Sep 12 18:28:21 hass hass[1084]: websocket._exceptions.WebSocketTimeoutException: timed out
Sep 19 19:02:42 hass hass[1084]:     raise WebSocketTimeoutException(message)
Sep 19 19:02:42 hass hass[1084]: websocket._exceptions.WebSocketTimeoutException: timed out

(and, to be clear, we use our TV & turn it off much more frequently than that ;o)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants