Commit Graph

53 Commits

Author SHA1 Message Date
Franck Nijhof
fb0cb7cad6 Add Wh/km unit for energy distance (#145243) 2025-05-20 12:16:27 +01:00
alorente
1d47dc41c9 Add reactive energy device class and units (#143941) 2025-05-15 12:05:46 +01:00
Michael
3405b2549b Add new units L/h , L/s and m³/s to volume flow rate sensor device class (#143625)
add new units L/h , L/s and m³/s
2025-04-25 00:17:47 +02:00
J. Nick Koston
e2c050ed40 Cache sensor precision calculation (#140019) 2025-03-07 16:14:22 -10:00
Jakob Schlyter
84ae476b67 Energy distance units (#136933)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
2025-01-31 14:22:25 +00:00
Lukas Schlötterer
7b63c17101 Add kV and MV unit conversion for voltages (#135396) 2025-01-13 13:00:35 +01:00
Stefan Agner
962f1bad32 Add mW as unit of measurement for Matter electrical power sensors (#133504) 2024-12-19 11:40:05 +00:00
Stefan Agner
9ab69aa41c Add mWh as unit of measurement for Matter energy sensors (#133005) 2024-12-13 09:33:58 +01:00
Josef Zweck
3cfd958dc2 Allow mL/s as UnitOfVolumeFlowRate (#130771) 2024-11-21 20:47:24 +01:00
Michael Arthur
d8549409f7 Area units and conversion between metric and US (#123563)
* area conversions

* start work on tests

* add number device class

* update unit conversions to utilise distance constants

* add area unit

* update test unit system

* update device condition and trigger

* update statistic unit converters

* further tests work WIP

* update test unit system

* add missing string translations

* fix websocket tests

* add deprecated notice

* add more missing strings and missing initialisation of unit system

* adjust icon and remove strings from scrape and random

* Fix acre to meters conversion

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Tidy up valid units

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* fix ordering of area

* update order alphabetically

* fix broken test

* update test_init

* Update homeassistant/const.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* remove deprecated unit and fix alphabetical order

* change deprecation and add tests, change to millimeter conversion for inches

* fix order

* re-order defs alphabetically

* add measurement as well

* update icons

* fix up Deprecation of area square meters

* Update core integrations to UnitOfArea

* update test recorder tests

* unit system tests in alphabetical

* update snapshot

* rebuild

* revert alphabetization of functions

* other revert of alphabetical order

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2024-11-21 16:10:44 +01:00
Manu
397a299f15 Add µV as UnitOfElectricPotential (#130838) 2024-11-19 22:38:22 +01:00
mrspouse
5c52e865a0 Correct spelling of BloodGlucoseConcentrationConverter (#130449)
* Correct spelling of BloodGlucoseConcentrationConverter

* Correct spelling of BloodGlucoseConcentrationConverter
2024-11-12 21:48:42 +01:00
epenet
25fb70f281 Add blood glucose concentration device class (#129340) 2024-11-09 11:29:24 +01:00
Jakob Schlyter
cd11f01ace Add support for MW/GW/TW and GWh/TWh (#130089) 2024-11-08 22:12:16 +01:00
Erik Montnemery
0956dbb578 Rename UnitOfConductivity enum members (#127919)
* Rename UnitOfConductivity enum members

* Update test snapshots
2024-10-08 14:44:01 +02:00
Michael
ffa6b5fcb2 Use two words for Nautical miles unit (#126905) 2024-09-27 13:16:13 +02:00
Michael
26b5dab12b Add nmi (nautical miles) as valid distance unit (#124723) 2024-09-27 10:40:59 +02:00
Trevor Schirmer
96b7fc9a75 Add mm/s and in/s As Unit Of Speed (#125044)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-22 09:01:46 -05:00
Sergey Dudanov
dcd7830a35 Add calories to energy sensor device class (#122796)
* added calories to energy class

* changes

* temporarily solving the problem with conversion accuracy

* add tests

* added calories to energy class

* changes

* add tests

* Update homeassistant/util/unit_conversion.py

Co-authored-by: Robert Resch <robert@resch.dev>

* Update homeassistant/util/unit_conversion.py

Co-authored-by: Robert Resch <robert@resch.dev>

* apply suggestions

* Update homeassistant/util/unit_conversion.py

---------

Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-09-10 12:22:15 +02:00
dontinelli
0dd5391cd7 Add Siemes and Millisiemens as additional units of conductivity and enable conversion between conductivity units (#118728) 2024-06-21 11:10:15 +02:00
Marc Mueller
19ab3d6daf Add empty line after module docstring [helpers + other] (#112707) 2024-03-08 10:36:11 -05:00
fwestenberg
385b29bdf5 Add Beaufort to wind_speed (#105795)
* Add Beaufort to wind_speed

* Add Bft to UnitOfSpeed

* Update tests with Bft

* Remove check for unit

* Fix test_deprecated_constants

* Test depricated constant Beaufort

* Fix test_unit_system.py for Beaufort

* Remove _DEPRECATED_SPEED_FEET_BEAUFORT

* Remove maxsize from lru_cache

* Update test_deprecated_constants

* Update comment

* Add missing docstring

* Apply suggestions from code review

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-03-05 14:55:59 +01:00
Robert Resch
b409933d19 Add DurationConverter (#108865)
* Add DurationConverter

* Update withings snapshots

* Add sensor test

* Fix tests

* Update snapshots after #108902 was merged
2024-01-30 23:08:12 +01:00
Joakim Plate
cece117c93 Flow rate unit conversions and device class (#106077)
* Add volume flow rate conversions

* Add missing translations

* Adjust liter unit and add gallons per minute

* Adjust to min instead of m for minutes

* Add matching class for number

* Add some tests for number and sensor platform

* Add deprecated constants

* Add explicit list of flow rate for check

This reverts commit 105171af31.
2024-01-30 15:01:08 +01:00
Dave T
a4a99ce957 Remove deprecated volume conversion functions (#101200) 2023-10-01 16:06:14 +02:00
J. Nick Koston
2f1f32f0bb Make unit converter use a factory to avoid looking up the ratios each conversion (#93706) 2023-05-29 20:50:40 +02:00
Erik Montnemery
9a70f47049 Teach UnitlessRatioConverter about ppm and ppb (#92989) 2023-05-12 16:46:37 +02:00
Franck Nijhof
ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
SgtBatten
0ccab19d2c Add Mega Joule as valid unit of energy (#86055)
* Add Mega joule

* Reorder valid energy types

Alphabetical

* Add Mega Joule

* Add Mega Joule as valid energy unit

* Add Mega Joule

* Add Mega Joule as a Unit of Measurement to Energy

* Update tests

* Update tests

* Update number docstring

Co-authored-by: Roving Ronin <108674933+Roving-Ronin@users.noreply.github.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2023-01-25 14:13:42 +01:00
epenet
64535175b1 Add missing conversion tests in unit conversion (#86434) 2023-01-23 10:11:11 +01:00
epenet
e1fc494b54 Add missing ratio test cases in unit conversion (#86340)
* Add missing ratio test cases in unit conversion

* Improve ratio test to check inverse
2023-01-22 16:39:45 +01:00
epenet
e8d19e7c62 Ensure all unit converters are tested (#86271)
* Ensure all unit converters are tested

* Adjust

* Simplify

* Simplify

* docstring
2023-01-21 13:11:13 +01:00
SukramJ
005bc8994d Add mA to SensorDeviceClass.CURRENT units (#84492)
fixes undefined
2022-12-30 13:55:14 +01:00
epenet
f68a7636c5 Cleanup pytest.approx in unit conversion tests (#84810) 2022-12-30 10:16:20 +01:00
epenet
6261994fcf Enable unit conversion for DATA_SIZE (#84699) 2022-12-29 09:58:15 +01:00
epenet
46e02ebaff Enable unit conversion for DATA_RATE (#84698) 2022-12-28 21:49:00 +01:00
epenet
f4c13645d2 Add support for CCF volume unit (#84029) 2022-12-19 14:57:04 +01:00
epenet
4a848e8222 Add stones to mass units (#83933) 2022-12-13 17:35:14 +01:00
epenet
2a2e097e17 Use unit enums in unit utilities (#81030) 2022-10-26 20:47:17 +02:00
epenet
842cb18d39 Migrate energy units to an enum (#80998) 2022-10-26 13:56:51 +02:00
epenet
7838bb3ebe Replace new PRECIPITATION_INTENSITY with enum (#80653) 2022-10-25 16:45:45 +02:00
Erik Montnemery
727eccfec4 Add GJ as supported unit for energy sensors (#80870)
* Add GJ as supported unit for energy sensors

* Update homeassistant/const.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-25 16:43:00 +02:00
epenet
9afb4c6c9e Adjust precipitation units (#79780)
* Adjust precipitation units

* Use PRECIPITATION_INTENSITY

* Revert isy994

* Adjust SensorDeviceClass docstring

* Adjust comment
2022-10-19 14:35:49 +02:00
epenet
aa0bb9c3d2 Improve precision in pressure conversion (#79362)
* Improve precision in pressure conversion

* Use _STANDARD_GRAVITY

* Add again pytest.approx
2022-10-06 12:48:31 +02:00
epenet
825f9502ad Align temperature conversion with other converters (#79521)
* Align temperature conversion with other converters

* Add comments and docstring

* Align tests
2022-10-03 10:09:55 +02:00
epenet
5438552d4a Cleanup unit conversion (#79197)
* Move UNIT_RATIO to BaseUnitConverter

* Make UNIT_CONVERSION private

* Remove STATISTIC_UNIT_TO_UNIT_CLASS constant

* Cleanup websocket_api

* Imrpove valid_units check
2022-09-28 13:49:46 +02:00
epenet
5389ff3253 Add new weight device class (#79185) 2022-09-28 12:13:49 +02:00
epenet
c96c5bed7d Remove argument validation in Unit Converter (#79107)
* Remove argument validation in Unit Converter

* Use HomeAssistantError

* Adjust tests

* Improve coverage
2022-09-28 10:58:04 +02:00
epenet
4200778eaf Move distance and speed util to unit_conversion (#78967) 2022-09-23 08:23:59 -04:00
epenet
ddf56baf7a Move temperature utility to unit_conversion (#78960) 2022-09-22 18:31:50 +02:00