core: Samsung TV integration fails intermittently on 2021.6
The problem
I ran into some errors with the Samsung integration after updating to 2021.6. The screen is a Series 7 Plasma, circa 2010. Surprisingly the integration had been very reliable until the 2021.6 update, but now it seems to “drop out” and go unavailable with some errors. In my testing below, I’ve only obtained logs for this occurring upon a reboot, but it has happened out of the blue a few times too. The results of some initial testing are below, please let me know if there’s anything else I could try.
What is version of Home Assistant Core has the issue?
core-2021.6.0
What was the last working version of Home Assistant Core?
core-2021.5.?
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Samsung TV
Link to integration documentation on our website
https://www.home-assistant.io/integrations/samsungtv/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2021-06-04 11:10:02 ERROR (MainThread) [homeassistant.components.media_player] samsungtv: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 550, in async_device_update
await task
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/samsungtv/media_player.py", line 116, in update
self._state = STATE_ON if self._bridge.is_on() else STATE_OFF
File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 75, in is_on
return self._get_remote() is not None
File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 188, in _get_remote
self._remote = Remote(self.config.copy())
File "/usr/local/lib/python3.8/site-packages/samsungctl/remote.py", line 9, in __init__
self.remote = RemoteLegacy(config)
File "/usr/local/lib/python3.8/site-packages/samsungctl/remote_legacy.py", line 22, in __init__
self.connection.connect((config["host"], config["port"]))
TypeError: str, bytes or bytearray expected, not NoneType
Additional information
Test 1:
- Delete Samsung integration from WebUI
- Restart Home Assistant (docker) * Samsung is auto-discovered
- Configure auto-discovered integration
2021-06-04 10:50:18 DEBUG (SyncWorker_16) [homeassistant.components.samsungtv] Try config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.0.17', 'method': 'legacy', 'port': None, 'timeout': 31}
2021-06-04 10:50:18 DEBUG (SyncWorker_16) [homeassistant.components.samsungtv] Working config: {'name': 'HomeAssistant', 'description': 'HomeAssistant', 'id': 'ha.component.samsung', 'host': '192.168.0.17', 'method': 'legacy', 'port': None, 'timeout': 31}
2021-06-04 10:50:18 DEBUG (SyncWorker_26) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 10:50:28 DEBUG (SyncWorker_7) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 10:50:38 DEBUG (SyncWorker_16) [homeassistant.components.samsungtv] Create SamsungRemote
The final Create SamsungRemote
is seen to repeat every 10s indefinitely. Turning the TV on or off seems to cause the next instance to not appear, but then the 10s interval resumes regardless of whether the TV is on or off.
Test 2
10 minutes passed without dropout. Trying more tests to attempt to replicate.
- Restarting via HomeAssistant WebUI
- Issue replicated immediately upon startup
No other logs from the Samsung appeared from the restart. Despite the handful of INFO logs before the error, the entity didn’t leave the unavailable
state at any point following the restart:
2021-06-04 11:09:20 DEBUG (SyncWorker_14) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 11:09:35 DEBUG (SyncWorker_24) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 11:09:44 DEBUG (SyncWorker_18) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 11:09:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2021-06-04 11:09:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2021-06-04 11:09:56 DEBUG (SyncWorker_6) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 11:10:02 DEBUG (MainThread) [homeassistant.components.samsungtv] Stopping SamsungRemote
2021-06-04 11:10:02 DEBUG (SyncWorker_5) [homeassistant.components.samsungtv] Create SamsungRemote
2021-06-04 11:10:02 ERROR (MainThread) [homeassistant.components.media_player] samsungtv: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 550, in async_device_update
await task
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/samsungtv/media_player.py", line 116, in update
self._state = STATE_ON if self._bridge.is_on() else STATE_OFF
File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 75, in is_on
return self._get_remote() is not None
File "/usr/src/homeassistant/homeassistant/components/samsungtv/bridge.py", line 188, in _get_remote
self._remote = Remote(self.config.copy())
File "/usr/local/lib/python3.8/site-packages/samsungctl/remote.py", line 9, in __init__
self.remote = RemoteLegacy(config)
File "/usr/local/lib/python3.8/site-packages/samsungctl/remote_legacy.py", line 22, in __init__
self.connection.connect((config["host"], config["port"]))
TypeError: str, bytes or bytearray expected, not NoneType
Test 3
- Repeated Test 1 to restore entity.
- Restarting again, similar to Test 2, but via Docker instead of Home Assistant WebUI.
media_player.samsung_dtv_rcr
continues to work as expected, Create SamsungRemote
logs continue to repeat every 10s.
2021-06-04 11:23:07 DEBUG (SyncWorker_0) [homeassistant.components.samsungtv] Create SamsungRemote
Test 4
- Restarting again, via Home Assistant WebUI this time
media_player.samsung_dtv_rcr
does not leave unavailable
state, Create SamsungRemote
logs continue to repeat every 10s. Despite entity not working, no errors appear in log.
Test 5
- Restarting via Docker
Same as Test 4, media_player.samsung_dtv_rcr
does not leave unavailable
state, Create SamsungRemote
logs continue to repeat every 10s. Despite entity not working, no errors appear in log.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 23 (8 by maintainers)
@chemelli74 Then I may not have the same issue, I can’t reproduce the error posted here but I do regularly get integration requires reconfigures notifications. then I need to debug that behavior more and create a separate issue if applicable.
Hi @boardwarp, @ktvanzwol, the repeating debug log line
2021-06-04 11:23:07 DEBUG (SyncWorker_0) [homeassistant.components.samsungtv] Create SamsungRemote
is expected. Current library does a connect->close connection at every scheduled refresh interval ( 10s ).The real issue is the trace error that we need to track down.