Repository navigation
Fix wrong units in the BACnet engineering units map - #1061
Open
zigpy-review-bot wants to merge 1 commit into
Open
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
Several BACnet engineering units were mapped to a different unit than the one they name, so analog output numbers and analog input sensors showed values from such devices with the wrong unit: - BTUs (energy) as BTU/h (power) - tons as stones - degrees-angular as rpm - BTUs-per-pound as calories - liters-per-hour as L/min - kilowatt-hours-per-square-meter/foot as km/kWh and mi/kWh - millimeters-per-second as mm - decibels-millivolt as dBm, decibels-volt as dB - ampere-square-hours as A·h Map each of them to the unit it names.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1061 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 61 61
Lines 10870 10870
=======================================
Hits 10597 10597
Misses 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Severity: low (the audit's estimate)
Eleven entries of
BACNET_UNITS_TO_HA_UNITSnamed a different unit than the BACnet engineering unit they stand for, so analog output numbers, and analog input sensors without an application type, showed values from devices using these units with the wrong unit (liters per hour as L/min, tons as stones, BTUs as BTU/h, degrees-angular as rpm, …). This maps each of them to the unit it names.Changes
zha/application/platforms/number/bacnet.py:"BTU""ton"DEGREE"BTU/lb"UnitOfVolumeFlowRate.LITERS_PER_HOUR"kWh/m²"and"kWh/ft²"UnitOfSpeed.MILLIMETERS_PER_SECOND"dBmV"and"dBV""A²·h"Microsiemens (190) and millisiemens (202), which name conductance, still map to the conductivity units µS/cm and mS/cm: devices may use these ids for conductivity readings (BACnet has no µS/cm), so that is left for a maintainer to decide. Tons (41) now shows the same
tonas tons-refrigeration (52), a power unit; a maintainer may prefer a distinct string for one of them.An existing analog input sensor on one of these units changes its unit with this fix. Except for L/min → L/h, which Home Assistant converts, its long-term statistics then get a "units changed" statistics issue once, as for any unit change of a sensor with a state class.
Testing
test_number_engineering_units, parametrized over the eleven units, joins an analog output device with thatengineering_unitsvalue and checks the entity's unit. All eleven cases fail at 2da1a5b and pass with the fix.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1060