Skip to content

Commit

Permalink
Merge pull request #123 from uvjim/fix-deprecated-constants
Browse files Browse the repository at this point in the history
Fix deprecated constants
  • Loading branch information
bigbadblunt authored Jan 11, 2024
2 parents 75193c3 + 14c4edd commit d8ac57a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 12 deletions.
9 changes: 8 additions & 1 deletion custom_components/lightwave2/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
from homeassistant.components.binary_sensor import BinarySensorEntity, BinarySensorEntityDescription
except ImportError:
from homeassistant.components.binary_sensor import BinarySensorDevice as BinarySensorEntity
from homeassistant.components.binary_sensor import (DEVICE_CLASS_WINDOW, DEVICE_CLASS_PLUG, DEVICE_CLASS_MOTION)
# Device Classes
try:
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
DEVICE_CLASS_WINDOW = BinarySensorDeviceClass.WINDOW
DEVICE_CLASS_PLUG = BinarySensorDeviceClass.PLUG
DEVICE_CLASS_MOTION = BinarySensorDeviceClass.MOTION
except ImportError:
from homeassistant.components.binary_sensor import (DEVICE_CLASS_WINDOW, DEVICE_CLASS_PLUG, DEVICE_CLASS_MOTION)
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers import entity_registry as er
Expand Down
33 changes: 29 additions & 4 deletions custom_components/lightwave2/climate.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
import logging
from .const import LIGHTWAVE_LINK2, LIGHTWAVE_ENTITIES
from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF
try:
from homeassistant.components.climate import ClimateEntity
except ImportError:
from homeassistant.components.climate import ClimateDevice as ClimateEntity
from homeassistant.components.climate.const import (
HVAC_MODE_OFF, HVAC_MODE_HEAT, SUPPORT_TARGET_HUMIDITY, SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE, CURRENT_HVAC_HEAT, CURRENT_HVAC_IDLE, CURRENT_HVAC_OFF)
from homeassistant.const import (
ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT, STATE_OFF)
try:
from homeassistant.components.climate.const import ClimateEntityFeature, HVACAction, HVACMode
CURRENT_HVAC_HEAT = HVACAction.HEATING
CURRENT_HVAC_IDLE = HVACAction.IDLE
CURRENT_HVAC_OFF = HVACAction.OFF
HVAC_MODE_HEAT = HVACMode.HEAT
HVAC_MODE_OFF = HVACMode.OFF
SUPPORT_PRESET_MODE = ClimateEntityFeature.PRESET_MODE
SUPPORT_TARGET_HUMIDITY = ClimateEntityFeature.TARGET_HUMIDITY
SUPPORT_TARGET_TEMPERATURE = ClimateEntityFeature.TARGET_TEMPERATURE
except ImportError:
from homeassistant.components.climate.const import (
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
CURRENT_HVAC_OFF,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_HUMIDITY,
SUPPORT_TARGET_TEMPERATURE,
)
# Units
try:
from homeassistant.const import UnitOfTemperature
TEMP_CELSIUS = UnitOfTemperature.CELSIUS
TEMP_FAHRENHEIT = UnitOfTemperature.FAHRENHEIT
except ImportError:
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.core import callback
from .const import DOMAIN

Expand Down
12 changes: 9 additions & 3 deletions custom_components/lightwave2/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
from homeassistant.components.cover import CoverEntity
except ImportError:
from homeassistant.components.cover import CoverDevice as CoverEntity
from homeassistant.components.cover import (
SUPPORT_CLOSE, SUPPORT_OPEN,
SUPPORT_STOP)
try:
from homeassistant.components.cover import CoverEntityFeature
SUPPORT_CLOSE = CoverEntityFeature.CLOSE
SUPPORT_OPEN = CoverEntityFeature.OPEN
SUPPORT_STOP = CoverEntityFeature.STOP
except ImportError:
from homeassistant.components.cover import (
SUPPORT_CLOSE, SUPPORT_OPEN,
SUPPORT_STOP)
from homeassistant.core import callback
from .const import DOMAIN

Expand Down
45 changes: 41 additions & 4 deletions custom_components/lightwave2/sensor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
import logging
from .const import LIGHTWAVE_LINK2, LIGHTWAVE_ENTITIES, DOMAIN
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, SensorEntity, SensorEntityDescription
from homeassistant.const import (POWER_WATT, ENERGY_WATT_HOUR, DEVICE_CLASS_POWER, DEVICE_CLASS_ENERGY,
DEVICE_CLASS_SIGNAL_STRENGTH, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, PERCENTAGE, DEVICE_CLASS_BATTERY,
DEVICE_CLASS_TIMESTAMP, ELECTRIC_POTENTIAL_VOLT, ELECTRIC_CURRENT_MILLIAMPERE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_VOLTAGE, DEVICE_CLASS_ILLUMINANCE)
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
# State Classes
try:
from homeassistant.components.sensor import SensorStateClass
STATE_CLASS_MEASUREMENT = SensorStateClass.MEASUREMENT
STATE_CLASS_TOTAL_INCREASING = SensorStateClass.TOTAL_INCREASING
except ImportError:
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING
# Device Classes
try:
from homeassistant.components.sensor import SensorDeviceClass
DEVICE_CLASS_BATTERY = SensorDeviceClass.BATTERY
DEVICE_CLASS_CURRENT = SensorDeviceClass.CURRENT
DEVICE_CLASS_ENERGY = SensorDeviceClass.ENERGY
DEVICE_CLASS_ILLUMINANCE = SensorDeviceClass.ILLUMINANCE
DEVICE_CLASS_POWER = SensorDeviceClass.POWER
DEVICE_CLASS_SIGNAL_STRENGTH = SensorDeviceClass.SIGNAL_STRENGTH
DEVICE_CLASS_TIMESTAMP = SensorDeviceClass.TIMESTAMP
DEVICE_CLASS_VOLTAGE = SensorDeviceClass.VOLTAGE
except ImportError:
from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_POWER,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLTAGE
)
# Units
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
try:
from homeassistant.const import UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, UnitOfPower
ELECTRIC_CURRENT_MILLIAMPERE = UnitOfElectricCurrent.MILLIAMPERE
ELECTRIC_POTENTIAL_VOLT = UnitOfElectricPotential.VOLT
ENERGY_WATT_HOUR = UnitOfEnergy.WATT_HOUR
POWER_WATT = UnitOfPower.WATT
except ImportError:
from homeassistant.const import (POWER_WATT, ENERGY_WATT_HOUR, ELECTRIC_POTENTIAL_VOLT, ELECTRIC_CURRENT_MILLIAMPERE)

from homeassistant.core import callback
from homeassistant.util import dt as dt_util
from homeassistant.helpers.entity import EntityCategory
Expand Down

0 comments on commit d8ac57a

Please sign in to comment.