Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

fix(sensor): use UnitOfVolumeFlowRate enum for UOMs 130, 143, 144#122

Merged
shbatm merged 1 commit into
devfrom
core-parity/sensor-uom-volumeflowrate
May 7, 2026
Merged

fix(sensor): use UnitOfVolumeFlowRate enum for UOMs 130, 143, 144#122
shbatm merged 1 commit into
devfrom
core-parity/sensor-uom-volumeflowrate

Conversation

@shbatm

@shbatm shbatm commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Swap string literals ("L/h" f-string, "gpm", "gph") for UnitOfVolumeFlowRate.LITERS_PER_HOUR / GALLONS_PER_MINUTE / GALLONS_PER_HOUR in UOM_FRIENDLY_NAME entries 130/143/144.
  • Restores VOLUME_FLOW_RATE device class (and the derived state_class) for sensors with these UOMs.

Why

sensor.py:_check_volume_flow_rate_uom validates the unit via UOM_FRIENDLY_NAME.get(uom) in UnitOfVolumeFlowRate. The in check on a StrEnum matches enum members, not values, so the literals failed and the device class was stripped to None. Mirrors the equivalent fix in core PR home-assistant/core#169017.

Test plan

  • Devcontainer: load the integration against a controller exposing a UOM 130/143/144 sensor and confirm the entity reports device_class: volume_flow_rate and a non-null state_class.
  • pre-commit run --all-files clean.
  • (Follow-up PR) snapshot tests once test_sensor.py is migrated.

🤖 Generated with Claude Code

UOM_FRIENDLY_NAME entries 130/143/144 stored string literals
("L/h", "gpm", "gph") which fail _check_volume_flow_rate_uom's
`UOM_FRIENDLY_NAME.get(uom) in UnitOfVolumeFlowRate` check — the
StrEnum `in` test matches enum members, not values. Result:
sensors with these UOMs had VOLUME_FLOW_RATE device_class
stripped to None and consequently no state_class.

Switching to UnitOfVolumeFlowRate.LITERS_PER_HOUR /
GALLONS_PER_MINUTE / GALLONS_PER_HOUR matches the fix that
landed in core PR #169017.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shbatm
shbatm merged commit 72c449e into dev May 7, 2026
2 checks passed
@shbatm
shbatm deleted the core-parity/sensor-uom-volumeflowrate branch May 7, 2026 14:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant