Skip to content

Commit 73e8fdc

Browse files
Solves warning from deprecated consts
Solves warning from deprecated consts
1 parent f5ea175 commit 73e8fdc

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

custom_components/uhomeuponor/climate.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,10 @@
99
from requests.exceptions import RequestException
1010

1111
from homeassistant.exceptions import PlatformNotReady
12-
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
12+
from homeassistant.components.climate import ClimateEntity
1313
from homeassistant.components.climate.const import (
14-
HVAC_MODE_AUTO, HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_COOL,
15-
PRESET_COMFORT, PRESET_ECO,
16-
CURRENT_HVAC_HEAT, CURRENT_HVAC_COOL, CURRENT_HVAC_IDLE,
17-
SUPPORT_PRESET_MODE, SUPPORT_TARGET_TEMPERATURE)
18-
from homeassistant.const import (
19-
ATTR_ATTRIBUTION, ATTR_ENTITY_ID, ATTR_TEMPERATURE, ATTR_BATTERY_LEVEL,
20-
CONF_FRIENDLY_NAME, CONF_HOST, CONF_NAME, CONF_PREFIX,
21-
PRECISION_TENTHS,
22-
TEMP_CELSIUS)
23-
import homeassistant.helpers.config_validation as cv
14+
HVACMode, PRESET_COMFORT, PRESET_ECO, HVACAction, ClimateEntityFeature)
15+
from homeassistant.const import (ATTR_TEMPERATURE, CONF_HOST, CONF_PREFIX, PRECISION_TENTHS, UnitOfTemperature)
2416
from logging import getLogger
2517

2618
from .uponor_api import UponorClient
@@ -105,7 +97,7 @@ def available(self):
10597
# ** Static **
10698
@property
10799
def temperature_unit(self):
108-
return TEMP_CELSIUS
100+
return UnitOfTemperature.CELSIUS
109101

110102
@property
111103
def precision(self):
@@ -117,17 +109,17 @@ def target_temperature_step(self):
117109

118110
@property
119111
def supported_features(self):
120-
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
112+
return ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
121113

122114
@property
123115
def hvac_modes(self):
124116
modes = []
125117

126118
if self.supports_heating:
127-
modes.append(HVAC_MODE_HEAT)
119+
modes.append(HVACMode.HEAT)
128120

129121
if self.supports_cooling:
130-
modes.append(HVAC_MODE_COOL)
122+
modes.append(HVACMode.COOL)
131123

132124
return modes
133125

@@ -166,19 +158,19 @@ def preset_mode(self):
166158
@property
167159
def hvac_mode(self):
168160
if self.uponor_client.uhome.by_name('hc_mode').value == 1:
169-
return HVAC_MODE_COOL
161+
return HVACMode.COOL
170162

171-
return HVAC_MODE_HEAT
163+
return HVACMode.HEAT
172164

173165
@property
174166
def hvac_action(self):
175167
if self.thermostat.by_name('room_in_demand').value == 0:
176-
return CURRENT_HVAC_IDLE
168+
return HVACAction.IDLE
177169

178-
if self.hvac_mode == HVAC_MODE_HEAT:
179-
return CURRENT_HVAC_HEAT
170+
if self.hvac_mode == HVACMode.HEAT:
171+
return HVACAction.HEATING
180172
else:
181-
return CURRENT_HVAC_COOL
173+
return HVACAction.COOLING
182174

183175
# ** Actions **
184176
async def async_update(self):
@@ -194,7 +186,7 @@ async def async_update(self):
194186
_LOGGER.error("Uponor thermostat was unable to update: %s", ex)
195187

196188
def set_hvac_mode(self, hvac_mode):
197-
if hvac_mode == HVAC_MODE_HEAT:
189+
if hvac_mode == HVACMode.HEAT:
198190
value = UHOME_MODE_HEAT
199191
else:
200192
value = UHOME_MODE_COOL

custom_components/uhomeuponor/sensor.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@
1111
from requests.exceptions import RequestException
1212

1313
from homeassistant.exceptions import PlatformNotReady
14-
from homeassistant.components.sensor import PLATFORM_SCHEMA
15-
from homeassistant.const import (
16-
ATTR_ATTRIBUTION,
17-
CONF_NAME, CONF_HOST, CONF_PREFIX,
18-
TEMP_CELSIUS,
19-
DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE)
14+
from homeassistant.components.sensor import (PLATFORM_SCHEMA, SensorDeviceClass)
15+
from homeassistant.const import (CONF_HOST, CONF_PREFIX, UnitOfTemperature)
2016
import homeassistant.helpers.config_validation as cv
2117
from logging import getLogger
2218
from homeassistant.helpers.entity import Entity
@@ -118,11 +114,11 @@ def available(self):
118114
# ** Static **
119115
@property
120116
def unit_of_measurement(self):
121-
return TEMP_CELSIUS
117+
return UnitOfTemperature.CELSIUS
122118

123119
@property
124120
def device_class(self):
125-
return DEVICE_CLASS_TEMPERATURE
121+
return SensorDeviceClass.TEMPERATURE
126122

127123
# ** State **
128124
@property
@@ -186,7 +182,7 @@ def unit_of_measurement(self):
186182

187183
@property
188184
def device_class(self):
189-
return DEVICE_CLASS_HUMIDITY
185+
return SensorDeviceClass.HUMIDITY
190186

191187
# ** State **
192188
@property
@@ -247,7 +243,7 @@ def unit_of_measurement(self):
247243

248244
@property
249245
def device_class(self):
250-
return DEVICE_CLASS_BATTERY
246+
return SensorDeviceClass.BATTERY
251247

252248
# ** State **
253249
@property

0 commit comments

Comments
 (0)