Closed VenominousX closed 1 year ago
Hey there @chemelli74, @epenet, mind taking a look at this issue as it has been labeled with an integration (samsungtv
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
samsungtv documentation samsungtv source (message by IssueLinks)
Hey @VenominousX, could you share your logbook data for the full time range (before restart until the power on event)?
Hey @holysoles , here it is:
before restart
turn off TV
after restart
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1076, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1060, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 969, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 501, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('10.11.12.101', 9197)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/async_upnp_client/aiohttp.py", line 170, in async_http_request return await self._async_http_request(method, url, headers, body) File "/usr/local/lib/python3.10/site-packages/async_upnp_client/aiohttp.py", line 204, in _async_http_request async with self._session.request( File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection raise last_exc File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.11.12.101:9197 ssl:default [Connect call failed ('10.11.12.101', 9197)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/samsungtv/media_player.py", line 287, in _async_startup_dmr upnp_device = await upnp_factory.async_create_device( File "/usr/local/lib/python3.10/site-packages/async_upnp_client/client_factory.py", line 72, in async_create_device root_el = await self._async_get(description_url) File "/usr/local/lib/python3.10/site-packages/async_upnp_client/client_factory.py", line 394, in _async_get ) = await self.requester.async_http_request("GET", url) File "/usr/local/lib/python3.10/site-packages/async_upnp_client/aiohttp.py", line 172, in async_http_request raise UpnpConnectionError(repr(err)) from err async_upnp_client.exceptions.UpnpConnectionError: ('ClientConnectorError(ConnectionKey(host=\'10.11.12.101\', port=9197, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=-8223295724473837405), ConnectionRefusedError(111, "Connect call failed (\'10.11.12.101\', 9197)"))', None)
I think this was introduced with PR #67541
HA polls for the device power status using SamsungTVWSBridge.async_is_on()
. However on startup, when we test the contents of self._device_info
here, it isn't defined yet since the device hasn't been polled yet.
As a result we fall back to usingSamsungTVWSBaseBridge.async_is_on()
to get the device power state, but as noted here, using a websocket connection to a powered off TV can cause it to be powered on. This explains why in your logs the integration is trying to connect via websocket, then eventually starts connecting via device info later since self.device_info
becomes defined.
We should implement the same init check done here, I'll get a PR opened up.
That sounds comprehensible. Thank you @holysoles for your effort and support.
Watching this... I think this might be the reason why my samsung TV keeps flagging as being truned on, yet isnt actually on.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
Hello, my Samsung TV turns on after restarting Home Assistant. I have been able to reproduce this behavior several times. The integration sets the status to ON even if the TV was turned off before the restart and the integration set the status to OFF. This happens both when using sqlite or MariaDB.
I don't have any automations or scripts that turn on my TV after reboot.
I restart my Home Asisstant instances very early every morning, as it provides the best reliability throughout the day after a few months of testing. A TV that then turns on without a specific request is no good. Since intentionally turning on the TV triggers a number of other automations, logically those are then triggered when Home Assistant is restarted. Besides wasting energy, it is also not nice for visitors to be woken up by the sudden switch-on.
Best regards Marcus
What version of Home Assistant Core has the issue?
2023.4.6, same on 2023.5.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Samsung Smart TV
Link to integration documentation on our website
https://www.home-assistant.io/integrations/samsungtv
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response