home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.16k stars 29.19k forks source link

LG WebOS source doesn't get updated in home assistant after switching to Live TV #49453

Closed andrei4002 closed 2 years ago

andrei4002 commented 3 years ago

The problem

If i switch between sources using the tv remote or hass, everthing runs fine, UNTIL i switch to Live TV, and after that, the source stops getting updated even if i switch it from hass. Turning off/on the tv doesn't seem to fix it. The only workaround i found was to restart home assistant, but after switching to live tv again, the issue appears.

I don't see any errors in the logs

My TV is an LG CX (latest firmware)

The commands to switch sources do still work, i'm only talking about querying the state of the selected source (so in the video below, when i'm changing sources, the tv is indeed changing them, but they stop updating in hass)

https://user-images.githubusercontent.com/475334/115350421-c327fa00-a1bd-11eb-9b88-2a661502b4e2.mp4

Environment

Traceback/Error logs

Additional information

probot-home-assistant[bot] commented 3 years ago

Hey there @bendavid, mind taking a look at this issue as its been labeled with an integration (webostv) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

corneyl commented 3 years ago

Are you sure you're running the latest version (2021.4)? This exact problem should be fixed in the newest version while it was present in the previous versions (<=2021.3).

andrei4002 commented 3 years ago

yes, i'm on 2021.4.6

if there's anything i can provide like logs or such, let me know

andrei4002 commented 3 years ago

just updated to 2021.5.0 - the issue is still present

dinnyosz commented 3 years ago

I am facing the same issue on version 2021.5.5. Only solution is to restart HA completely, turning on/off the TV do not help and cannot see any relevant info in HA logs.

NuijtenDev commented 3 years ago

I had the same problem when i switched my HAS container network to bridged, after switching it back to host it works without a problem.

andrei4002 commented 3 years ago

I had the same problem when i switched my HAS container network to bridged, after switching it back to host it works without a problem.

I'm also running the container in host mode (and have the issue).

I don't see how running in host/bridged mode would affect the functionality in this particular way - meaning it works all good until you switch to live tv

github-actions[bot] commented 2 years ago

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.

alsbi commented 2 years ago

ScreenShot

no next/prev button

supervisor-2021.06.8

metec22 commented 2 years ago

This issue is still occurring. Does anyone know if this is a bug in the integration or webOS?

andrei4002 commented 2 years ago

must be in the integration since it works after a hass restart (and breaks again once you reproduce the steps)

metec22 commented 2 years ago

I added the sources manually in the config file and this somehow resolved the issue for me. Not sure if it will last but so far I can no longer reproduce this issue whereas before it happened every single time I switched to Live TV.

NateEaton commented 2 years ago

Just ran across this same issue on my LG TV with Home Assistant OS, Core 2021.12.8.

heisenberg2980 commented 2 years ago

Same issue here and with the same behaviour. Home Assistant stops reporting the correct TV source for my LG TV after switching to Live TV, and the issue is fixed after restarting Home Assistant.

mlewand commented 2 years ago

It might be related to #43492 one nice folk made a branch where referenced bug is supposedly fixed. You might also give it at try.

andrei4002 commented 2 years ago

just tested this now in 2022.2.0 - unfortunately it behaves the same

kongo09 commented 2 years ago

I never had this problem - until I upgraded to 2022.2. Now the source is stuck on Live TV no matter what. I also use source selection and just migrated from the yaml to UI.

There are some errors in the log from the integration. That's also new with the upgrade to 2022.2. Maybe related:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/webostv/media_player.py:110
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 15:19:18 (4 occurrences)
Last logged: 15:23:50

[3796533816] Error calling async_select_source on entity media_player.lg_fernseher, state:on
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/webostv/media_player.py", line 107, in cmd_wrapper
    await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/webostv/media_player.py", line 408, in async_select_source
    await self._client.launch_app(source_dict["id"])
  File "/usr/local/lib/python3.9/site-packages/aiowebostv/webos_client.py", line 723, in launch_app
    return await self.request(ep.LAUNCH, {"id": app})
  File "/usr/local/lib/python3.9/site-packages/aiowebostv/webos_client.py", line 616, in request
    raise WebOsTvResponseTypeError(response)
