Skip to content

Add bronze quality scale to DNS IP#169688

Open
Phil-Rad wants to merge 4 commits intohome-assistant:devfrom
Phil-Rad:quality-scale/dnsip-bronze
Open

Add bronze quality scale to DNS IP#169688
Phil-Rad wants to merge 4 commits intohome-assistant:devfrom
Phil-Rad:quality-scale/dnsip-bronze

Conversation

@Phil-Rad
Copy link
Copy Markdown

@Phil-Rad Phil-Rad commented May 3, 2026

Breaking change

Proposed change

Brings the dnsip integration onto the Integration Quality Scale at the Bronze tier.

Changes:

  • New file homeassistant/components/dnsip/quality_scale.yaml — full rule audit against the Bronze checklist; all 18 Bronze rules satisfied (done or exempt with justification). Silver / Gold / Platinum rules left as todo for follow-up PRs.
  • manifest.json — added "quality_scale": "bronze".
  • strings.json — added data_description blocks under both config.step.user and options.step.init. The existing descriptive text was promoted from data (field labels) to data_description (helper text), with concise field names retained as labels. This is required by the strict translation check that activates once config-flow: done is claimed.
  • script/hassfest/quality_scale.py — removed dnsip from both INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE and INTEGRATIONS_WITHOUT_SCALE.

Two Bronze rules are marked exempt rather than done, which I'd appreciate a sanity check on:

  • runtime-data — each WanIpSensor carries its own aiodns.DNSResolver instance. There is no shared per-config-entry state that benefits from being stored on entry.runtime_data.
  • test-before-setup — the integration has no central connection to validate at setup time. Each sensor performs its own DNS resolution in async_update and reports availability via _attr_available.

Happy to refactor toward a DataUpdateCoordinator pattern in a follow-up if you'd prefer those rules to be done rather than exempt. Wanted to keep this PR scoped to the YAML / strings changes for clean review.

Validated locally:

  • python -m script.hassfest --integration-path homeassistant/components/dnsip — clean
  • pytest tests/components/dnsip/ — 17 passed
  • ruff check — clean
  • All pre-commit hooks pass

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:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings May 3, 2026 13:40
Copy link
Copy Markdown
Contributor

@home-assistant home-assistant Bot left a comment

Choose a reason for hiding this comment

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

Hi @Phil-Rad

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!

@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented May 3, 2026

Hey there @gjohansson-ST, mind taking a look at this pull request as it has been labeled with an integration (dnsip) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of dnsip can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign dnsip Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request brings the dnsip integration onto the Home Assistant Integration Quality Scale by declaring Bronze compliance and aligning metadata/translations accordingly.

Changes:

  • Add homeassistant/components/dnsip/quality_scale.yaml with Bronze rules marked done/exempt (and higher tiers left as todo).
  • Declare "quality_scale": "bronze" in the dnsip integration manifest.
  • Update dnsip translations to use data_description helper text for config/options flows and remove dnsip from hassfest “without quality scale” lists.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
script/hassfest/quality_scale.py Removes dnsip from lists that track integrations lacking IQS grading/files.
homeassistant/components/dnsip/strings.json Moves verbose field help text into data_description and keeps concise labels in data.
homeassistant/components/dnsip/quality_scale.yaml Adds the quality scale rule audit and Bronze tier declaration for dnsip.
homeassistant/components/dnsip/manifest.json Sets the integration’s declared quality scale tier to bronze.

