mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
Extend UnitOfApparentPower with 'kVA' (#151420)
This commit is contained in:
@@ -89,7 +89,7 @@ class NumberDeviceClass(StrEnum):
|
||||
APPARENT_POWER = "apparent_power"
|
||||
"""Apparent power.
|
||||
|
||||
Unit of measurement: `mVA`, `VA`
|
||||
Unit of measurement: `mVA`, `VA`, `kVA`
|
||||
"""
|
||||
|
||||
AQI = "aqi"
|
||||
|
||||
@@ -120,7 +120,7 @@ class SensorDeviceClass(StrEnum):
|
||||
APPARENT_POWER = "apparent_power"
|
||||
"""Apparent power.
|
||||
|
||||
Unit of measurement: `mVA`, `VA`
|
||||
Unit of measurement: `mVA`, `VA`, `kVA`
|
||||
"""
|
||||
|
||||
AQI = "aqi"
|
||||
|
||||
@@ -590,6 +590,7 @@ class UnitOfApparentPower(StrEnum):
|
||||
|
||||
MILLIVOLT_AMPERE = "mVA"
|
||||
VOLT_AMPERE = "VA"
|
||||
KILO_VOLT_AMPERE = "kVA"
|
||||
|
||||
|
||||
# Power units
|
||||
|
||||
@@ -391,10 +391,12 @@ class ApparentPowerConverter(BaseUnitConverter):
|
||||
_UNIT_CONVERSION: dict[str | None, float] = {
|
||||
UnitOfApparentPower.MILLIVOLT_AMPERE: 1 * 1000,
|
||||
UnitOfApparentPower.VOLT_AMPERE: 1,
|
||||
UnitOfApparentPower.KILO_VOLT_AMPERE: 1 / 1000,
|
||||
}
|
||||
VALID_UNITS = {
|
||||
UnitOfApparentPower.MILLIVOLT_AMPERE,
|
||||
UnitOfApparentPower.VOLT_AMPERE,
|
||||
UnitOfApparentPower.KILO_VOLT_AMPERE,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -191,6 +191,24 @@ _CONVERTED_VALUE: dict[
|
||||
0.01,
|
||||
UnitOfApparentPower.VOLT_AMPERE,
|
||||
),
|
||||
(
|
||||
10,
|
||||
UnitOfApparentPower.MILLIVOLT_AMPERE,
|
||||
0.00001,
|
||||
UnitOfApparentPower.KILO_VOLT_AMPERE,
|
||||
),
|
||||
(
|
||||
10,
|
||||
UnitOfApparentPower.VOLT_AMPERE,
|
||||
0.01,
|
||||
UnitOfApparentPower.KILO_VOLT_AMPERE,
|
||||
),
|
||||
(
|
||||
10,
|
||||
UnitOfApparentPower.KILO_VOLT_AMPERE,
|
||||
10000,
|
||||
UnitOfApparentPower.VOLT_AMPERE,
|
||||
),
|
||||
],
|
||||
AreaConverter: [
|
||||
# Square Meters to other units
|
||||
|
||||
Reference in New Issue
Block a user