Skip to content

Fix concentration unit deprecation warnings - #1850

Open
hmmbob wants to merge 1 commit into
AlexxIT:masterfrom
hmmbob:agent/fix-concentration-unit-deprecations
Open

Fix concentration unit deprecation warnings#1850
hmmbob wants to merge 1 commit into
AlexxIT:masterfrom
hmmbob:agent/fix-concentration-unit-deprecations

Conversation

@hmmbob

@hmmbob hmmbob commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • use UnitOfDensity and UnitOfRatio when Home Assistant provides them
  • retain compatibility with the declared Home Assistant 2023.2 minimum by falling back to the legacy concentration constants
  • update the CO2 unit test to use the compatibility value without importing a deprecated constant

Root cause

Home Assistant 2026.8 warns when integrations import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER or CONCENTRATION_PARTS_PER_MILLION. Their replacements were introduced in Home Assistant 2026.7, while SonoffLAN still declares and enforces Home Assistant 2023.2 as its minimum version.

The feature-detection shim avoids touching the deprecated constants on current Home Assistant versions without dropping support for older installations.

Fixes #1849.

Validation

  • full test suite on Home Assistant 2026.8.0b2 / Python 3.14: 94 passed
  • fresh Sonoff sensor import on Home Assistant 2026.8.0b2 with no concentration deprecation warning
  • legacy and current import paths exercised independently
  • changed files parsed successfully using the Python 3.10 grammar required by Home Assistant 2023.2

@hmmbob
hmmbob marked this pull request as ready for review July 31, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HA 2026.8.0 beta deprecation warning on concentration

1 participant