Skip to content

Add zeroconf ATTR constants#58671

Merged
frenck merged 4 commits intohome-assistant:devfrom
epenet:zeroconf_attributes
Oct 31, 2021
Merged

Add zeroconf ATTR constants#58671
frenck merged 4 commits intohome-assistant:devfrom
epenet:zeroconf_attributes

Conversation

@epenet
Copy link
Copy Markdown
Contributor

@epenet epenet commented Oct 29, 2021

Proposed change

Add ATTR_* constants to zeroconf, to be used by the various config flows.
Sample use in hue

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

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
Copy Markdown

Hey there @balloob, @frenck, mind taking a look at this pull request as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@probot-home-assistant
Copy link
Copy Markdown

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

Comment on lines +65 to +70
ATTR_HOST: Final = "host"
ATTR_HOSTNAME: Final = "hostname"
ATTR_NAME: Final = "name"
ATTR_PORT: Final = "port"
ATTR_PROPERTIES: Final = "properties"
ATTR_TYPE: Final = "type"
Copy link
Copy Markdown
Contributor Author

@epenet epenet Oct 29, 2021

Choose a reason for hiding this comment

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

Only three attributes used in this PR:

  • zeroconf uses ATTR_NAME and ATTR_PROPERTIES
  • hue uses ATTR_HOST and ATTR_PROPERTIES

But I figured it was best to create all 6 attributes right away,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should not create unused constants. That is introducing dead code.

Copy link
Copy Markdown
Contributor Author

@epenet epenet Oct 29, 2021

Choose a reason for hiding this comment

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

Noted
I have dropped the extra 3 constants, and will add them back in as and when required.

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Oct 29, 2021
@epenet
Copy link
Copy Markdown
Contributor Author

epenet commented Oct 29, 2021

@MartinHjelmare how do you feel about this PR regarding zeroconf constants?
I have often had my PRs reviewed with comments "this could be moved to a constant"

Copy link
Copy Markdown
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.

Constants here makes sense since it's a fixed interface and each integration does not need to define their own interface.

Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @epenet 👍

@frenck frenck merged commit 2ae8612 into home-assistant:dev Oct 31, 2021
@epenet epenet deleted the zeroconf_attributes branch October 31, 2021 15:14
@epenet epenet mentioned this pull request Oct 31, 2021
22 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed code-quality Hacktoberfest integration: hue integration: zeroconf small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants