Skip to content

Add OpenAQ integration#169755

Open
jeeftor wants to merge 15 commits intohome-assistant:devfrom
jeeftor:feature/openAQ
Open

Add OpenAQ integration#169755
jeeftor wants to merge 15 commits intohome-assistant:devfrom
jeeftor:feature/openAQ

Conversation

@jeeftor
Copy link
Copy Markdown
Contributor

@jeeftor jeeftor commented May 4, 2026

Breaking change

Proposed change

Add the OpenAQ integration with API-key setup, map-based monitoring location subentries, and air quality sensor entities.

OpenAQ is an environmental tech nonprofit. We aggregate and harmonize open air quality data from across the globe onto an open-source, open-access data platform so that anyone concerned about air quality has unfettered access to the data they need to analyze, communicate and advocate for clean air. By providing universal access to air quality data, OpenAQ empowers a global community of changemakers to solve air inequality–the unequal access to clean air.
Anyone can explore the data via OpenAQ Explorer, an interactive web application. For programmatic access via the API or to create custom lists on OpenAQ Explorer, user registration is required. See also our AQI Hub, a unique website to navigate air quality indexes across the world.

The location flow searches outward from the selected Home Assistant map point, ranks useful stations by supported sensor coverage and distance, and lets the user add one station at a time. It also adds a disabled-by-default diagnostic distance sensor for each station.

This PR includes the initial OpenAQ quality scale file with Bronze config-flow coverage complete.

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

New dependency:

  • openaq==0.7.0

Verification:

  • uv run pytest -q tests/components/openaq
  • uv run python -m script.hassfest --integration-path homeassistant/components/openaq
  • prek run --hook-stage pre-commit

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 4, 2026 17:17
@jeeftor jeeftor requested a review from a team as a code owner May 4, 2026 17:17
@jeeftor jeeftor marked this pull request as draft May 4, 2026 17:19
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

Adds a new openaq integration to Home Assistant core, enabling configuration via an API key with location subentries and exposing latest air-quality measurements as sensor entities.

Changes:

  • Introduces the OpenAQ integration (config flow + location subentry flow, coordinator-based polling, and sensor platform entities).
  • Adds a full initial test suite with snapshots for sensors and config flow coverage for core paths.
  • Registers the dependency (openaq==0.7.0) and updates generated/metadata files (integrations/config flows, CODEOWNERS, quality scale tracking).

Reviewed changes

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

Show a summary per file
File Description
homeassistant/components/openaq/__init__.py Sets up the integration entry, creates the shared OpenAQ client, initializes per-location coordinators, forwards platform setups, and unload handling.
homeassistant/components/openaq/config_flow.py Implements API-key config flow plus location subentry flows (map/radius search and direct location ID).
homeassistant/components/openaq/const.py Defines integration constants (domain, defaults, subentry keys).
homeassistant/components/openaq/coordinator.py Coordinator and data normalization for OpenAQ location metadata and latest measurements.
homeassistant/components/openaq/sensor.py Defines sensor entity descriptions, unit mapping, and CoordinatorEntity-based sensor entities per parameter.
homeassistant/components/openaq/manifest.json Declares integration metadata and the openaq==0.7.0 dependency.
homeassistant/components/openaq/strings.json Adds UI strings for the config flow, subentry flow, entities, and translated exceptions.
homeassistant/components/openaq/icons.json Adds icon translations for selected sensor translation keys.
homeassistant/components/openaq/quality_scale.yaml Introduces initial quality scale tracking with TODOs and exemptions.
tests/components/openaq/__init__.py Adds a helper to set up the integration in tests.
tests/components/openaq/conftest.py Provides fixtures for a mock config entry, mock OpenAQ client, and SDK-like response objects.
tests/components/openaq/test_config_flow.py Tests the user flow and location subentry flows (map search, location ID, duplicates).
tests/components/openaq/test_init.py Tests setup success, setup retry behavior, unload client close, and reload listener.
tests/components/openaq/test_sensor.py Tests sensor entity creation, unit/device class behavior, missing values behavior, and unavailable states on refresh failure.
tests/components/openaq/snapshots/test_sensor.ambr Snapshot coverage for the created OpenAQ sensor entities and their states/registry entries.
requirements_all.txt Adds openaq==0.7.0 to the full requirements list.
requirements_test_all.txt Adds openaq==0.7.0 for test environments.
homeassistant/generated/integrations.json Registers the openaq integration in generated integration metadata.
homeassistant/generated/config_flows.py Registers openaq as having a config flow in generated config flow metadata.
script/hassfest/quality_scale.py Adds openaq to integrations without a scored quality scale.
CODEOWNERS Adds code ownership entries for the OpenAQ integration and its tests.

Comment thread homeassistant/components/openaq/config_flow.py Outdated
Comment thread homeassistant/components/openaq/__init__.py
Comment thread homeassistant/components/openaq/sensor.py Outdated
Comment thread homeassistant/components/openaq/strings.json Outdated
Comment thread homeassistant/components/openaq/config_flow.py Outdated
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 19 out of 21 changed files in this pull request and generated 4 comments.

Comment thread homeassistant/components/openaq/coordinator.py Outdated
Comment thread homeassistant/components/openaq/coordinator.py
Comment thread tests/components/openaq/conftest.py Outdated
Comment thread tests/components/openaq/test_config_flow.py
Copilot AI review requested due to automatic review settings May 4, 2026 19:00
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread script/hassfest/quality_scale.py Outdated
Copilot AI review requested due to automatic review settings May 5, 2026 16:03
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 20 out of 22 changed files in this pull request and generated 3 comments.

Comment thread homeassistant/components/openaq/manifest.json Outdated
Comment thread script/hassfest/quality_scale.py
Comment thread homeassistant/components/openaq/coordinator.py
@jeeftor jeeftor requested a review from Copilot May 5, 2026 16:50
@jeeftor jeeftor marked this pull request as ready for review May 5, 2026 17:09
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 19 out of 21 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/openaq/coordinator.py Outdated
Comment thread homeassistant/components/openaq/config_flow.py Outdated
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 19 out of 21 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/openaq/coordinator.py Outdated
Copilot AI review requested due to automatic review settings May 6, 2026 15:20
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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