propagate status of input sensors - #457
Open
dewi-ny-je wants to merge 39 commits into
Open
Conversation
…tion-in-integration Propagate source unknown/unavailable states to derived sensors
Home Assistant deprecated `FlowHandler.show_advanced_options` in Core 2026.6: it now always returns True, logs a deprecation warning on every access, and is removed in 2027.6. User profile advanced mode is going away, so a data entry flow can no longer tell advanced users apart. Show the poll, scan interval, custom icons and enabled sensors options to everyone, and always offer the wider entity list in the temperature and humidity pickers, keeping entities with a matching device class first. Without it, sensors that carry no device class could not be selected by anyone. The `no_sensors_advanced` abort reason is therefore unreachable and is merged into `no_sensors`, which takes over its wording in every translation. Raise the minimum supported Home Assistant to 2026.6.0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYoDyQh9qU1KcnSohNSpex
Home Assistant Core 2026.7 introduced the `UnitOfDensity` and `UnitOfRatio` enumerators, which replace the `CONCENTRATION_*` constants. Declare the absolute humidity unit through `UnitOfDensity.GRAMS_PER_CUBIC_METER` instead of a bare string. The value is unchanged, so no entity is affected. The enumerators spell the micro prefix as U+03BC while the constants they replace used U+00B5, so the config flow now excludes both spellings of the microgram concentration units. Without it, a sensor reporting the new spelling would show up among the selectable source entities. This requires Home Assistant 2026.7, so raise the minimum and move the pytest matrix to Python 3.14, which the supported Home Assistant versions require. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYoDyQh9qU1KcnSohNSpex
Use the unit enumerators for density and ratio units
This reverts commit d89724c.
Local brand images
Add a release workflow that works out the next version from the commits since the most recent release tag, following Conventional Commits: a `!` marker or a `BREAKING CHANGE:` footer bumps the major, `feat` bumps the minor and everything else bumps the patch. Merge commits are ignored. It publishes the tag, the release and the notes, and can be started by hand to override the bump or to do a dry run. The archive workflow becomes reusable so the release workflow can attach the zip itself. A release created with GITHUB_TOKEN does not trigger the `release` event, so relying on that trigger alone would leave the release without the archive HACS expects. It keeps the `release` trigger for releases published by hand, and now resolves the package directory without tripping over `__pycache__` and uploads through the gh CLI, so the tag is correct on both paths. The other workflows gain `workflow_dispatch`, `concurrency` groups and an empty top level `permissions` with the minimum granted per job, and move to the current action versions. `no-commit-to-branch` is skipped in CI, where it has no local branch to guard. Dependabot keeps the actions and the test requirements up to date. Also fix the two checks that were already failing on master: three unused imports in the config flow tests, a comment black wanted to reformat and the formatting of the inlang settings. The gitignore grows the usual Python, pytest, coverage and editor entries, and `.github/scripts` is allowed to write to stdout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYoDyQh9qU1KcnSohNSpex
…lity-45ia3h ci: automate releases and tighten the workflows
Update manifest.json with new codeowners and links
Delete custom_components/__init__.py
Remove unnecessary fields from hacs.json
`hacs.json` no longer sets `zip_release`, so HACS takes the other download path: `download_repository_zip()` fetches the source archive of the tagged commit and extracts the integration directory as committed. The zip asset it used to read, the only place the release workflow wrote the version, is no longer looked at. The version the integration reports to Home Assistant is therefore whatever `manifest.json` holds at the tagged commit, which would stay at 2.3.0 for every future release. Write the version into the manifest, commit it and tag that commit instead. The push uses GITHUB_TOKEN, which does not start another workflow run, so this cannot loop. Since the manifest now tracks the released version, it also serves as the baseline when the repository has no release tag yet, which removes the need to seed one by hand. A tag still wins when there is one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYoDyQh9qU1KcnSohNSpex
…ility-45ia3h fix(ci): commit the release version to the manifest
Three independent causes made the whole suite fail (27 failed, 3 passed): 1. The tests build their source sensors with the command_line integration, which declares a jsonpath requirement in its manifest. Home Assistant installs integration requirements at runtime, but the test harness only ships core's dependencies, so command_line.sensor could not be imported and neither source sensor existed. Everything downstream then saw no temperature or humidity: 15 entities instead of 17, every computed value "unknown", missing extra attributes, and a config flow that aborted with no_sensors because it found no candidate sensors. Install the requirement explicitly. 2. async_migrate_entry assigned config_entry.version directly, which Home Assistant now rejects with "version cannot be changed directly, use async_update_entry instead". Migration raised, so entry setup failed. 3. Source unknown/unavailable states were propagated by writing the literal state string into the native value. Home Assistant rejects that for both numeric and enum sensors, and because the ValueError is raised inside _async_write_ha_state the write is aborted and the entity keeps its stale value. Express unavailable through the entity's availability and unknown through a None native value instead, and stop reporting the source readings as attributes while no value can be computed. Beyond the tests, the third fix also stops error spam and stale readings in real installations whenever a source sensor drops out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012gHfwGR2qDjfhvCWW9RDX6
The tests built their temperature and humidity sources with the command_line integration, which pulled in a jsonpath requirement the test harness does not install, and which ran a subprocess per sensor to produce a constant. Set the source states on the state machine instead: the tests already drove every subsequent reading that way. start_ha now seeds a source_states mapping before setting up the domains, so a test declares its readings alongside its config. Tests that deliberately run without sources simply omit it, and the two that did so keep their entity counts unchanged. Drops the jsonpath-python pin added for the previous workflow fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012gHfwGR2qDjfhvCWW9RDX6
test_sensor.py carried four helpers named get_sensor_* that pytest never collected, so their assertions had not run in a long time. Rename them to test_* and repair what had gone stale in the meantime: - test_sensor_unknown's config predated unique_id becoming a required key, so setting the integration up from it failed outright. - It also seeded NaN readings, which made it a copy of test_sensor_is_nan despite its name. Give it unknown source states so the pair covers both paths. Checked that neither test passes vacuously: feeding both valid readings instead fails them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012gHfwGR2qDjfhvCWW9RDX6
…tion-514d72 fix: repair the pytest workflow failures
Removed push trigger for master branch from release workflow.
The pre-commit workflow runs the hooks over the whole tree, so both of these failed it regardless of what a pull request touched: - codespell: "lastest" in the bug report issue template. - prettier: the codeowners array in manifest.json fits on one line. Reformatted by prettier 2.7.1 itself, the version the hook pins. Verified by running both hooks the way pre-commit invokes them, over every tracked file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012gHfwGR2qDjfhvCWW9RDX6
chore: fix the two pre-commit hook failures
Fixes the issues found while reviewing PR #12, plus the two Sourcery comments. Correctness: - Fix the expected states in the new enthalpy tests. Home Assistant stringifies float states with 15 significant digits, so the values taken from Python's repr never matched. The arithmetic was correct. - Sort the homeassistant.const import block, which tripped ruff I001. - Persist a cleared pressure sensor as an explicit None. voluptuous drops absent vol.Optional keys and get_value() falls back to config_entry.data, so the sensor could be set but never unset. - Offer atmospheric_pressure sensors in the config flow. That is the device class weather integrations and ESPHome BME/BMP sensors use, and the generic exclusion filters, written for the temperature and humidity pickers, dropped every entity carrying a pressure unit. - Reset a stale pressure reading when the sensor becomes unavailable or reports outside 300 - 1100 hPa, so the elevation fallback takes over instead of pinning the last good value. Log the discarded reading. - Guard PressureConverter.convert, which raises HomeAssistantError for an unrecognised unit, inside the state change listener. - Report the first error in check_input instead of letting a later check overwrite an earlier one. Tests: - Cover unit conversion, an unavailable sensor, an out of range reading and an unsupported unit, plus config flow coverage for clearing the sensor, the pressure_not_found error and the picker contents. - Let source_states carry attributes so a source entity can be seeded with a device class and a unit of measurement. - Restore hass.config.elevation after the elevation test. Documentation and translations: - Document the option in yaml.md, config_flow.md and sensors.md, including the caveat that a mean sea level pressure sensor is less accurate than the elevation fallback. - Add the strings to the remaining 24 translations and drop the "(optional)" suffix from the label. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018X8YgHmgHEph3NK6atYBVZ
- Make the pressure range bounds inclusive. The constant names and the documentation both describe 300 - 1100 hPa as the accepted range, while the check excluded the bounds themselves. Add a test pinning it. - Drive normalize_optional_entities from OPTIONAL_ENTITY_KEYS so adding another optional entity selector cannot silently miss normalization. - Fix a pre-existing double period in the yaml.md humidity_sensor entry. Not applied: reading native_unit_of_measurement alongside unit_of_measurement in _new_pressure_state. That key never reaches state.attributes, and the state value is expressed in the converted unit_of_measurement rather than the native one, so the fallback would misread any entity whose display unit differs from its native unit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018X8YgHmgHEph3NK6atYBVZ
…eview-em6alg Add optional atmospheric pressure sensor support
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.
No description provided.