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
71.11k stars 29.79k forks source link

LG webOS TV automations need reloading #65771

Closed Efekent closed 1 year ago

Efekent commented 2 years ago

The problem

Since core-2022.2.1 LG webOS Smart TV is available from the UI, and power on is possible through a automation like explained here: https://github.com/home-assistant/core/issues/65461#issuecomment-1028456127

After updating to core-2022.2.1 I removed the integration from the configuration.yaml since it was automatically added, and I used the automation mentioned above, this made the power on button available again while the TV was turned off.

But after a while the power button disappears when the TV is turned off, only way to get the power button back is, by reloading the automations. It looks like when the TV is turned off there is an error with header: Error unloading entry see below for more log information.

I think disappearing power button has to do with this error.

What version of Home Assistant Core has the issue?

core-2022.2.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

LG webOS Smart TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/webostv/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-02-05 08:11:43 ERROR (MainThread) [homeassistant.config_entries] 
 Error unloading entry Woonkamer TV LG for media_player Traceback (most recent call last): 
 File "/usr/src/homeassistant/homeassistant/config_entries.py", line 466, in async_unload result = await component.async_unload_entry(hass, self) 
 File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 383, in async_unload_entry return await component.async_unload_entry(entry) 
 File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry raise ValueError("Config entry was never loaded!") 
ValueError: Config entry was never loaded!

Additional information

No response

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

webostv documentation webostv source (message by IssueLinks)

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

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

thecode commented 2 years ago

Does the error above occur before reloading the automations or after?

Efekent commented 2 years ago

It happens before, when I don't see the power button I check the logs and I see the error, after reloading automations button comes back.

btw this is a minor problem for me, I am not in hurry, it was just to report the bug. Thanks for your time.

RadekLorenc commented 2 years ago

Same here - can't turn on TV remotely via wake on lan service or turn it off (before update to 2022.2.2 everything works fine)

tomsruk commented 2 years ago

Since updating to 2022.2.2 I can no longer turn on my TV via HA iOS app. It just shows as unavailable and the controls disappear. I can turn it off fine.

thecode commented 2 years ago

@RadekLorenc @tomsruk this issue is for a specific problem when the TV is configured correctly but the button disappear after some time with an error and reloading automations bring it back. If you don't have a turn on option at all please follow the instructions at https://github.com/home-assistant/core/issues/65461#issuecomment-1028456127 or use the blueprint from https://community.home-assistant.io/t/lg-webos-smart-tv-enable-turn-on-action-for-ha-2022-2/388153

thecode commented 2 years ago

@Efekent did you use the UI method or added a trigger via YAML? can you share the automation? (if it is via the UI it will be in automations.yaml)

Efekent commented 2 years ago

@thecode I have used the UI method, here is the YAML:

- id: '1643854662787'
  alias: LG TV on
  description: ''
  trigger:
  - platform: device
    device_id: 123748efa27cea917a0124162b42df21
    domain: webostv
    type: webostv.turn_on
  condition: []
  action:
  - service: wake_on_lan.send_magic_packet
    data:
      mac: 12-34-5C-5A-FG-5D
  mode: single

EDIT: The Error occurs after turning the TV on multiple times, TV was turned on @ 18:30 and till now 22:45 it happened 34 times:

Here a copy from logbook:

Logger: homeassistant.config_entries
Source: helpers/entity_component.py:172
First occurred: 18:30:51 (34 occurrences)
Last logged: 22:43:23

Error unloading entry Woonkamer TV LG for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 466, in async_unload
    result = await component.async_unload_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 383, in async_unload_entry
    return await component.async_unload_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
thecode commented 2 years ago

I think I have a clue, can you add the following to configuration.yaml, restart home assistant, wait until you see this error and attach the log.

logger:
  default: info
  logs:
    homeassistant.components.webostv: 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.

Thanks

Efekent commented 2 years ago

I am not sure if you want the entire log, but it happens at 2022-02-06 00:27:24 mark. log_6_feb_2022.txt

Thanks again.

Normally I have logger default on waning, putting on info made me realize how big the logs become :)

thecode commented 2 years ago

Thanks, Can you repeat the test but let it run so that there is more than 1 error (3-4) it looks suspicious that the error is very close to samsungtv and dlna_dmr You can also try to temporally disable these devices (from the device card select edit and disable device) and enable them back after some testing.

Efekent commented 2 years ago

