mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Add Wh/km unit for energy distance (#145243)
This commit is contained in:
parent
a3c0b83dee
commit
fb0cb7cad6
@ -176,7 +176,7 @@ class NumberDeviceClass(StrEnum):
|
||||
Use this device class for sensors measuring energy by distance, for example the amount
|
||||
of electric energy consumed by an electric car.
|
||||
|
||||
Unit of measurement: `kWh/100km`, `mi/kWh`, `km/kWh`
|
||||
Unit of measurement: `kWh/100km`, `Wh/km`, `mi/kWh`, `km/kWh`
|
||||
"""
|
||||
|
||||
ENERGY_STORAGE = "energy_storage"
|
||||
|
@ -205,7 +205,7 @@ class SensorDeviceClass(StrEnum):
|
||||
Use this device class for sensors measuring energy by distance, for example the amount
|
||||
of electric energy consumed by an electric car.
|
||||
|
||||
Unit of measurement: `kWh/100km`, `mi/kWh`, `km/kWh`
|
||||
Unit of measurement: `kWh/100km`, `Wh/km`, `mi/kWh`, `km/kWh`
|
||||
"""
|
||||
|
||||
ENERGY_STORAGE = "energy_storage"
|
||||
|
@ -647,6 +647,7 @@ class UnitOfEnergyDistance(StrEnum):
|
||||
"""Energy Distance units."""
|
||||
|
||||
KILO_WATT_HOUR_PER_100_KM = "kWh/100km"
|
||||
WATT_HOUR_PER_KM = "Wh/km"
|
||||
MILES_PER_KILO_WATT_HOUR = "mi/kWh"
|
||||
KM_PER_KILO_WATT_HOUR = "km/kWh"
|
||||
|
||||
|
@ -313,6 +313,7 @@ class EnergyDistanceConverter(BaseUnitConverter):
|
||||
UNIT_CLASS = "energy_distance"
|
||||
_UNIT_CONVERSION: dict[str | None, float] = {
|
||||
UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM: 1,
|
||||
UnitOfEnergyDistance.WATT_HOUR_PER_KM: 10,
|
||||
UnitOfEnergyDistance.MILES_PER_KILO_WATT_HOUR: 100 * _KM_TO_M / _MILE_TO_M,
|
||||
UnitOfEnergyDistance.KM_PER_KILO_WATT_HOUR: 100,
|
||||
}
|
||||
|
@ -509,6 +509,18 @@ _CONVERTED_VALUE: dict[
|
||||
6.213712,
|
||||
UnitOfEnergyDistance.MILES_PER_KILO_WATT_HOUR,
|
||||
),
|
||||
(
|
||||
10,
|
||||
UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
|
||||
100,
|
||||
UnitOfEnergyDistance.WATT_HOUR_PER_KM,
|
||||
),
|
||||
(
|
||||
15,
|
||||
UnitOfEnergyDistance.WATT_HOUR_PER_KM,
|
||||
1.5,
|
||||
UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
|
||||
),
|
||||
(
|
||||
25,
|
||||
UnitOfEnergyDistance.KILO_WATT_HOUR_PER_100_KM,
|
||||
|
Loading…
x
Reference in New Issue
Block a user