Commit Graph

28 Commits (87ecdfb84f97ee36fb3710588be4b66910b954b7)

Author SHA1 Message Date
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
epenet c8491c4404
Move volume utility to unit_conversion (#78955)
* Move volume utility to unit_conversion

* Split tests
2022-09-22 17:49:45 +02:00
epenet 523d8d246b
Move pressure utility to unit_conversion (#78953) 2022-09-22 16:44:09 +02:00
epenet 0767cdd935
Move energy and power utilites to unit_conversion (#78950)
* Move energy and power utilites to unit_conversion

* Move tests
2022-09-22 15:39:49 +02:00