Add kV and MV unit conversion for voltages (#135396)
parent
dae87db244
commit
7b63c17101
|
@ -363,7 +363,7 @@ class NumberDeviceClass(StrEnum):
|
|||
VOLTAGE = "voltage"
|
||||
"""Voltage.
|
||||
|
||||
Unit of measurement: `V`, `mV`, `µV`
|
||||
Unit of measurement: `V`, `mV`, `µV`, `kV`, `MV`
|
||||
"""
|
||||
|
||||
VOLUME = "volume"
|
||||
|
|
|
@ -392,7 +392,7 @@ class SensorDeviceClass(StrEnum):
|
|||
VOLTAGE = "voltage"
|
||||
"""Voltage.
|
||||
|
||||
Unit of measurement: `V`, `mV`, `µV`
|
||||
Unit of measurement: `V`, `mV`, `µV`, `kV`, `MV`
|
||||
"""
|
||||
|
||||
VOLUME = "volume"
|
||||
|
|
|
@ -647,6 +647,8 @@ class UnitOfElectricPotential(StrEnum):
|
|||
MICROVOLT = "µV"
|
||||
MILLIVOLT = "mV"
|
||||
VOLT = "V"
|
||||
KILOVOLT = "kV"
|
||||
MEGAVOLT = "MV"
|
||||
|
||||
|
||||
# Degree units
|
||||
|
|
|
@ -249,11 +249,15 @@ class ElectricPotentialConverter(BaseUnitConverter):
|
|||
UnitOfElectricPotential.VOLT: 1,
|
||||
UnitOfElectricPotential.MILLIVOLT: 1e3,
|
||||
UnitOfElectricPotential.MICROVOLT: 1e6,
|
||||
UnitOfElectricPotential.KILOVOLT: 1 / 1e3,
|
||||
UnitOfElectricPotential.MEGAVOLT: 1 / 1e6,
|
||||
}
|
||||
VALID_UNITS = {
|
||||
UnitOfElectricPotential.VOLT,
|
||||
UnitOfElectricPotential.MILLIVOLT,
|
||||
UnitOfElectricPotential.MICROVOLT,
|
||||
UnitOfElectricPotential.KILOVOLT,
|
||||
UnitOfElectricPotential.MEGAVOLT,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -435,10 +435,24 @@ _CONVERTED_VALUE: dict[
|
|||
ElectricPotentialConverter: [
|
||||
(5, UnitOfElectricPotential.VOLT, 5000, UnitOfElectricPotential.MILLIVOLT),
|
||||
(5, UnitOfElectricPotential.VOLT, 5e6, UnitOfElectricPotential.MICROVOLT),
|
||||
(5, UnitOfElectricPotential.VOLT, 5e-3, UnitOfElectricPotential.KILOVOLT),
|
||||
(5, UnitOfElectricPotential.VOLT, 5e-6, UnitOfElectricPotential.MEGAVOLT),
|
||||
(5, UnitOfElectricPotential.MILLIVOLT, 0.005, UnitOfElectricPotential.VOLT),
|
||||
(5, UnitOfElectricPotential.MILLIVOLT, 5e3, UnitOfElectricPotential.MICROVOLT),
|
||||
(5, UnitOfElectricPotential.MILLIVOLT, 5e-6, UnitOfElectricPotential.KILOVOLT),
|
||||
(5, UnitOfElectricPotential.MILLIVOLT, 5e-9, UnitOfElectricPotential.MEGAVOLT),
|
||||
(5, UnitOfElectricPotential.MICROVOLT, 5e-3, UnitOfElectricPotential.MILLIVOLT),
|
||||
(5, UnitOfElectricPotential.MICROVOLT, 5e-6, UnitOfElectricPotential.VOLT),
|
||||
(5, UnitOfElectricPotential.MICROVOLT, 5e-9, UnitOfElectricPotential.KILOVOLT),
|
||||
(5, UnitOfElectricPotential.MICROVOLT, 5e-12, UnitOfElectricPotential.MEGAVOLT),
|
||||
(5, UnitOfElectricPotential.KILOVOLT, 5e9, UnitOfElectricPotential.MICROVOLT),
|
||||
(5, UnitOfElectricPotential.KILOVOLT, 5e6, UnitOfElectricPotential.MILLIVOLT),
|
||||
(5, UnitOfElectricPotential.KILOVOLT, 5e3, UnitOfElectricPotential.VOLT),
|
||||
(5, UnitOfElectricPotential.KILOVOLT, 5e-3, UnitOfElectricPotential.MEGAVOLT),
|
||||
(5, UnitOfElectricPotential.MEGAVOLT, 5e12, UnitOfElectricPotential.MICROVOLT),
|
||||
(5, UnitOfElectricPotential.MEGAVOLT, 5e9, UnitOfElectricPotential.MILLIVOLT),
|
||||
(5, UnitOfElectricPotential.MEGAVOLT, 5e6, UnitOfElectricPotential.VOLT),
|
||||
(5, UnitOfElectricPotential.MEGAVOLT, 5e3, UnitOfElectricPotential.KILOVOLT),
|
||||
],
|
||||
EnergyConverter: [
|
||||
(10, UnitOfEnergy.MILLIWATT_HOUR, 0.00001, UnitOfEnergy.KILO_WATT_HOUR),
|
||||
|
|
Loading…
Reference in New Issue