I just started from scratch with webOS, to be sure I deleted the webOS integration since it was added automatically through the core-2022.2.1 update. I also deleted the automations and Node-Red flows regarding the TV (couple notifications and turning on kitchen TV if the TV was on HDMI1 and motion was detected in kitchen, couple lights gets turned off and some turned on between certain times)

So everything related to our LG TV was removed from HA, after restarting HA the TV got recognized as new device, I added the integration and make sure TV had a new entity-id.

I think it is my English, I didn't understand what devices you want me to disable? I don't have Samsung TV's or DLNA integration added as integration (we do have 2 Samsung TV's and a Philips TV but non of these are in HA) Other devices are 9 Google (NEST) Hub/Home and Chromecasts, the other non media devices are Zigbee devices (101 pieces), 2 (local)Tuya wifi devices, 2 Octoprint instances, a Surepet cat flap, Xiaomi robot vacuum, a NUT

Maybe I should report this before, the HA OS is running on a NUC (dedicated only for HA)

Anyways after starting from scratch the problem is still there, the Power button disappears after the errors and comes back after reloading the automations.

Problem occurs 6 times in the logs now, changed the mac adres and some other information in the logs for privacy reasons: log_6_feb_2022_01.txt

thecode commented 2 years ago

Can you check automations for if you have a call to a service homeassistant.reload_config_entry?

Efekent commented 2 years ago

I just checked the automations.yaml and the Node-Red flows there was not a call service for homeassistant.reload_config_entry anywhere.

After posting the last log file above, the error occurred 17 times more till this morning in couple hours, TV was turned off with its own remote and the power button was gone again, after reloading the automations the errors stopped occurring and the power button is back, this will stay like this till the TV is turned on and turned back off. It looks like something is happening when the TV is turned off, doesn't matter if it happens through HA or with its own remote controller.

The weird thing is. it looks like I am the only one with this problem since no one else reporting same issue, I don't wanna take your time if it is only me, I can live with it and try to figure out what is going wrong.

What I didn't check was to remove the power from the TV for couple minutes and power back on, I am not sure if it makes a difference since the error ValueError: Config entry was never loaded! looks like HA related, but you never know. Problem with taking the power off is that everything is tugged away, but luckily the TV is on a Zigbee socket, together with a network switch going to another network switch so I will loose my network and camera's partially but at least I can make sure problem is not coming through the TV itself. I will do this later today when I have more time in my hands

thecode commented 2 years ago

I don't think the issue is related to your specific TV. it is either a bug for something I don't understand and it might be that something will make it happen for others in the future also or it is something with your setup/automations/other integrations.

I don't think an issue should be prioritized by it's occurrences, I do however put issues with missing information or lake of cooperation at low priority which is not the case here.

If you have a spare PI (or just a clean SD card if your setup is on PI) you can try to start with a clean setup to see if it happens with it too. I will add additional logging in future releases to try to improve debugging of such issues.

Thanks for your cooperation.

Efekent commented 2 years ago

I had to do something outside but it is pouring rain at the moment, thus I could go further with investigation, I power cycled the TV, it was 10 minutes powerless, after that restarted HA. Tested couple times the error is still there but weird enough only when the TV is turned ON the error occurs and after turning off I don't get errors anymore, but I still loose the power button while it is turned off, till automations reload. I don't know why only happens once now, I didn't change anything than power cycling the TV.

If you have a spare PI (or just a clean SD card if your setup is on PI) you can try to start with a clean setup to see if it happens with it too. I will add additional logging in future releases to try to improve debugging of such issues.

Thanks for your cooperation.

I like to thank you for your time too, unfortunately I don't have a spare PI and I am running HA on a Intel NUC with M.2 SSD, fresh install is hard to do, I install the HA OS by taking out the M.2 SSD and putting in a enclosure for a M.2 and flash the image with balenaEtcher, the other issue is I am running my multi zone heating for several floors in the house through HA and Node-Red automations regulating valves between the floors and the generic thermostats are created in HA, it is unfortunately too cold outside to stop heating for testing and put back everything back.

This is the Intel NUC I am using. ha_intel_nuc https://ark.intel.com/content/www/us/en/ark/products/83256/intel-nuc-kit-nuc5i3ryk.html

On top of that my wife will kill me if everything stops working 😄, basically whole house runs on HA through Zigbee: my_zigbee_int

I am truly sorry I couldn't help you with a fresh install 😞

