Skip to content

Commit a679033

Browse files
committed
Fix the version compatibility issue of constant unit 'var'
1 parent 9e8b5a0 commit a679033

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

custom_components/bituopmd/sensor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
UnitOfElectricCurrent,
1010
UnitOfElectricPotential,
1111
UnitOfApparentPower,
12-
POWER_VOLT_AMPERE_REACTIVE,
1312
UnitOfPower,
1413
PERCENTAGE,
1514
SIGNAL_STRENGTH_DECIBELS,
1615
)
16+
try:
17+
from homeassistant.const import UnitOfReactivePower
18+
POWER_VOLT_AMPERE_REACTIVE = UnitOfReactivePower.VOLT_AMPERE_REACTIVE
19+
except (ImportError, AttributeError):
20+
from homeassistant.const import POWER_VOLT_AMPERE_REACTIVE
21+
1722
from homeassistant.helpers.entity import DeviceInfo
1823
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass
1924
from homeassistant.helpers.update_coordinator import (

0 commit comments

Comments
 (0)