Skip to content

Use Radon device class in Airthings BLE - #175388

Merged
abmantis merged 3 commits into
devfrom
airthings_ble_radon_device_class
Jul 3, 2026
Merged

Use Radon device class in Airthings BLE#175388
abmantis merged 3 commits into
devfrom
airthings_ble_radon_device_class

Conversation

@abmantis

@abmantis abmantis commented Jul 2, 2026

Copy link
Copy Markdown
Member

Proposed change

Replace the custom unit logic with the recently added radon device class.

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 July 2, 2026 18:17
@home-assistant

home-assistant Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

Code owner commands

Code owners of airthings_ble 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 airthings_ble 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Airthings BLE integration to model radon measurements using Home Assistant’s radon sensor device class and standard radon concentration units, removing bespoke unit-handling code in the integration.

Changes:

  • Switch radon average sensors to SensorDeviceClass.RADON with UnitOfRadiationConcentration.BECQUEREL_PER_CUBIC_METER.
  • Remove custom radon unit constants and the per-unit-system unit swapping logic in sensor setup.
  • Force the underlying library fetch to use metric radon values so Home Assistant can perform consistent unit conversion for display.

Reviewed changes

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

File Description
homeassistant/components/airthings_ble/sensor.py Uses radon device class + standard unit enum and removes custom unit-mapping logic.
homeassistant/components/airthings_ble/icons.json Removes explicit icon overrides for radon average sensors (now covered by device class behavior).
homeassistant/components/airthings_ble/coordinator.py Always requests metric values from the library to support HA-managed unit conversion.
homeassistant/components/airthings_ble/const.py Removes custom radon unit string constants no longer needed.

@jpettitt

jpettitt commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

overall LGTM - minor non-blocking suggestions

[SUGGESTION] tests/components/airthings_ble/test_sensor.py — no test asserts the new behavior. A small test verifying the radon sensors report device_class: radon with Bq/m³ native unit (and ideally one with US_CUSTOMARY_SYSTEM asserting the state renders in pCi/L) would lock in the statistics-continuity behavior this PR relies on.

[SUGGESTION] coordinator.py:38-40 — since the library default is already is_metric=True, the argument could be dropped entirely; keeping it explicit with the comment is also defensible given the old code toggled it. Take it or leave it.

Comment thread homeassistant/components/airthings_ble/coordinator.py Outdated
Comment thread homeassistant/components/airthings_ble/coordinator.py Outdated
Copilot AI review requested due to automatic review settings July 3, 2026 15:02
@abmantis

abmantis commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

overall LGTM - minor non-blocking suggestions

[SUGGESTION] tests/components/airthings_ble/test_sensor.py — no test asserts the new behavior. A small test verifying the radon sensors report device_class: radon with Bq/m³ native unit (and ideally one with US_CUSTOMARY_SYSTEM asserting the state renders in pCi/L) would lock in the statistics-continuity behavior this PR relies on.

No need, IMO, since we now rely on default behavior (we usually don't add unit conversion tests on integrations).

[SUGGESTION] coordinator.py:38-40 — since the library default is already is_metric=True, the argument could be dropped entirely; keeping it explicit with the comment is also defensible given the old code toggled it. Take it or leave it.

I prefer to keep that explicit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

Comment on lines 64 to 69
"radon_1day_avg": AirthingsBLESensorEntityDescription(
key="radon_1day_avg",
translation_key="radon_1day_avg",
native_unit_of_measurement=VOLUME_BECQUEREL,
device_class=SensorDeviceClass.RADON,
native_unit_of_measurement=UnitOfRadiationConcentration.BECQUEREL_PER_CUBIC_METER,
suggested_display_precision=0,
Comment thread homeassistant/components/airthings_ble/sensor.py Outdated
Comment thread homeassistant/components/airthings_ble/sensor.py Outdated
@abmantis
abmantis merged commit d16f71c into dev Jul 3, 2026
33 checks passed
@abmantis
abmantis deleted the airthings_ble_radon_device_class branch July 3, 2026 16:16
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 4, 2026
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.

4 participants