thecode commented 2 years ago

I had an offline discussion and we think we have a good understanding why you need to reload the automations. It still doesn't explain why you have many unloading/reloading of the webOS TV device and I still think one of the integrations or addons is causing that, but it does explain why you need to reload the automations after. When fixed you won't need to reload the automations but the error in the log will stay.

I suggest to try to disable automations, custom integrations to try to eliminate the root cause. For automations you can just rename the automations.yaml file and put an empty file with [] instead. For node-red you can just disable the addon from running, same for other addons. It sounds complicated but I guess within 2 hours you will find the root cause.

Tigger2014 commented 2 years ago

I seem to be facing the same issue, It works for a few mins and then the device goes offline again

2022-02-06 13:08:37 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 203, in async_init flow, result = await task File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 230, in _async_init result = await self._async_handle_step(flow, flow.init_step, data, init_done) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/webostv/config_flow.py", line 148, in async_step_ssdp self._name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME] KeyError: 'friendlyName' 2022-02-06 13:08:37 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 203, in async_init flow, result = await task File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 230, in _async_init result = await self._async_handle_step(flow, flow.init_step, data, init_done) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/usr/src/homeassistant/homeassistant/components/webostv/config_flow.py", line 148, in async_step_ssdp self._name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME] KeyError: 'friendlyName' 2022-02-06 13:09:09 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry LG Living Room TV for media_player Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 466, in async_unload result = await component.async_unload_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 383, in async_unload_entry return await component.async_unload_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry raise ValueError("Config entry was never loaded!") ValueError: Config entry was never loaded! 2022-02-06 13:09:11 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.webostv 2022-02-06 13:09:11 INFO (MainThread) [homeassistant.components.notify] Setting up notify.webostv

tomsruk commented 2 years ago

I've fixed mine by adding this Blueprint https://community.home-assistant.io/t/lg-webos-smart-tv-enable-turn-on-action-for-ha-2022-2/388153

It wasn't obvious in the documentation, at least to me, that the breaking changes would include WakeOnLan too.

Tigger2014 commented 2 years ago

@tomsruk Im not sure thats the same issue from my understand of this thread (and the issue i have) the issue is once the device is powered on it shows online and you are able to control it but after a small period of time it dies and shows offline again

Efekent commented 2 years ago

I had an offline discussion and we think we have a good understanding why you need to reload the automations. It still doesn't explain why you have many unloading/reloading of the webOS TV device and I still think one of the integrations or addons is causing that, but it does explain why you need to reload the automations after. When fixed you won't need to reload the automations but the error in the log will stay.

I suggest to try to disable automations, custom integrations to try to eliminate the root cause. For automations you can just rename the automations.yaml file and put an empty file with [] instead. For node-red you can just disable the addon from running, same for other addons. It sounds complicated but I guess within 2 hours you will find the root cause.

Thanks for your time and explanation @thecode I will try to check with the automations and Node-Red when I have time in couple days. Weird thing is the error occurs only once now after powering off. I was using the integration through YAML version till core-2022.2.1 and didn't had this issue, I didn't add any automations, Node-Red flows and integrations after the update except the power button WOL automation for the TV. But it does not hurt to check of course. I am looking forward to the not reloading automations fix, but like I said I am not in hurry.

@Tigger2014 my TV does not go offline, only the power button disappears when the TV is turned off. TV stays constantly online, while watching TV or if its off.

Tigger2014 commented 2 years ago

hmm @Efekent very different issues then, I also have power button disappear when the tv is off, but i seem to have the device going offline too, I wonder if its the same root cause?

Scrap my issue, was a network issue :)

TGroene commented 2 years ago

Hi Guys,

Same issue here. In the yaml config you had the option to sent magic packet to the TV. Perhaps it's something to do with that?

Thanks for checking!

thecode commented 2 years ago

Hi Guys,

Same issue here. In the yaml config you had the option to sent magic packet to the TV. Perhaps it's something to do with that?

Thanks for checking!

Read the breaking changes, not related to this issue, If you don't have a turn on option at all please follow the instructions at https://github.com/home-assistant/core/issues/65461#issuecomment-1028456127 or use the blueprint from https://community.home-assistant.io/t/lg-webos-smart-tv-enable-turn-on-action-for-ha-2022-2/388153

Ndrinta commented 2 years ago

