mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
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>
This commit is contained in:
@@ -30,6 +30,7 @@ from homeassistant.const import (
|
||||
PERCENTAGE,
|
||||
STATE_UNKNOWN,
|
||||
EntityCategory,
|
||||
UnitOfArea,
|
||||
UnitOfDataRate,
|
||||
UnitOfEnergy,
|
||||
UnitOfLength,
|
||||
@@ -651,6 +652,34 @@ async def test_custom_unit(
|
||||
"device_class",
|
||||
),
|
||||
[
|
||||
# Area
|
||||
(
|
||||
UnitOfArea.SQUARE_KILOMETERS,
|
||||
UnitOfArea.SQUARE_MILES,
|
||||
UnitOfArea.SQUARE_MILES,
|
||||
1000,
|
||||
"1000",
|
||||
"386",
|
||||
SensorDeviceClass.AREA,
|
||||
),
|
||||
(
|
||||
UnitOfArea.SQUARE_CENTIMETERS,
|
||||
UnitOfArea.SQUARE_INCHES,
|
||||
UnitOfArea.SQUARE_INCHES,
|
||||
7.24,
|
||||
"7.24",
|
||||
"1.12",
|
||||
SensorDeviceClass.AREA,
|
||||
),
|
||||
(
|
||||
UnitOfArea.SQUARE_KILOMETERS,
|
||||
"peer_distance",
|
||||
UnitOfArea.SQUARE_KILOMETERS,
|
||||
1000,
|
||||
"1000",
|
||||
"1000",
|
||||
SensorDeviceClass.AREA,
|
||||
),
|
||||
# Distance
|
||||
(
|
||||
UnitOfLength.KILOMETERS,
|
||||
@@ -1834,6 +1863,7 @@ async def test_non_numeric_device_class_with_unit_of_measurement(
|
||||
[
|
||||
SensorDeviceClass.APPARENT_POWER,
|
||||
SensorDeviceClass.AQI,
|
||||
SensorDeviceClass.AREA,
|
||||
SensorDeviceClass.ATMOSPHERIC_PRESSURE,
|
||||
SensorDeviceClass.BATTERY,
|
||||
SensorDeviceClass.CO,
|
||||
|
||||
Reference in New Issue
Block a user