Skip to content

Commit

Permalink
Merge branch 'master' into release-1.5.0-beta
Browse files Browse the repository at this point in the history
* master:
  lint
  fix issue 1274
  • Loading branch information
wtom committed Feb 16, 2024
2 parents 055bfb0 + 3ef10e0 commit 355e2f7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
37 changes: 34 additions & 3 deletions custom_components/better_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
ATTR_HVAC_MODE,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
PRESET_AWAY,
PRESET_NONE,
PRESET_ECO,
PRESET_BOOST,
PRESET_COMFORT,
PRESET_HOME,
PRESET_SLEEP,
PRESET_ACTIVITY,
SUPPORT_PRESET_MODE,
)
from homeassistant.components.climate.const import (
ATTR_MAX_TEMP,
Expand Down Expand Up @@ -249,6 +258,7 @@ def __init__(
self._device_class = device_class
self._state_class = state_class
self._hvac_list = [HVACMode.HEAT, HVACMode.OFF]
self._preset_mode = PRESET_NONE
self.map_on_hvac_mode = HVACMode.HEAT
self.next_valve_maintenance = datetime.now() + timedelta(
hours=randint(1, 24 * 5)
Expand All @@ -261,7 +271,7 @@ def __init__(
self.bt_max_temp = 30
self.bt_target_temp = 5.0
self.bt_target_cooltemp = None
self._support_flags = SUPPORT_FLAGS
self._support_flags = SUPPORT_FLAGS | SUPPORT_PRESET_MODE
self.bt_hvac_mode = None
self.closed_window_triggered = False
self.call_for_heat = True
Expand Down Expand Up @@ -1258,6 +1268,12 @@ async def async_set_temperature(self, **kwargs) -> None:
self.async_write_ha_state()
await self.control_queue_task.put(self)

async def async_turn_off(self) -> None:
await self.async_set_hvac_mode(HVACMode.OFF)

async def async_turn_on(self) -> None:
await self.async_set_hvac_mode(HVACMode.HEATING)

@property
def min_temp(self):
"""Return the minimum temperature.
Expand Down Expand Up @@ -1316,14 +1332,29 @@ def supported_features(self):
return (
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)
return (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)

@property
def preset_mode(self):
return self._preset_mode

@property
def preset_modes(self):
return [
PRESET_NONE,
# PRESET_AWAY,
# PRESET_ECO,
# PRESET_COMFORT,
# PRESET_BOOST,
# PRESET_SLEEP,
# PRESET_ACTIVITY,
# PRESET_HOME,
]
6 changes: 5 additions & 1 deletion custom_components/better_thermostat/utils/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@
CONF_NO_SYSTEM_MODE_OFF = "no_off_system_mode"
CONF_TOLERANCE = "tolerance"
CONF_TARGET_TEMP_STEP = "target_temp_step"
SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE
SUPPORT_FLAGS = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)

ATTR_STATE_WINDOW_OPEN = "window_open"
ATTR_STATE_CALL_FOR_HEAT = "call_for_heat"
Expand Down
4 changes: 2 additions & 2 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
homeassistant==2023.9.2
homeassistant==2024.2.1
pre-commit==2.15.0
black==23.9.1
codespell==2.2.2
ruff==0.0.289
yamllint==1.32.0
flake8==4.0.1
flake8==4.0.1

0 comments on commit 355e2f7

Please sign in to comment.