Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated warnings #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions custom_components/uponor/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@

from homeassistant.const import (
ATTR_TEMPERATURE,
TEMP_CELSIUS
UnitOfTemperature
)

from homeassistant.components.climate.const import (
HVAC_MODE_HEAT,
HVAC_MODE_COOL,
HVAC_MODE_OFF,
CURRENT_HVAC_OFF,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_COOL,
CURRENT_HVAC_IDLE,
HVACMode,
HVACAction,
PRESET_AWAY,
PRESET_ECO,
SUPPORT_TARGET_TEMPERATURE,
SUPPORT_PRESET_MODE
ClimateEntityFeature,
)

from .const import (
Expand Down Expand Up @@ -79,38 +73,38 @@ def _update_callback(self):
@property
def supported_features(self):
if self._is_on:
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
return ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
return 0

@property
def hvac_action(self):
if not self._is_on:
return CURRENT_HVAC_OFF
return HVACAction.OFF
if self._state_proxy.is_active(self._thermostat):
return CURRENT_HVAC_COOL if self._state_proxy.is_cool_enabled() else CURRENT_HVAC_HEAT
return CURRENT_HVAC_IDLE
return HVACAction.COOLING if self._state_proxy.is_cool_enabled() else HVACAction.HEATING
return HVACAction.IDLE

@property
def hvac_mode(self):
if not self._is_on:
return HVAC_MODE_OFF
return HVACMode.OFF
if self._state_proxy.is_cool_enabled():
return HVAC_MODE_COOL
return HVAC_MODE_HEAT
return HVACMode.COOL
return HVACMode.HEAT

async def async_set_hvac_mode(self, hvac_mode):
if hvac_mode == HVAC_MODE_OFF and self._is_on:
if hvac_mode == HVACMode.OFF and self._is_on:
await self._state_proxy.async_turn_off(self._thermostat)
self._is_on = False
if (hvac_mode == HVAC_MODE_HEAT or hvac_mode == HVAC_MODE_COOL) and not self._is_on:
if (hvac_mode == HVACMode.HEAT or hvac_mode == HVACMode.COOL) and not self._is_on:
await self._state_proxy.async_turn_on(self._thermostat)
self._is_on = True

@property
def hvac_modes(self):
if self._state_proxy.is_cool_enabled():
return [HVAC_MODE_COOL, HVAC_MODE_OFF]
return [HVAC_MODE_HEAT, HVAC_MODE_OFF]
return [HVACMode.COOL, HVACMode.OFF]
return [HVACMode.HEAT, HVACMode.OFF]

@property
def preset_mode(self):
Expand All @@ -126,7 +120,7 @@ def preset_modes(self):

@property
def temperature_unit(self):
return TEMP_CELSIUS
return UnitOfTemperature.CELSIUS

@property
def current_temperature(self):
Expand Down