Skip to content

Commit

Permalink
Fix conductivity deprecation #1489
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Nov 22, 2024
1 parent 3493a7f commit 2a1726d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
13 changes: 13 additions & 0 deletions custom_components/xiaomi_gateway3/hass/backward.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try:
from homeassistant.const import UnitOfConductivity

# https://github.com/home-assistant/core/blob/2024.11.0/homeassistant/const.py
CONDUCTIVITY = UnitOfConductivity.MICROSIEMENS_PER_CM
except:
try:
from homeassistant.const import UnitOfConductivity

# https://github.com/home-assistant/core/blob/2024.7.0/homeassistant/const.py
CONDUCTIVITY = UnitOfConductivity.MICROSIEMENS
except:
from homeassistant.const import CONDUCTIVITY
9 changes: 1 addition & 8 deletions custom_components/xiaomi_gateway3/hass/entity_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
MAJOR_VERSION,
MINOR_VERSION,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfElectricPotential,
Expand All @@ -24,12 +22,7 @@
)
from homeassistant.helpers.entity import Entity, EntityCategory

if (MAJOR_VERSION, MINOR_VERSION) >= (2024, 7):
from homeassistant.const import UnitOfConductivity
CONDUCTIVITY = UnitOfConductivity.MICROSIEMENS
else:
from homeassistant.const import CONDUCTIVITY

from .backward import CONDUCTIVITY
from ..core.converters.base import BaseConv

# just to reduce the code
Expand Down

0 comments on commit 2a1726d

Please sign in to comment.