Skip to content

Commit fc4b5f6

Browse files
Extend UnitOfApparentPower with 'kVA' (home-assistant#151420)
1 parent 55978f2 commit fc4b5f6

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

homeassistant/components/number/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class NumberDeviceClass(StrEnum):
8989
APPARENT_POWER = "apparent_power"
9090
"""Apparent power.
9191
92-
Unit of measurement: `mVA`, `VA`
92+
Unit of measurement: `mVA`, `VA`, `kVA`
9393
"""
9494

9595
AQI = "aqi"

homeassistant/components/sensor/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class SensorDeviceClass(StrEnum):
120120
APPARENT_POWER = "apparent_power"
121121
"""Apparent power.
122122
123-
Unit of measurement: `mVA`, `VA`
123+
Unit of measurement: `mVA`, `VA`, `kVA`
124124
"""
125125

126126
AQI = "aqi"

homeassistant/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ class UnitOfApparentPower(StrEnum):
590590

591591
MILLIVOLT_AMPERE = "mVA"
592592
VOLT_AMPERE = "VA"
593+
KILO_VOLT_AMPERE = "kVA"
593594

594595

595596
# Power units

homeassistant/util/unit_conversion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,12 @@ class ApparentPowerConverter(BaseUnitConverter):
391391
_UNIT_CONVERSION: dict[str | None, float] = {
392392
UnitOfApparentPower.MILLIVOLT_AMPERE: 1 * 1000,
393393
UnitOfApparentPower.VOLT_AMPERE: 1,
394+
UnitOfApparentPower.KILO_VOLT_AMPERE: 1 / 1000,
394395
}
395396
VALID_UNITS = {
396397
UnitOfApparentPower.MILLIVOLT_AMPERE,
397398
UnitOfApparentPower.VOLT_AMPERE,
399+
UnitOfApparentPower.KILO_VOLT_AMPERE,
398400
}
399401

400402

tests/util/test_unit_conversion.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@
191191
0.01,
192192
UnitOfApparentPower.VOLT_AMPERE,
193193
),
194+
(
195+
10,
196+
UnitOfApparentPower.MILLIVOLT_AMPERE,
197+
0.00001,
198+
UnitOfApparentPower.KILO_VOLT_AMPERE,
199+
),
200+
(
201+
10,
202+
UnitOfApparentPower.VOLT_AMPERE,
203+
0.01,
204+
UnitOfApparentPower.KILO_VOLT_AMPERE,
205+
),
206+
(
207+
10,
208+
UnitOfApparentPower.KILO_VOLT_AMPERE,
209+
10000,
210+
UnitOfApparentPower.VOLT_AMPERE,
211+
),
194212
],
195213
AreaConverter: [
196214
# Square Meters to other units

0 commit comments

Comments
 (0)