@Phil-Rad Phil-Rad marked this pull request as ready for review May 3, 2026 13:45
@Phil-Rad Phil-Rad requested review from a team and gjohansson-ST as code owners May 3, 2026 13:45
status: exempt
comment: Each WanIpSensor manages its own aiodns.DNSResolver instance and there is no shared state at the config-entry level.
test-before-configure: done
test-before-setup:
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 probably fix that beforehand instead of exempting it.
We can create the resolver in setup, test the connection and attach it to config entry runtime to use later in the sensor (I don't see a need for a coordinator really)

@home-assistant home-assistant Bot marked this pull request as draft May 3, 2026 19:31
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented May 3, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@Phil-Rad Phil-Rad marked this pull request as ready for review May 4, 2026 01:57
Copilot AI review requested due to automatic review settings May 4, 2026 01:57
@home-assistant home-assistant Bot requested a review from gjohansson-ST May 4, 2026 01:57
@home-assistant home-assistant Bot dismissed their stale review May 4, 2026 01:57

Stale

@Phil-Rad
Copy link
Copy Markdown
Author

Phil-Rad commented May 4, 2026

First commit so just wanted something small to see how it works but now done with your request and pushed the refactor.

async_setup_entry now creates both resolvers, runs a quick test query against the configured hostname (raises ConfigEntryNotReady if it fails), and hands them off via entry.runtime_data. The sensors just pick them up from there. Both rules flipped to done in the YAML.

All local checks green. Let me know if something else needs to be changed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

tests/components/dnsip/test_init.py:55

  • Add assertions/tests to cover the new setup-time validation and ensure resolver resources are properly closed on unload and on setup failure.
    entry.add_to_hass(hass)

    with patch(
        "homeassistant.components.dnsip.aiodns.DNSResolver",
        return_value=RetrieveDNS(),
    ):
        await hass.config_entries.async_setup(entry.entry_id)
    await hass.async_block_till_done()

    assert entry.state is ConfigEntryState.LOADED
    assert await hass.config_entries.async_unload(entry.entry_id)
    await hass.async_block_till_done()

Comment on lines +45 to +60
resolver_ipv4 = aiodns.DNSResolver(
nameservers=[nameserver_ipv4], tcp_port=port_ipv4, udp_port=port_ipv4
)
resolver_ipv6 = aiodns.DNSResolver(
nameservers=[nameserver_ipv6], tcp_port=port_ipv6, udp_port=port_ipv6
)

hostname = entry.data[CONF_HOSTNAME]
try:
async with asyncio.timeout(10):
if entry.data[CONF_IPV4]:
await resolver_ipv4.query(hostname, "A")
elif entry.data[CONF_IPV6]:
await resolver_ipv6.query(hostname, "AAAA")
except (TimeoutError, DNSError) as err:
raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in next push

Comment on lines +53 to +61
try:
async with asyncio.timeout(10):
if entry.data[CONF_IPV4]:
await resolver_ipv4.query(hostname, "A")
elif entry.data[CONF_IPV6]:
await resolver_ipv6.query(hostname, "AAAA")
except (TimeoutError, DNSError) as err:
raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Unsure if this is required. Can add this change if this is needed

Comment on lines 71 to 74
async def async_unload_entry(hass: HomeAssistant, entry: DnsIPConfigEntry) -> bool:
"""Unload DNS IP config entry."""

return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed in next push

Copilot AI review requested due to automatic review settings May 4, 2026 02:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Comment on lines 150 to 154
dns_mock.error = DNSError()
with patch(
"homeassistant.components.dnsip.sensor.aiodns.DNSResolver",
"homeassistant.components.dnsip.aiodns.DNSResolver",
return_value=dns_mock,
):
Comment on lines 210 to 214
with (
patch(
"homeassistant.components.dnsip.sensor.aiodns.DNSResolver",
"homeassistant.components.dnsip.aiodns.DNSResolver",
return_value=dns_mock,
),
Comment on lines +22 to +25
runtime-data: done
test-before-configure: done
test-before-setup: done
unique-config-entry: done
Comment on lines +53 to +63
try:
async with asyncio.timeout(10):
if entry.data[CONF_IPV4]:
await resolver_ipv4.query(hostname, "A")
elif entry.data[CONF_IPV6]:
await resolver_ipv6.query(hostname, "AAAA")
except (TimeoutError, DNSError) as err:
await resolver_ipv4.close()
await resolver_ipv6.close()
raise ConfigEntryNotReady(f"DNS lookup failed for {hostname}: {err}") from err

resolver_ipv6=resolver_ipv6,
)

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants