1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-07 23:49:17 +00:00

62 Commits

Author SHA1 Message Date
Shay Levy
32a16ae0f0
Make UnitSystem a frozen dataclass ()
* Make UnitSystem a frozen dataclass

* Use super() for attribute setting in UnitSystem class
2025-03-25 11:45:54 +01:00
G Johansson
8cde404997
Raise issue for deprecated imperial unit system () 2024-12-13 10:05:46 +01:00
Michael Arthur
d8549409f7
Area units and conversion between metric and US ()
* 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
Michael
ffa6b5fcb2
Use two words for Nautical miles unit () 2024-09-27 13:16:13 +02:00
Michael
26b5dab12b
Add nmi (nautical miles) as valid distance unit () 2024-09-27 10:40:59 +02:00
Trevor Schirmer
96b7fc9a75
Add mm/s and in/s As Unit Of Speed ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-09-22 09:01:46 -05:00
J. Nick Koston
0a11acf7ae
Replace linear search in unit_system with dict lookup () 2024-09-07 23:49:44 -04:00
Marc Mueller
19ab3d6daf
Add empty line after module docstring [helpers + other] () 2024-03-08 10:36:11 -05:00
Erik Montnemery
ead88cc3f8
Add preferred wind speed unit to unit systems ()
* Add preferred wind speed unit to unit systems

* Tweak

* Update tests
2023-03-30 12:54:12 +02:00
Erik Montnemery
45ac8c515e
Update unit system unit conversions ()
* Update unit system unit conversions

* Tweak tests
2023-02-08 10:52:54 +01:00
Erik Montnemery
4cecc28f8c
Update unit system unit conversions () 2023-02-07 13:19:11 +01:00
epenet
561fc2d771
Remove deprecated unit system properties ()
* Remove deprecated unit system properties

* Fix tests
2023-01-27 12:09:26 +01:00
Franck Nijhof
7adb8d5ddc
Code styling tweaks to core utils & YAML loader ()
Code styling tweaks to core utils
2023-01-08 22:01:55 -08:00
Franck Nijhof
d4f69a3652
String formatting and max line length - Part 7 ()
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-12-27 11:18:56 +01:00
epenet
583b4aef07
Enable automatic conversion for pressures ()
* Enable automatic conversion between bar and psi

* Fix tests

* Fix mazda tests

* Fix oncue tests

* Adjust US pressures

* Adjust metric pressures

* Adjust tests

* Adjust tests
2022-12-12 12:42:35 +01:00
epenet
b172abaeeb
Add new atmospheric pressure device class ()
* Add new atmospheric pressure device class

* Translations

* Automatic conversion

* Convert all pressure units
2022-12-09 08:02:53 +01:00
epenet
91d6d620c2
Use new unit enums in alexa ()
* Use new unit enums in alexa

* Adjust for mypy
2022-12-06 17:31:40 +01:00
epenet
4ad9633dfb
Use new unit enums in weather entity () 2022-11-29 18:10:31 +01:00
epenet
dd960c4e62
Add precipitation device class () 2022-11-18 12:41:33 +01:00
epenet
2a2e097e17
Use unit enums in unit utilities () 2022-10-26 20:47:17 +02:00
Erik Montnemery
352976fd1d
Add rules for converting volumes ()
* Add rules for converting volumes

* Use SensorDeviceClass in new tests

* Tweak tests

* Update flo tests

* Update sensor tests
2022-10-26 10:29:33 +02:00
epenet
0018939142
Adjust unit_system type hints () 2022-10-25 15:56:18 +02:00
Erik Montnemery
b07e1281da
Add rules for converting speeds ()
* Add rules for converting speeds

* Update metoffice wind speed sensors to prefer mph

* Don't convert speeds measured in knots
2022-10-25 14:53:59 +02:00
Erik Montnemery
aea0067e49
Add additional rules for converting distances ()
* Add additional rules for converting distances

* Convert in to mm

* Adjust existing tests

* Add test
2022-10-25 12:51:23 +02:00
Erik Montnemery
6979cd95b0
Add suggested_unit_of_measurement attribute to sensors ()
* Add suggested_unit_of_measurement attribute to sensors

* Lazy calculation of initial entity options

* Add type alias for entity options

* Small tweak

* Add tests

* Store suggested_unit_of_measurement in its own option key

* Adapt to renaming of IMPERIAL_SYSTEM

* Fix rebase mistakes

* Apply suggestions from code review

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

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
2022-10-24 16:08:02 +02:00
epenet
8a1cc05e0c
Enforce kwargs in unit system initialisation ()
* Enforce kwargs in unit system initialisation

* Fix tests