aiowebostv.exceptions.WebOsTvResponseTypeError: {'type': 'error', 'id': 24, 'error': '500 Application error', 'payload': {'returnValue': False}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 190, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 921, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/webostv/media_player.py", line 110, in cmd_wrapper
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Error calling async_select_source on entity media_player.lg_fernseher, state:on
UserQuaark commented 2 years ago

image image

Hello together, I could solve the problem today after I had to switch to the GUI integration (my wake on lan did not work anymore after an update). The source integration did not work for me at first (via the LG integration). After looking in detail into my distribution, I found an old implementation in my customize.yaml. After deleting it everything is working fine. Please also check if you have anything in your configuration.yaml, same problem could be there.

Greetings

heisenberg2980 commented 2 years ago

@UserQuaark unfortunately after removing the integration from my configuration.yaml the issue of the entity stuck after switching to Live TV is still happening, so the issue is still there in 2022.2.0

thecode commented 2 years ago

@UserQuaark unfortunately after removing the integration from my configuration.yaml the issue of the entity stuck after switching to Live TV is still happening, so the issue is still there in 2022.2.0

When importing from YAML the configuration will stay even after you remove the YAML configuration. If you want to start with a clean configuration you can remove the device from the integration page use the "CONFIGURE" option and select different sources, this will cause the integration to reload the available sources from the TV.

I will add additional logging in future releases in order to find the root cause for this. The code is already complicated around the Live TV feature due differences and workarounds needed for it to work in different models.

thecode commented 2 years ago

Beta for core 2022.3 has started with this version I have added detailed logging to the low level communication to help identify the issue. Those who willing to help please add the following to configuration.yaml, restart home assistant, reproduce the issue and attach the log.

logger:
  default: info
  logs:
    homeassistant.components.webostv: debug
    aiowebostv: debug

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

Please try to write the time the error happens. Thanks

heisenberg2980 commented 2 years ago

@thecode I have tested it and this is the log (I have extracted the lines containing webostv, let me know if you need the full log):

2022-02-26 18:24:38 INFO (MainThread) [homeassistant.components.notify] Setting up notify.webostv
2022-02-26 18:24:38 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.webostv
2022-02-26 18:25:45 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi1","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:25:48 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:26:14 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi1","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:26:16 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:26:40 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.livetv","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:26:40 DEBUG (MainThread) [aiowebostv] send(192.168.0.200): {'id': 11, 'type': 'subscribe', 'uri': 'ssap://tv/getCurrentChannel', 'payload': {}}
2022-02-26 18:26:48 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:27:16 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi1","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:27:20 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:33:16 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi1","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:33:22 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:35:24 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi2","returnValue":true,"windowId":"","processId":""}}
2022-02-26 18:35:29 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":5,"payload":{"subscribed":true,"appId":"com.webos.app.hdmi4","returnValue":true,"windowId":"","processId":""}}
2022-02-26 19:35:29 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":4,"payload":{"returnValue":true,"state":"Active","processing":"Request Screen Saver"}}
2022-02-26 19:35:29 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":4,"payload":{"returnValue":true,"state":"Active","processing":"Screen On"}}
2022-02-26 19:35:29 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":4,"payload":{"returnValue":true,"state":"Active"}}
2022-02-26 19:36:29 DEBUG (MainThread) [aiowebostv] send(192.168.0.200): {'id': 12, 'type': 'request', 'uri': 'ssap://system.notifications/createToast', 'payload': {'message': 'Warning: Maria laptop is on', 'iconData': '', 'iconExtension': ''}}
2022-02-26 19:36:29 DEBUG (MainThread) [aiowebostv] recv(192.168.0.200): {"type":"response","id":12,"payload":{"returnValue":true,"toastId":"3VEdCetb.134-1645904189086"}}

The issue happened at 18:26:40 when I selected Live TV as source for the TV, after that, even the logs keep showing the correct source selected, the media_player entity is stuck in the last source I had selected before changing to Live TV.

EDIT: one hour after the latest change of source and while being in HDMI 4, the media_player entity has changed to Live TV. Logs updated

thecode commented 2 years ago

The issue happened at 18:26:40 when I selected Live TV as source for the TV, after that, even the logs keep showing the correct source selected, the media_player entity is stuck in the last source I had selected before changing to Live TV

@Heisenberg2980 Thanks for the test, good news is that the TV update the states after switching to Live TV so the communication is not broken (which would be harder to fix), your log is missing the initial communication with the TV, should look like this:

2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] send(192.168.1.39): hello
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] recv(192.168.1.39): {"type":"hello","payload":{"protocolVersion":1,"deviceType":"tv","deviceOS":"webOS","deviceOSVersion":"4.1.0","deviceOSReleaseVersion":"4.4.0","deviceUUID":"2f254315-afbe-12dd-3be5-71e3b1b68fe3","pairingTypes":["PIN","PROMPT","COMBINED"]}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] send(192.168.1.39): registration
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] recv(192.168.1.39): registration
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] send(192.168.1.39): {'id': 0, 'type': 'request', 'uri': 'ssap://com.webos.service.networkinput/getPointerInputSocket', 'payload': {}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] recv(192.168.1.39): {"type":"response","id":0,"payload":{"socketPath":"ws://192.168.1.39:3000/resources/c7fe6679da4a34fb5748e6477fb314696bb5afd2/netinput.pointer.sock","returnValue":true}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] send(192.168.1.39): {'id': 1, 'type': 'request', 'uri': 'ssap://system/getSystemInfo', 'payload': {}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] send(192.168.1.39): {'id': 2, 'type': 'request', 'uri': 'ssap://com.webos.service.update/getCurrentSWInformation', 'payload': {}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] recv(192.168.1.39): {"type":"response","id":1,"payload":{"returnValue":true,"features":{"3d":false,"dvr":true},"receiverType":"dvb","modelName":"55SK8500YVA","programMode":"true"}}
2022-02-12 00:14:01 DEBUG (MainThread) [aiowebostv] recv(192.168.1.39): {"type":"response","id":2,"payload":{"returnValue":true,"product_name":"webOSTV 4.0","model_name":"HE_DTV_W18H_AFADABAA","sw_type":"FIRMWARE","major_ver":"05","minor_ver":"40.09","country":"IL","country_group":"IL","device_id":"fe:23:aa:ae:1e:33","auth_flag":"N","ignore_disable":"N","eco_info":"01","config_key":"00","language_code":"he-IL"}}

