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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add serial_number to device registry entries #77713

Merged
merged 1 commit into from
Sep 27, 2022

Conversation

emontnemery
Copy link
Contributor

@emontnemery emontnemery commented Sep 2, 2022

Proposed change

Add serial_number to device registry entries

The serial number can be displayed in the device card in frontend

The "identifiers" set which is part of device registry entries can't be used for this purpose because:

  • they are globally unique
  • we have no idea what they are, it could be a serial number, but it could also be anything else used by the backing integration

Developer documentation: home-assistant/developers.home-assistant#1477

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • 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:

@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (config) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@project-bot project-bot bot added this to Needs review in Dev Sep 2, 2022
@bdraco
Copy link
Member

bdraco commented Sep 2, 2022

Related arch discussion

home-assistant/architecture#717

"entry_type": "service",
"hw_version": "hw_version",
"id": "abcdefghijklm",
"identifiers": [["serial", "12:34:56:AB:CD:EF"]],
Copy link
Member

Choose a reason for hiding this comment

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

"serial" here is just a coincidence, right? It's not a requirement of this PR, right?

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's indeed just a concidence 馃憤

Copy link
Member

Choose a reason for hiding this comment

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

This should have rang a bell IMHO, as a serial number IS an identifier.

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.

I don't remember if we agreed that this was ok besides the related architecture discussion. Code looks good.

Dev automation moved this from Needs review to Reviewer approved Sep 23, 2022
@emontnemery
Copy link
Contributor Author

We agreed this was OK.
The related architecture discussion can be solved by frontend simply picking MAC(s) from the device entry and displaying that.

@emontnemery emontnemery merged commit cba3b6a into dev Sep 27, 2022
Dev automation moved this from Reviewer approved to Done Sep 27, 2022
@emontnemery emontnemery deleted the device_registry_serial_number branch September 27, 2022 07:08
@frenck
Copy link
Member

frenck commented Sep 27, 2022

The related architecture discussion can be solved by frontend simply picking MAC(s) from the device entry and displaying that.

I'm confused by this comment @emontnemery, so your are saying MAC addresses could be just picked up by the frontend from the identifiers...

Why isn't serial in the identifiers as well in that case?

That comment, just made this PR invalid IMHO.

@frenck frenck restored the device_registry_serial_number branch September 27, 2022 07:11
@@ -90,6 +90,7 @@ class DeviceEntry:
model: str | None = attr.ib(default=None)
name_by_user: str | None = attr.ib(default=None)
name: str | None = attr.ib(default=None)
serial_number: str | None = attr.ib(default=None)
Copy link
Member

Choose a reason for hiding this comment

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

A serial number IS an identifier, for which we already have a property.

emontnemery added a commit that referenced this pull request Sep 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2022
@frenck frenck deleted the device_registry_serial_number branch January 3, 2023 23:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants