Repository navigation
Refuse to load on Home Assistant older than 2026.8.0 with a clear error - #1619
Open
IDavinciCode wants to merge 1 commit into
Open
IDavinciCode wants to merge 1 commit into
IDavinciCode wants to merge 1 commit into
Conversation
hacs.json declares 2026.8.0 as the minimum, but nothing in the integration enforces it. On an older Home Assistant the first thing a user sees is a raw ImportError for UnitOfDensity from const.py (or an AttributeError for async_get_device_by_identifier), with no hint that the version is the problem. Check the running version in __init__.py before the local imports and raise one ImportError that names the required version, the running version and both remedies. The floor is a constant kept equal to hacs.json, and a test asserts the two agree. Fixes custom-components#1613 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1613
hacs.json declares Home Assistant 2026.8.0 as the minimum, but nothing in the integration enforces it. On an older Home Assistant the first error a user sees is a raw
ImportError: cannot import name 'UnitOfDensity'from const.py (or an AttributeError forasync_get_device_by_identifier), with no hint that the version is the problem.This adds the guard proposed in the issue:
MIN_HA_VERSION = "2026.8.0"in__init__.py, checked after thehomeassistant.*imports and before the local imports (which pull in const.py). On an older version it raises one ImportError that names the required version, the running version and both remedies. Importing the config flow runs the package__init__first, so the same check covers it.Before, with Home Assistant reporting 2026.1.3 and UnitOfDensity absent:
ImportError: cannot import name 'UnitOfDensity' from 'homeassistant.const'
After:
ImportError: Passive BLE Monitor requires Home Assistant 2026.8.0 or newer, but this instance runs 2026.1.3. Update Home Assistant, or install a ble_monitor release that supports 2026.1.3.
Tests: test/test_ha_version.py checks that an older version is refused with both versions in the message, that 2026.8.0 and newer (including a beta) load, and that MIN_HA_VERSION equals the minimum in hacs.json, so the two cannot drift apart. The full suite passes apart from test_obj3003_timestamps_are_utc, which fails the same way on master on my Windows machine (time zone). isort and codespell are clean.
🤖 Generated with Claude Code