mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-10-28 00:20:49 +08:00
fix: replace deprecated CONCENTRATION_* unit constants (#1801)
This commit is contained in:
@@ -50,12 +50,22 @@ from homeassistant.components.sensor import SensorStateClass
|
||||
from homeassistant.components.event import EventDeviceClass
|
||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||
|
||||
from homeassistant.const import (CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
EntityCategory, LIGHT_LUX, UnitOfEnergy,
|
||||
from homeassistant.const import (EntityCategory, LIGHT_LUX, UnitOfEnergy,
|
||||
UnitOfPower, UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential, UnitOfTemperature,
|
||||
UnitOfPressure, PERCENTAGE)
|
||||
UnitOfPressure)
|
||||
|
||||
try: # UnitOfDensity and UnitOfRatio are introduced in HA core 2026.7
|
||||
from homeassistant.const import UnitOfDensity, UnitOfRatio
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER = (
|
||||
UnitOfDensity.MICROGRAMS_PER_CUBIC_METER)
|
||||
CONCENTRATION_PARTS_PER_MILLION = UnitOfRatio.PARTS_PER_MILLION
|
||||
PERCENTAGE = UnitOfRatio.PERCENTAGE
|
||||
except ImportError:
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
PERCENTAGE)
|
||||
|
||||
# pylint: disable=pointless-string-statement
|
||||
"""SPEC_DEVICE_TRANS_MAP
|
||||
|
||||
Reference in New Issue
Block a user