Implemented basic async volume transition for media_player#6766
Implemented basic async volume transition for media_player#6766PetePriority wants to merge 2 commits into
Conversation
|
@PetePriority, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @armills and @fabaff to be potential reviewers. |
|
Also we'd need to abort the transition if the user changes the volume externally during a transition. We have the same issues here as implementing software dimmer transitions. There's a thread about this somewhere, but I can't seem to find it. Much later edit, for posterity: #656 |
|
I don't think we should add logic on base stuff. At last we only represent a device a not extend it. For that we have automation. I don't think we should do that. CC @balloob ? |
|
This branch shows an example of cancelable transitions. I had to make changes to the Alternatively, we could move the functionality to a separate "fader" module that calls the set_volume service of specified media players. Maybe that would be a better approach? |
|
I'm not a fan of this either. @armills is right. It will add too much complexity and eventually will end up with a pile of workarounds and hacks. Some alternatives to achieve this:
|
|
@PetePriority I close this PR. You can choise a way they Paulus describe in his comments. |
Description:
This PR implements a simple
volume_transition servicefor the media_player platform. The service callsasync_volume_transitionwhich starts a coroutine_async_transition_helper.Since I'm new with
asyncio, I'd appreciate feedback on my implementation. One problem I see is that when the service gets called while another transition is already running, they'd interfere. Is there a way to cancel an already running coroutine? Another solution would be to have a class-ownedthreading.Timerwhich calls itself after the interval, but this would require__init__for the platform andsuper-calls from all platform components.Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2319