Can you also check the state of the entity in the developer tools before and after switching to Live TV (if you possible include a capture like this): image

I think we are close to pinpoint this problem, with some more logging and testing it should be fixed soon :-)

heisenberg2980 commented 2 years ago

@thecode I have updated my previous comment. I will restart HA and do another test

heisenberg2980 commented 2 years ago

After restarting HA, this is a new log the from the beginning: LG.txt

I have a template sensor that is updated every time media_player source changes, this is the history ("cameras" is HDMI 1):

image

I changed the source to Live TV at 19:53:18, but the media_player source keeps showing HDMI 4, and it doesn´t change anymore regardless of how many times I change to other sources

thecode commented 2 years ago

@Heisenberg2980 can you add the output from developer tools (as described in https://github.com/home-assistant/core/issues/49453#issuecomment-1052510069) Thanks

heisenberg2980 commented 2 years ago

This is the original status before switching to Live TV:

image

This is after changing to Live TV and back to HDMI 4 (no changes in the status):

image

And this is around an hour later, after the media_player entity has changed to Live TV by itself: image

Let me know if you also want to see the status right after changing to Live TV and before going back to HDMI 4.

thecode commented 2 years ago

The interesting part is that the 3rd picture is missing HDMI4 in the source_list, I have no idea why, but it is probably part of the problem.

heisenberg2980 commented 2 years ago

@thecode that might be a different issue, because I recently changed the name of the channel to "HDMI 4", and from that moment "HDMI 4" is disappearing from the source_list every time I select another source (so basically after selecting a different source I cannot come back to HDMI 4 from HA)

Anyway let me know if you need any other testing to help pinpoint this issue.

thecode commented 2 years ago

@thecode that might be a different issue, because I recently changed the name of the channel to "HDMI 4", and from that moment "HDMI 4" is disappearing from the source_list every time I select another source (so basically after selecting a different source I cannot come back to HDMI 4 from HA)

Anyway let me know if you need any other testing to help pinpoint this issue.

I actually think it is related. Your TV doesn't have Live TV in the source list and I suspect when 2 sources are missing the state stops updating.

Can you configure sources again, make sure to change something so the configuration will be updated (go to the device page and select configure when the TV is on) and test again?

Thanks

heisenberg2980 commented 2 years ago

@thecode actually my TV have Live TV in the source list (you can see it in the 3 screenshots), but when you mentioned it I realised the HDMI 4 was not selected in the list:

image

I have selected it now as well as Roku, and and after restarting HA (to ensure a clean test) and performing new test, the same issue has happened: after changing the source to Live TV with the TV remote control, source is stuck in the last source selected before changing to Live TV, which is HDMI 4 in this case:

image

heisenberg2980 commented 2 years ago

@thecode do you have any update about this issue? please let me know if you need any other test, happy to help and find the root cause of this annoying issue

thecode commented 2 years ago

@thecode do you have any update about this issue? please let me know if you need any other test, happy to help and find the root cause of this annoying issue

I was hopping that with the release of core 2022.3 out of beta some more users will jump in and with additional logs maybe I have better understanding for the root cause, anyhow I was thinking adding detailed logging on the integration side and publishing it on my repo to be used as a custom component (to prevent need to wait for HA releases and to allow adding extra logging which can't be permanent on a released code).

If you are willing to test it as a custom integration let me know, your current configuration will not be changed and once you remove the custom component the core integration will work as before.

I am also available on discord which will be much easier to have faster feedback and response so hopefully this can be resolved. Thanks for helping.

metec22 commented 2 years ago

I’m willing to test as well via custom integration as I cannot update right now due to breaking changes. 

On Wednesday, March 9, 2022, 4:33 PM, Shay Levy @.***> wrote:

@thecode do you have any update about this issue? please let me know if you need any other test, happy to help and find the root cause of this annoying issue

I was hopping that with the release of core 2022.3 out of beta some more users will jump in and with additional logs maybe I have better understanding for the root cause, anyhow I was thinking adding detailed logging on the integration side and publishing it on my repo to be used as a custom component (to prevent need to wait for HA releases and to allow adding extra logging which can't be permanent on a released code).

If you are willing to test it as a custom integration let me know, your current configuration will not be changed and once you remove the custom component the core integration will work as before.

I am also available on discord which will be much easier to have faster feedback and response so hopefully this can be resolved. Thanks for helping.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.Message ID: @.***>

heisenberg2980 commented 2 years ago

@thecode yes I am happy to install your version as a custom component, just share your repo once you have added the additional logging and I will test it

thecode commented 2 years ago

This version has detailed logging to be used as a custom component: https://github.com/thecode/home-assistant-custom-components/tree/webostv-debug

Add this to home assistant config folder, enable logging by adding the following to configuration.yaml:

logger:
  default: info
  logs:
    custom_components.webostv: debug
    aiowebostv: debug

Reproduce the problem and attach the log.

Notes:

Thanks

heisenberg2980 commented 2 years ago

@thecode I can´t open that repo, can you add me as collaborator or make it public?

thecode commented 2 years ago

@thecode I can´t open that repo, can you add me as collaborator or make it public?

Sorry, forgot to make it public, changed now

heisenberg2980 commented 2 years ago

Tested with the custom integration. After changing the source to Live TV at 10:43:04, the entity is stuck on "Cameras" (HDMI1), this is the log: Webostv.txt

thecode commented 2 years ago

Tested with the custom integration. After changing the source to Live TV at 10:43:04, the entity is stuck on "Cameras" (HDMI1), this is the log: Webostv.txt

The log is missing the data from the media player component, did you add custom_components.webostv: debug to the loggers?

heisenberg2980 commented 2 years ago

You are right, I still had homeassistant.components.webostv: debug. New log sent in discord

ghost commented 2 years ago

I'm still experiencing this issue on the following system; Home Assistant 2022.4.0 Operating System Version 5.10.103-v8 Host Operating System Home Assistant OS 7.6

Anything I can do to help contribute to logging this? It's a minor inconvenience, I guess I could just change to my Live TV input by using a Broadlink adapters and some IR commands, but I'd rather avoid that where possible.

heisenberg2980 commented 2 years ago

@lucifudge this issue should be fixed in 2022.4.0, what exactly are you experiencing? Is your HA entity stuck after you switch to Live TV?

EDIT: I just updated my HA to 2022.4.0 and it is working as expected, with the TV entity changing to Live TV and then changing back to the correct source without any issue.