mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-10-27 16:10:49 +08:00
fix: replace deprecated CONCENTRATION_* unit constants (#1801)
This commit is contained in:
@@ -52,14 +52,9 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
|
||||||
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
|
|
||||||
CONCENTRATION_PARTS_PER_BILLION,
|
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
|
||||||
DEGREE,
|
DEGREE,
|
||||||
LIGHT_LUX,
|
LIGHT_LUX,
|
||||||
REVOLUTIONS_PER_MINUTE,
|
REVOLUTIONS_PER_MINUTE,
|
||||||
PERCENTAGE,
|
|
||||||
SIGNAL_STRENGTH_DECIBELS,
|
SIGNAL_STRENGTH_DECIBELS,
|
||||||
UnitOfBloodGlucoseConcentration,
|
UnitOfBloodGlucoseConcentration,
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
@@ -105,6 +100,23 @@ from .miot_spec import (
|
|||||||
MIoTSpecValueRange
|
MIoTSpecValueRange
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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_MILLIGRAMS_PER_CUBIC_METER = (
|
||||||
|
UnitOfDensity.MILLIGRAMS_PER_CUBIC_METER)
|
||||||
|
CONCENTRATION_PARTS_PER_MILLION = UnitOfRatio.PARTS_PER_MILLION
|
||||||
|
CONCENTRATION_PARTS_PER_BILLION = UnitOfRatio.PARTS_PER_BILLION
|
||||||
|
PERCENTAGE = UnitOfRatio.PERCENTAGE
|
||||||
|
except ImportError:
|
||||||
|
from homeassistant.const import (
|
||||||
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
|
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
|
||||||
|
CONCENTRATION_PARTS_PER_BILLION,
|
||||||
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
PERCENTAGE)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,12 +50,22 @@ from homeassistant.components.sensor import SensorStateClass
|
|||||||
from homeassistant.components.event import EventDeviceClass
|
from homeassistant.components.event import EventDeviceClass
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||||
|
|
||||||
from homeassistant.const import (CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
from homeassistant.const import (EntityCategory, LIGHT_LUX, UnitOfEnergy,
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
|
||||||
EntityCategory, LIGHT_LUX, UnitOfEnergy,
|
|
||||||
UnitOfPower, UnitOfElectricCurrent,
|
UnitOfPower, UnitOfElectricCurrent,
|
||||||
UnitOfElectricPotential, UnitOfTemperature,
|
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
|
# pylint: disable=pointless-string-statement
|
||||||
"""SPEC_DEVICE_TRANS_MAP
|
"""SPEC_DEVICE_TRANS_MAP
|
||||||
|
|||||||
Reference in New Issue
Block a user