Sorry @thecode, but this is clearly a downgrade, no matter how many times you mention that it was stated in the breaking changes section. I think I'm talking for most of us here, we simply want it back. It was really easy to set up in YAML, it can't be difficult to include it in the new integration. The workaround of turning it ON with an automation is a workaround indeed. No one wants to do that and no one has plan to stick with it, the ideal solution is and always will be the button straight inside the multimedia card. Personally, I'm not even setting up automation, and for what? To have a dedicated button just to turn ON my TV, alone in the dashboard? A conditional card that shows the button if the TV is OFF and the multimedia card if the TV is ON?

Is in the roadmap to bring it back or it's simply gone until someone branches it into HACS for yet another clone custom integration?

Cheers

thecode commented 2 years ago

Sorry @thecode, but this is clearly a downgrade, no matter how many times you mention that it was stated in the breaking changes section. I think I'm talking for most of us here, we simply want it back. It was really easy to set up in YAML, it can't be difficult to include it in the new integration. The workaround of turning it ON with an automation is a workaround indeed. No one wants to do that and no one has plan to stick with it, the ideal solution is and always will be the button straight inside the multimedia card. Personally, I'm not even setting up automation, and for what? To have a dedicated button just to turn ON my TV, alone in the dashboard? A conditional card that shows the button if the TV is OFF and the multimedia card if the TV is ON?

Is in the roadmap to bring it back or it's simply gone until someone branches it into HACS for yet another clone custom integration?

Cheers

No it just means you did not read or did not understand what you read, when you setup the automation (via UI or YAML) you get the button back straight in the multimedia card exactly as it was before, there was zero functionally removed from the integration. After you follow the procedure I linked if you did not get the multimedia card look exactly as it was before please create a new issue, locking this issue for now as the op does not need to get notifications for unrelated comments.

thecode commented 2 years ago

I have renamed the issue so that issues with missing power button will not land here. We had a discussion and currently think how to handle it within the core, so that if an integration is reloaded the automations related to it will also get reloaded.

elkarto commented 2 years ago

Same issue here.

Power on works fine for a while, but then I have the "error unloading entry" and it don't work any more.

Just thinking, could it be related to the deprecated yaml configuration? I've already deleted that part of config, but perhaps it is expecting it (because it was there before) and that's the thing it isn't able to unload.

thecode commented 2 years ago

Same issue here.

Power on works fine for a while, but then I have the "error unloading entry" and it don't work any more.

Just thinking, could it be related to the deprecated yaml configuration? I've already deleted that part of config, but perhaps it is expecting it (because it was there before) and that's the thing it isn't able to unload.

Should not be related, anyhow your entity is already migrated to the UI (you can probably see the device card in the integrations page) you can remove the YAML or just comment it if you want to keep it.

The behavior of the button disappearing after the Error unloading entry is a bug and clear to me why it happen. However it is still not clear why something try to unload the webostv entry.

It would be good to try to narrow down what is causing it, removing the YAML is a good first step, next steps would be disable other integrations or automations and try to pin out what is unloading the entry.

Thanks for helping with this.

TomF79 commented 2 years ago

Hi, I have following problem.

The Integration must be often reloaded to show the correct Information from the running TV. When i doesnt reload it the Card shows a deactivated TV and he is grey and had no ON Button. It only works when I switch the TV on with the Remote Control and after that reload the Integration.

craigmcewen commented 2 years ago

