Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use callback to get app_list in SamsungTV #68506

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

Merged
merged 17 commits into from
Mar 23, 2022

Conversation

epenet
Copy link
Contributor

@epenet epenet commented Mar 22, 2022

Proposed change

After #66752 was merged, I discovered that some newer models no longer reply to the app_list request. They accept the request, but don't respond and we are waiting for the timeout to trigger in the media_player update method.

This PR moves the logic into a callback, so the app_list request is sent on connect, but we no longer wait for a response.
If a response does come, then the callback is triggered.

Follow-up to #66752, #68114, #68235

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

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

@epenet epenet changed the title Use callback to get SamsungTV app list Use callback to get app_list in SamsungTV Mar 22, 2022
@bdraco
Copy link
Member

bdraco commented Mar 23, 2022

This is a much better design. Is there any risk that the sources won't be available until after the started event ?

@epenet
Copy link
Contributor Author

epenet commented Mar 23, 2022

This is a much better design. Is there any risk that the sources won't be available until after the started event ?

Not in my experience - I always get the list. But I cannot say for all TVs.

@bdraco
Copy link
Member

bdraco commented Mar 23, 2022

Maybe wait 2-3s for an asyncio.Future or asyncio.Event on the first update to make sure it has a chance to set the sources list before started?

@epenet
Copy link
Contributor Author

epenet commented Mar 23, 2022

Maybe wait 2-3s for an asyncio.Future or asyncio.Event on the first update to make sure it has a chance to set the sources list before started?

Is this what you have in mind? 69d22960e04d22ce3573293465951b2b746428e5

@epenet epenet force-pushed the samsung-app-list branch from 761152a to 042581e Compare March 23, 2022 10:27
@epenet
Copy link
Contributor Author

epenet commented Mar 23, 2022

From Discord:

To make sure startup doesn’t finish before the app list is returned
and the the voice assistants such as homekit/Alexa/google assistant load the source list at the stated event

If we need to wait anyway inside the async_update routine, maybe it makes less sense to do this refactor...
There is already the equivalent code using a Future in https://github.com/xchwarze/samsung-tv-ws-api/blob/a111f2126ecf5c7f400cc87ccee24f4ceced9fba/samsungtvws/async_remote.py#L58-L71

I have refactored the code anyway but if you feel it's pointless we can close the PR.

@epenet epenet marked this pull request as draft March 23, 2022 11:24
@epenet
Copy link
Contributor Author

epenet commented Mar 23, 2022

Will need to be rebased over #68562

@epenet epenet force-pushed the samsung-app-list branch from 718626a to f782779 Compare March 23, 2022 11:34
@epenet epenet force-pushed the samsung-app-list branch from f782779 to ddfaa29 Compare March 23, 2022 18:37
@epenet epenet marked this pull request as ready for review March 23, 2022 18:37
@bdraco bdraco merged commit 9ba0475 into home-assistant:dev Mar 23, 2022
@epenet epenet deleted the samsung-app-list branch March 23, 2022 21:12
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants