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

Added unique_id property back to Yamaha media_player #12373

Closed
wants to merge 1 commit into from
Closed

Added unique_id property back to Yamaha media_player #12373

wants to merge 1 commit into from

Conversation

Petro31
Copy link
Contributor

@Petro31 Petro31 commented Feb 13, 2018

re-added the unique_id property because the component no longer finds zones beyond the main zone. The inherited unique_id from MediaPlayerDevice does not return a unique id for each zone.

Description:

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

re-added the unique_id property because the component no longer finds zones beyond the main zone.  The inherited unique_id from MediaPlayerDevice does not return a unique id for each zone.
@homeassistant
Copy link
Contributor

Hi @Petro31,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

def unique_id(self):
"""Return an unique ID."""
return '{0}:{1}'.format(self.receiver.ctrl_url, self._zone)

Choose a reason for hiding this comment

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

blank line contains whitespace

Copy link
Contributor

Choose a reason for hiding this comment

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

Is self._zone a user-configurable string (i.e., something that could change through, say, the Yamaha app)? The objective is to not have anything user-configurable in the unique ID that could change down the road while still representing the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not appear to, it appears as if it comes from rxv.RXV() call which returns a receiver object. After tracing through the rxv code, it appears to grab the self._zone from the xml that is requested from the device. When I get home, I can verify this.

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'll have to check the yamaha app as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing the reason it was removed was that it's based on the URL. A unique ID needs to be based on something that won't change for the device, such as a serial number or mac address. I'd see if something like that is available from the API that could be used instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. For time constraints, I only 'rolled back' the changes. When i get home I can find a better way to handle the unique_id. I may have been too hasty with this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

self._zone is not user configurable, it comes from the device.

As far as I can see in both the rxv code, and poking at the XML API for the Yamaha unit, there is nothing available at the rxv layer for uniqueness. That's all operating at the url level (which there was already code to ignore by url devices previously discovered).

The only existing path I'm seeing to get an actual unique id is data that's available in the upnp discovery packet. We don't require everyone to go through that path, so that wouldn't work if discovery was disabled. I don't see any imperative path to get that.

Newer receivers have a more REST like API, but for those of us with older ones losing multizone because there is not a guarunteed way to generate stable uuid would be really sad.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd try and investigate the underlying bug. Not having a unique ID shouldn't affect the behavior of the actual platform code at all.

@Petro31 Petro31 changed the title added unique_id property Added unique_id property back to Yamaha media_player Feb 13, 2018
@emlove
Copy link
Contributor

emlove commented Feb 13, 2018

@balloob
Copy link
Member

balloob commented Feb 13, 2018

Where is Yamaha using unique ID? Unique ID was a property used internally by Home Assistant. By removing it, Home Assistant is actually enforcing less rules. How can this break things?

@balloob
Copy link
Member

balloob commented Feb 13, 2018

Okay, I see it now. The problem is that the default unique ID returns None and you check if that unique ID already exists.

Currently we don't accept URLs as unique IDs because it is user configurable. Getting the MAC address or serial number is preferred.

I suggest that you rename the property to something else than unique_id. That way it doesn't interfere with the internals of Home Assistant and your logic still works.

@sdague
Copy link
Contributor

sdague commented Feb 13, 2018

This is an alternate fix. We don't actually need unique_id to be right for yamaha, we just need something to handle dedup - #12382

@Petro31
Copy link
Contributor Author

Petro31 commented Feb 13, 2018

Should I close this if the plan is to move forward with @sdague PR?

@sdague
Copy link
Contributor

sdague commented Feb 13, 2018

I think it should auto close after merge because of the commit message. @balloob is going to hotfix it into the 0.63.x stream.

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants