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 snapcast uuid to be more unique #14925

Merged
merged 1 commit into from
Jun 12, 2018

Conversation

jedi7
Copy link
Contributor

@jedi7 jedi7 commented Jun 11, 2018

Current uuid is ok when using only 1 snapserver
New uuid is needed when using multiple snapserver

Because the client can connect to more snapservers and
then uuid based on client MAC is not enough

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.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated 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:

  • Tests have been added to verify that the new code works.

@ghost ghost added in progress and removed small-pr PRs with less than 30 lines. labels Jun 11, 2018

@property
def name(self):
"""Return the name of the device."""
return '{}{}'.format(CLIENT_PREFIX, self._client.identifier)
return '{}{}_{}'.format(CLIENT_PREFIX, self._client._server._host, self._client.identifier)

Choose a reason for hiding this comment

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

line too long (99 > 79 characters)

"""Return the ID of this snapcast client.
Note: Host part is needed, when using multiple snapservers
"""
return '{}{}_{}'.format(CLIENT_PREFIX, self._client._server._host, self._client.identifier)

Choose a reason for hiding this comment

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

line too long (99 > 79 characters)


@property
def name(self):
"""Return the name of the device."""
return '{}{}'.format(GROUP_PREFIX, self._group.identifier)
return '{}{}_{}'.format(GROUP_PREFIX, self._group._server._host, self._group.identifier)

Choose a reason for hiding this comment

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

line too long (96 > 79 characters)

@@ -107,12 +107,12 @@ def state(self):
@property
def unique_id(self):
"""Return the ID of snapcast group."""
return '{}{}'.format(GROUP_PREFIX, self._group.identifier)
return '{}{}_{}'.format(GROUP_PREFIX, self._group._server._host, self._group.identifier)

Choose a reason for hiding this comment

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

line too long (96 > 79 characters)


@property
def name(self):
"""Return the name of the device."""
return '{}{}'.format(GROUP_PREFIX, self._group.identifier)
return '{}{}_{}'.format(GROUP_PREFIX, self._group._server._host,
Copy link
Member

Choose a reason for hiding this comment

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

Changing the name will change the entity_id, so that will make this a breaking change.

With the unique id set, the entity_id doesn't need to be changed. Both name and entity_id can be customized by the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I see. Reason for changing it was the same name twice in the tab.
So should I keep the previous name and make renaming inside the registry file?

Copy link
Member

Choose a reason for hiding this comment

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

That's my suggestion. I'm guessing not all users will need to change this if they don't have multiple hosts. So it's better to not make a breaking change and still allow impacted users to set their names and IDs as they want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok I changed it :)

Current uuid is ok when using only 1 snapserver
New uuid is needed when using multiple snapserver

Because the client can connect to more snapservers and
then uuid based on client MAC is not enough
@jedi7
Copy link
Contributor Author

jedi7 commented Jun 12, 2018

I must changed the way of getting host, port because travis does not like the access of "private" members

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

Sidenote: Please don't squash commits after review has started. It makes it harder to follow the changes. We will squash via github when merging.

@MartinHjelmare MartinHjelmare merged commit 89d008d into home-assistant:dev Jun 12, 2018
@ghost ghost removed the in progress label Jun 12, 2018
@OttoWinter
Copy link
Member

@MartinHjelmare Isn't this a breaking change? When the unique ID changes, the entity registry will generate a new entry for it and thus a new entity ID.

(side note: changing the name of an entity that implements unique_id is AFAIK not a breaking change, as the entity registry keeps entity IDs with the same unique ID static)

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Jun 15, 2018

That's true.

But since the unique_id was added five days ago it hasn't been released yet, so it's not a breaking change and my statements above was based on that.

#14895

@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
Current uuid is ok when using only 1 snapserver
New uuid is needed when using multiple snapserver

Because the client can connect to more snapservers and
then uuid based on client MAC is not enough
@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.

5 participants