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

Fix unmute bug in vlc_telnet #48441

Merged
merged 1 commit into from
Mar 29, 2021
Merged

Conversation

dmcc
Copy link
Contributor

@dmcc dmcc commented Mar 28, 2021

Proposed change

If volume was muted and media_player.volume_up is fired, VLC would still
show up as muted.

PR extracted from #44776.

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

Example entry for configuration.yaml:

# Example configuration.yaml

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.
  • 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:

If volume was muted and media_player.volume_up is fired, VLC would still
show up as muted.

PR extracted from home-assistant#44776.
@probot-home-assistant
Copy link

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

@@ -249,6 +249,10 @@ def set_volume_level(self, volume):
self._vlc.set_volume(volume * MAX_VOLUME)
self._volume = volume

if self._muted and self._volume > 0:
# This can happen if we were muted and then see a volume_up.
self._muted = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no feedback on mute state that we can get from vlc on update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good question. I've looked at the output of VLCTelnet.status() and VLCTelnet.info(), but didn't find anything relevant. AFAICT, the VLC telnet protocol doesn't ever tell us if VLC is actually muted so this seems to be a deeper problem.

Seems we'd want to use https://pypi.org/project/python-vlc/ for this type of control.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that library is using the c-bindings so is out of scope for this integration.

Instead of using a separate variable for muted I suggest we check if self._volume equals 0. The volume attribute is updated by the update method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, not sure I understand. Would that check mean that if the user sets the volume to 0 in VLC, Home Assistant would detect VLC as muted? If so, what would the behavior be if the user clicks unmute in Home Assistant?

Incidentally, here's another possible direction: We remove SUPPORT_VOLUME_MUTE from vlc_telnet entirely (since VLC doesn't actually support this and we're essentially simulating mute...).

(and yes, switching to the CTypes lib would be a totally separate integration -- probably not worth it if the only benefit is adding mute support :))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We probably wouldn't have added mute support today simulated like this, but removing it now is also a breaking change. We have some simulated features in the base media player class so we're a bit more flexible it seems for the media player. I'm ok with this fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vlc integration uses the c-bindings library.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Martin!

The vlc integration uses the c-bindings library.

Indeed! I'll have to revisit using that integration in my setup -- I forget why I settled on the telnet one of all things :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to have the vlc application installed on the same host as Home Assistant for that integration. I think that may be a major limitation for some users.

@MartinHjelmare MartinHjelmare merged commit f815ebe into home-assistant:dev Mar 29, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2021
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.

3 participants