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

Don't hang forever if manually added cast is down #21565

Merged
merged 7 commits into from Mar 11, 2019

Conversation

Projects
None yet
6 participants
@emontnemery
Copy link
Contributor

commented Mar 1, 2019

Description:

Don't hang forever if manually added cast is down when HA starts.
Also improve logging if exceptions are thrown when starting the platform.

Related issue (if applicable): fixes #17282

Note: Depends on balloob/pychromecast#271

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
@andriej

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2019

Will it fix situation when I have some cast's declared but they are 99% offline (as they turn on only together with TV - powered from it's USB?)
I have lots of logs with errors and reconnects.

@emontnemery

This comment has been minimized.

Copy link
Contributor Author

commented Mar 1, 2019

@andriej This will fix the issue where HA never starts if a manually added cast is not available. If a cast is not available, there will be debug prints when HA is repeatedly trying to reconnect.

In your case, I really recommend to add the cast integration instead of manually adding devices. HA will then discover and connect to casts which are online, and not aimlessly try to reconnect to casts that are offline.

@balloob

balloob approved these changes Mar 7, 2019

@balloob balloob changed the title Don't hang forever if manually added cast is down WIP: Don't hang forever if manually added cast is down Mar 7, 2019

@balloob

This comment has been minimized.

Copy link
Member

commented Mar 7, 2019

Renaming to WIP while we wait for upstream change.

@robbiet480

This comment has been minimized.

Copy link
Member

commented Mar 9, 2019

@emontnemery Just a FYI, applying this patch to my latest dev install fixed the exact same hang issue that @andriej reported. I didn't have cast: anywhere in my config. In fact, what caused the hang was when I upgraded to 0.89 and saw the warning in my logs about how I shouldn't manually configure via the platform. I removed the media_player.cast platform and then the hang started. I've got a mix of Chromecast devices including actual Chromecasts, a Fire TV, a Bravia TV running Android TV and a Google Home Hub.

Would be good to get this on 0.89.2.

@robbiet480

This comment has been minimized.

Copy link
Member

commented Mar 9, 2019

Oopsies, may have spoken too soon. Attempting to add the Google Cast integration via the frontend throws this:

2019-03-08 19:38:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'
2019-03-08 19:38:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'
2019-03-08 19:38:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'

EDIT: Got this before patching pychromecast. Even after patching it I still am seeing this.

EDIT 2: Slightly different errors here:

2019-03-08 19:42:26 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/data_entry_flow.py", line 57, in async_init
    handler, context=context, data=data)
  File "/home/robbiet480/home-assistant/homeassistant/config_entries.py", line 691, in _async_create_flow
    raise data_entry_flow.UnknownHandler
homeassistant.data_entry_flow.UnknownHandler
2019-03-08 19:42:26 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'
2019-03-08 19:42:26 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'
2019-03-08 19:42:26 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/robbiet480/home-assistant/homeassistant/components/cast/media_player.py", line 480, in async_set_cast_info
    self._chromecast.start()
AttributeError: 'Chromecast' object has no attribute 'start'

emontnemery added some commits Mar 9, 2019

@emontnemery

This comment has been minimized.

Copy link
Contributor Author

commented Mar 9, 2019

@robbiet480 There were additional changes to pychromecast after feedback from @balloob. Those changes are now merged and released, and it is enough to path the files included in this PR (HASS will then automatically install updated pychromecast).
Would you mind trying again?

emontnemery added some commits Mar 10, 2019

@emontnemery emontnemery changed the title WIP: Don't hang forever if manually added cast is down Don't hang forever if manually added cast is down Mar 10, 2019

@balloob balloob merged commit fc85b3f into home-assistant:dev Mar 11, 2019

4 checks passed

Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.02%) to 92.725%
Details

@ghost ghost removed the in progress label Mar 11, 2019

@balloob

This comment has been minimized.

Copy link
Member

commented Mar 11, 2019

🎉 🎉 🎉

@smcue

This comment has been minimized.

Copy link

commented Mar 12, 2019

Has this been implemented?

Having a a similar issue on 0.89.1, Cast Intergration throws an error and prevents web ui from loading. I have to delete 'core.config_entries' file, for the UI to load, which then deletes all the cast integration.

2019-03-12 16:41:21 ERROR (SyncWorker_19) [pychromecast.socket_client] [Fire TV:8010] Failed to connect to service Fire TV._googlecast._tcp.local., retrying in 5.0s

@emontnemery

This comment has been minimized.

Copy link
Contributor Author

commented Mar 13, 2019

@cueapps It will be in 0.90, please wait for it then open an issue if your problem doesn't go away

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Mar 13, 2019

@emontnemery emontnemery deleted the emontnemery:cast_dont_hang branch Apr 3, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.