Hi, I am still tinkering away trying to figure what is causing this weird behaviour... I did just realise though that at the exact time the error is being logged the TV drops off and on; (from Logbook - 2 tdifferent times that match my first log and last log from the error:

Craigs TV turned on 1:25:35 AM - 1 hour ago Craigs TV became unavailable 1:25:35 AM - 1 hour ago Craigs TV turned on 1:25:35 AM - 1 hour ago Craigs TV became unavailable 1:25:34 AM - 1 hour ago

The last time: Craigs TV turned on 2:23:08 AM - 9 minutes ago Craigs TV became unavailable 2:23:08 AM - 9 minutes ago Craigs TV turned on 2:23:08 AM - 9 minutes ago Craigs TV became unavailable 2:23:07 AM - 9 minutes ago

Matching to the error log:

Logger: homeassistant.config_entries Source: helpers/entity_component.py:172 First occurred: 1:25:34 AM (7 occurrences) Last logged: 2:23:08 AM

Error unloading entry Craigs TV for media_player Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 466, in async_unload result = await component.async_unload_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 383, in async_unload_entry return await component.async_unload_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry raise ValueError("Config entry was never loaded!") ValueError: Config entry was never loaded!

Siince you pointed me over here I have deleted the office TV and room tv and deleted all scripts and automations that had LG in them, the office tv not an issue but the room tv is now causing the issue.

I think its very interesting that the TV is unavail to on a few times at the same time the error is logged, then the tv is good to go as normal until it does it again next, it also appears that the error occurance quantity is also directly related to the unavail/avail, change registered by the tv

craigmcewen commented 2 years ago

For consistency: Craigs TV turned on 2:37:59 AM - 2 minutes ago Craigs TV became unavailable 2:37:59 AM - 2 minutes ago Craigs TV turned on 2:37:59 AM - 2 minutes ago Craigs TV became unavailable 2:37:58 AM - 2 minutes ago

matching the log

Logger: homeassistant.config_entries Source: helpers/entity_component.py:172 First occurred: 1:25:34 AM (9 occurrences) Last logged: 2:37:59 AM

Error unloading entry Craigs TV for media_player Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 466, in async_unload result = await component.async_unload_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 383, in async_unload_entry return await component.async_unload_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 172, in async_unload_entry raise ValueError("Config entry was never loaded!") ValueError: Config entry was never loaded!

Seems like only one of the status changes of unavail or on is triggering the issue maybe

bernikr commented 2 years ago

I'm not sure if it related, but since I updated to the non-yaml version the connection to the tv is sometimes lost. If that happens the TV shows as off in HA even if it is running and controlling the TV is not possible anymore. Calling homeassistant.reload_config_entry with the tv as a target usually fixes the issue.

Logger: homeassistant.components.webostv.media_player
Source: components/webostv/media_player.py:115
Integration: LG webOS Smart TV (documentation, issues)
First occurred: March 9, 2022, 13:40:38 (31 occurrences)
Last logged: March 14, 2022, 20:19:15

Error calling async_command on entity media_player.living_room_tv, state:off, error: WebOsTvCommandError("Not connected, can't execute command.")
Error calling async_select_source on entity media_player.living_room_tv, state:off, error: WebOsTvCommandError("Not connected, can't execute command.")
Tigger2014 commented 2 years ago

I'm not sure if it related, but since I updated to the non-yaml version the connection to the tv is sometimes lost. If that happens the TV shows as off in HA even if it is running and controlling the TV is not possible anymore. Calling homeassistant.reload_config_entry with the tv as a target usually fixes the issue.

Logger: homeassistant.components.webostv.media_player
Source: components/webostv/media_player.py:115
Integration: LG webOS Smart TV (documentation, issues)
First occurred: March 9, 2022, 13:40:38 (31 occurrences)
Last logged: March 14, 2022, 20:19:15

Error calling async_command on entity media_player.living_room_tv, state:off, error: WebOsTvCommandError("Not connected, can't execute command.")
Error calling async_select_source on entity media_player.living_room_tv, state:off, error: WebOsTvCommandError("Not connected, can't execute command.")

This is exactly the issue i have also

thecode commented 2 years ago

@bernikr @Tigger2014 this issue is here for a specific problem, not related to this, please create a separate issue. Thanks

DrewXT commented 2 years ago

My scenario is slightly different - I have an automation that I've turned into a template switch, using WoL to turn on the TV, via Ethernet connection - this works 100% of the time, so I have a workaround for turning the device on (for now)

What I am seeing, however is that the TV is unreachable as a device until it's turned on - this wasn't apparent when the Integration was configured via YAML

9/10 times if I restart home assistant, I can turn on the TV via the power button on the mini-media-player card, but that's not a practical solution in a family scenario

thecode commented 2 years ago

My scenario is slightly different - I have an automation that I've turned into a template switch, using WoL to turn on the TV, via Ethernet connection - this works 100% of the time, so I have a workaround for turning the device on (for now)

What I am seeing, however is that the TV is unreachable as a device until it's turned on - this wasn't apparent when the Integration was configured via YAML

9/10 times if I restart home assistant, I can turn on the TV via the power button on the mini-media-player card, but that's not a practical solution in a family scenario

Please create a separate issue

thecode commented 2 years ago

Locking this as somehow the last few days it become garbage collector for unrelated issues, when I will have news for this issue I will update here.

thecode commented 1 year ago

Fixed by https://github.com/home-assistant/core/pull/81900