* Sort kwargs in unit_system
2022-10-20 10:43:32 +02:00
epenet
67d1dde69f
Rename IMPERIAL_SYSTEM to US_CUSTOMARY_SYSTEM ()
* Rename IMPERIAL_SYSTEM

* Deprecate is_metric property and adjust tests

* Adjust unit_system config validation

* Add yaml tests

* Add tests for private name

* Fix incorrect rebase

* Adjust docstring

* Add store migration

* Update unit_system.py

* Minimise test tweaks

* Fix tests

* Add conversion to migration

* Rename new key and adjust tests

* Adjust websocket_detect_config

* Move original_unit_system tracking to subclass
2022-10-19 13:31:08 +02:00
epenet
bff5d1123f
Deprecate CONF_UNIT_SYSTEM_*** constants ()
* Deprecate CONF_UNIT_SYSTEM_*** constants

* Adjust pylint plugin

* Add tests

* Remove single-use function

* Revert logic change

* Revert "Revert logic change"

This reverts commit 60959a0050fbf5205e8e7d89654f4011256968d8.

* Tweak again
2022-10-14 16:50:04 +02:00
epenet
6a757662e4
Deprecate is_metric property of unit system () 2022-10-14 13:44:18 +02:00
epenet
4dd0c079d5
Deprecate name property of unit system () 2022-10-14 12:06:14 +02:00
epenet
253647aaa9
Use unit_conversion in unit_system utility () 2022-09-28 14:37:22 +02:00
epenet
dc82ae4f69
Make VALID_UNITS a set ()
* Make VALID_UNITS a set

* Also adjust weather
2022-09-27 07:16:03 +01:00
epenet
9692cdaf2d
Make _is_valid_unit private in unit system () 2022-09-22 21:02:31 +02:00
Marc Mueller
0188e8b319
Add type ignore error codes [util] () 2022-02-18 11:30:59 +01:00
Marc Mueller
240c9979c7
Move disallow-any-generics to mypy.ini () 2022-01-11 13:33:25 -08:00
Ruslan Sayfutdinov
55f4962c06
Fix pylint plugin which checks relative imports () 2021-12-23 11:14:47 -08:00
rianadon
ecf00a1eae
Add accumulated precipitation to unit system ()
* Add accumulated precipitation to unit system

* Fix template test

* Fix typo of testing pressure instead of precipitation

* Add extra arguments so unit system test passes
2021-11-19 09:18:44 +01:00
rianadon
7cc7bbb76d
Add speed to units system ()
* Use speed units in unit system

* Use more obvious conversion factor for unit system speed test

* Use wind_speed instead of speed, use m/s
2021-11-18 16:08:42 +01:00
Marc Mueller
a56485a8c5
Revert new unit types () 2021-07-20 14:13:51 +02:00
Marc Mueller
f6b162bc39
Add pylint CodeStyle extension () 2021-07-19 06:57:06 -07:00
Marc Mueller
71a8ae3016
Add new unit types for better type checking ()
* Add new unit types
* Update helper functions
* Update components
* Update lcn climate
2021-07-18 14:43:47 +02:00
Marc Mueller
fabd73f08b
Update typing 03 () 2021-03-17 21:46:07 +01:00
Ville Skyttä
94dbcc9d2b
Generics and other type hint improvements () 2021-01-18 22:23:25 +01:00
Philip Allgaier
dde6305549
Cleanup unused loggers (components N-Z + tests) () 2020-10-16 21:24:08 -05:00
Franck Nijhof
1c2ebdf307
Upgrade black to 20.8b1 () 2020-08-27 13:56:20 +02:00
Ville Skyttä
221d5205e4
Upgrade mypy to 0.770, tighten config a bit ()
* Upgrade mypy to 0.770, related cleanups

https://mypy-lang.blogspot.com/2020/03/mypy-0770-released.html

* Clean up config and make it a notch stricter, address findings
2020-03-12 11:52:20 +01:00
Ville Skyttä
fa4fa30461 Various string cleanups ()
* Remove some unnecessary string concatenations

* Replace some simple str.formats with f-strings

* Replace some string concatenations with f-strings
2020-01-03 14:47:06 +01:00
Bas Nijholt
67c56c860d Sort imports according to PEP8 for 'homeassistant' folder ()
Components are already done
2019-12-09 16:42:10 +01:00
Franck Nijhof
2f0eb07624 Migrate legacy typehints in core to PEP-526 ()
* Migrate legacy typehints in core to PEP-526

* Fix one type
2019-09-03 20:36:04 -07:00
Paulus Schoutsen
620cb74050 Type 2019-07-31 13:08:31 -07:00