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

Skip to content

Disable volume control for Onkyo when unavailable #14863

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 1 commit into from
Jun 8, 2018

Conversation

snikch
Copy link
Contributor

@snikch snikch commented Jun 7, 2018

Description:

Disables volume control support for zones which don't support it. This includes Zones set to HDMI out or pre-out.

There are two possibilities here, a) A zone that can never support volume and b) a zone that currently doesn't support volume. In the first case, we'd get a timeout error attempting to retrieve the volume, resulting in the volume_raw value being False. In the second case we'd receive a response to the volume command, but the volume_raw[1] value is the string N/A, so we do a type check to check for that. Both cases are handled.

fixes #14774

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

w/ volume
image

wo/volume
image

@ghost ghost added in progress and removed small-pr PRs with less than 30 lines. labels Jun 7, 2018
@@ -32,6 +32,9 @@
SUPPORT_VOLUME_STEP | SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
SUPPORT_SELECT_SOURCE | SUPPORT_PLAY

SUPPORT_ONKYO_WO_SOUND = SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \
Copy link
Member

Choose a reason for hiding this comment

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

SOUND or VOLUME?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, fixed.

@balloob
Copy link
Member

balloob commented Jun 7, 2018

Ok to merge when tests pass.

@snikch
Copy link
Contributor Author

snikch commented Jun 8, 2018

Can somebody please force a rebuild. Looks like travis had a network connectivity issue.

@syssi syssi closed this Jun 8, 2018
@ghost ghost removed the in progress label Jun 8, 2018
@syssi syssi reopened this Jun 8, 2018
@ghost ghost assigned syssi Jun 8, 2018
@ghost ghost added the in progress label Jun 8, 2018
@syssi
Copy link
Member

syssi commented Jun 8, 2018

@snikch Closing/Re-opening triggers a rebuild without the need of additional commits.

@syssi syssi merged commit e3fba79 into home-assistant:dev Jun 8, 2018
@ghost ghost removed the in progress label Jun 8, 2018
@@ -270,7 +273,8 @@ class OnkyoDeviceZone(OnkyoDevice):
def __init__(self, zone, receiver, sources, name=None):
"""Initialize the Zone with the zone identifier."""
self._zone = zone
super().__init__(receiver, sources, name)
self._supports_volume = True
super(OnkyoDeviceZone, self).__init__(receiver, sources, name)
Copy link
Member

Choose a reason for hiding this comment

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

super().__init__(receiver, sources, name)

if not (volume_raw and mute_raw and current_source_raw):
return

# It's possible for some players to have zones set to HDMI with
# no sound control. In this case, the string `N/A` is returned.
self._supports_volume = isinstance(volume_raw[1], (float, int))
Copy link
Member

Choose a reason for hiding this comment

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

How does this go along with outcome of home-assistant/architecture#1, which said that supported features shouldn't change during entity lifetime? This PR might be valid, but I'm curious as to where the lines are drawn.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, hadn't seen that discussed. The features here are less driven by state (idle, on etc.) and more by configuration (set zone 2 to HDMI out instead of speaker out), so they can change during the lifetime of the entity, but aren't expected to do so regularly.

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that for example, a device is synced to Google Assistant or Amazon Echo exactly once. If it changes, things might sync over incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I can move the code determining this into the constructor (not my initial code) and that would avoid the problem? It would add a delay in initialising the entity since it needs to make network requests, I assume that's acceptable and handled correctly.

@balloob balloob mentioned this pull request Jun 22, 2018
girlpunk pushed a commit to girlpunk/home-assistant that referenced this pull request Sep 4, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
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.

Onkyo Zone2/Zone3 issue
5 participants