Skip to content

Commit 355e2f7

Browse files
committed
Merge branch 'master' into release-1.5.0-beta
* master: lint fix issue 1274
2 parents 055bfb0 + 3ef10e0 commit 355e2f7

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

custom_components/better_thermostat/climate.py

+34-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
ATTR_HVAC_MODE,
3333
ATTR_TARGET_TEMP_HIGH,
3434
ATTR_TARGET_TEMP_LOW,
35+
PRESET_AWAY,
36+
PRESET_NONE,
37+
PRESET_ECO,
38+
PRESET_BOOST,
39+
PRESET_COMFORT,
40+
PRESET_HOME,
41+
PRESET_SLEEP,
42+
PRESET_ACTIVITY,
43+
SUPPORT_PRESET_MODE,
3544
)
3645
from homeassistant.components.climate.const import (
3746
ATTR_MAX_TEMP,
@@ -249,6 +258,7 @@ def __init__(
249258
self._device_class = device_class
250259
self._state_class = state_class
251260
self._hvac_list = [HVACMode.HEAT, HVACMode.OFF]
261+
self._preset_mode = PRESET_NONE
252262
self.map_on_hvac_mode = HVACMode.HEAT
253263
self.next_valve_maintenance = datetime.now() + timedelta(
254264
hours=randint(1, 24 * 5)
@@ -261,7 +271,7 @@ def __init__(
261271
self.bt_max_temp = 30
262272
self.bt_target_temp = 5.0
263273
self.bt_target_cooltemp = None
264-
self._support_flags = SUPPORT_FLAGS
274+
self._support_flags = SUPPORT_FLAGS | SUPPORT_PRESET_MODE
265275
self.bt_hvac_mode = None
266276
self.closed_window_triggered = False
267277
self.call_for_heat = True
@@ -1258,6 +1268,12 @@ async def async_set_temperature(self, **kwargs) -> None:
12581268
self.async_write_ha_state()
12591269
await self.control_queue_task.put(self)
12601270

1271+
async def async_turn_off(self) -> None:
1272+
await self.async_set_hvac_mode(HVACMode.OFF)
1273+
1274+
async def async_turn_on(self) -> None:
1275+
await self.async_set_hvac_mode(HVACMode.HEATING)
1276+
12611277
@property
12621278
def min_temp(self):
12631279
"""Return the minimum temperature.
@@ -1316,14 +1332,29 @@ def supported_features(self):
13161332
return (
13171333
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
13181334
| ClimateEntityFeature.PRESET_MODE
1319-
| ClimateEntityFeature.PRESET_MODE
13201335
| ClimateEntityFeature.TURN_OFF
13211336
| ClimateEntityFeature.TURN_ON
13221337
)
13231338
return (
13241339
ClimateEntityFeature.TARGET_TEMPERATURE
13251340
| ClimateEntityFeature.PRESET_MODE
1326-
| ClimateEntityFeature.PRESET_MODE
13271341
| ClimateEntityFeature.TURN_OFF
13281342
| ClimateEntityFeature.TURN_ON
13291343
)
1344+
1345+
@property
1346+
def preset_mode(self):
1347+
return self._preset_mode
1348+
1349+
@property
1350+
def preset_modes(self):
1351+
return [
1352+
PRESET_NONE,
1353+
# PRESET_AWAY,
1354+
# PRESET_ECO,
1355+
# PRESET_COMFORT,
1356+
# PRESET_BOOST,
1357+
# PRESET_SLEEP,
1358+
# PRESET_ACTIVITY,
1359+
# PRESET_HOME,
1360+
]

custom_components/better_thermostat/utils/const.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555
CONF_NO_SYSTEM_MODE_OFF = "no_off_system_mode"
5656
CONF_TOLERANCE = "tolerance"
5757
CONF_TARGET_TEMP_STEP = "target_temp_step"
58-
SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE
58+
SUPPORT_FLAGS = (
59+
ClimateEntityFeature.TARGET_TEMPERATURE
60+
| ClimateEntityFeature.TURN_OFF
61+
| ClimateEntityFeature.TURN_ON
62+
)
5963

6064
ATTR_STATE_WINDOW_OPEN = "window_open"
6165
ATTR_STATE_CALL_FOR_HEAT = "call_for_heat"

requirements.dev.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
homeassistant==2023.9.2
1+
homeassistant==2024.2.1
22
pre-commit==2.15.0
33
black==23.9.1
44
codespell==2.2.2
55
ruff==0.0.289
66
yamllint==1.32.0
7-
flake8==4.0.1
7+
flake8==4.0.1

0 commit comments

Comments
 (0)