Skip to content

Commit

Permalink
Merge pull request #100 from albertoxamin/fix-depr
Browse files Browse the repository at this point in the history
Migrate deprecated DEVICE_CLASS to SensorDeviceClass
  • Loading branch information
nbogojevic authored Feb 22, 2023
2 parents 26174b8 + 7a2d560 commit b06b507
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
11 changes: 5 additions & 6 deletions custom_components/midea_dehumidifier_lan/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Adds binary sensors for appliances."""

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_COLD,
DEVICE_CLASS_PROBLEM,
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -63,7 +62,7 @@ class TankFullSensor(ApplianceEntity, BinarySensorEntity):
dehumidifier from operating)
"""

_attr_device_class = DEVICE_CLASS_PROBLEM
_attr_device_class = BinarySensorDeviceClass.PROBLEM
_name_suffix = " Tank Full"

def on_update(self) -> None:
Expand All @@ -79,7 +78,7 @@ class TankRemovedSensor(ApplianceEntity, BinarySensorEntity):
dehumidifier from operating)
"""

_attr_device_class = DEVICE_CLASS_PROBLEM
_attr_device_class = BinarySensorDeviceClass.PROBLEM
_name_suffix = " Tank Removed"
_capability_attr = "pump"

Expand All @@ -92,7 +91,7 @@ class FilterReplacementSensor(ApplianceEntity, BinarySensorEntity):
Describes filter replacement binary sensors (indicated as problem)
"""

_attr_device_class = DEVICE_CLASS_PROBLEM
_attr_device_class = BinarySensorDeviceClass.PROBLEM
_attr_entity_registry_enabled_default = False
_name_suffix = " Replace Filter"
_capability_attr = "filter"
Expand All @@ -111,7 +110,7 @@ class DefrostingSensor(ApplianceEntity, BinarySensorEntity):
Describes defrosting mode binary sensors (indicated as cold)
"""

_attr_device_class = DEVICE_CLASS_COLD
_attr_device_class = BinarySensorDeviceClass.COLD
_attr_entity_registry_enabled_default = False
_name_suffix = " Defrosting"

Expand Down
14 changes: 8 additions & 6 deletions custom_components/midea_dehumidifier_lan/sensor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Adds sensors for each appliance."""

from homeassistant.components.sensor import SensorEntity, SensorStateClass
from homeassistant.components.sensor import (
SensorEntity,
SensorStateClass,
SensorDeviceClass
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
PERCENTAGE,
TEMP_CELSIUS,
)
Expand Down Expand Up @@ -48,7 +50,7 @@ async def async_setup_entry(
class CurrentHumiditySensor(ApplianceEntity, SensorEntity):
"""Crrent environment humidity sensor"""

_attr_device_class = DEVICE_CLASS_HUMIDITY
_attr_device_class = SensorDeviceClass.HUMIDITY
_attr_native_unit_of_measurement = PERCENTAGE
_attr_state_class = SensorStateClass.MEASUREMENT
_name_suffix = " Humidity"
Expand All @@ -60,7 +62,7 @@ def on_update(self) -> None:
class CurrentTemperatureSensor(ApplianceEntity, SensorEntity):
"""Current environment temperature sensor"""

_attr_device_class = DEVICE_CLASS_TEMPERATURE
_attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = TEMP_CELSIUS
_attr_state_class = SensorStateClass.MEASUREMENT
_name_suffix = " Temperature"
Expand Down Expand Up @@ -89,7 +91,7 @@ def on_update(self) -> None:
class OutsideTemperatureSensor(ApplianceEntity, SensorEntity):
"""Current outside temperature sensor"""

_attr_device_class = DEVICE_CLASS_TEMPERATURE
_attr_device_class = SensorDeviceClass.TEMPERATURE
_attr_native_unit_of_measurement = TEMP_CELSIUS
_attr_state_class = SensorStateClass.MEASUREMENT
_unique_id_prefx = UNIQUE_CLIMATE_PREFIX
Expand Down

0 comments on commit b06b507

Please sign in to comment.