diff --git a/custom_components/better_thermostat/climate.py b/custom_components/better_thermostat/climate.py index 75babfe2..814f758b 100644 --- a/custom_components/better_thermostat/climate.py +++ b/custom_components/better_thermostat/climate.py @@ -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, @@ -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) @@ -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 @@ -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. @@ -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, + ] diff --git a/custom_components/better_thermostat/utils/const.py b/custom_components/better_thermostat/utils/const.py index bc78b70f..5e46d26c 100644 --- a/custom_components/better_thermostat/utils/const.py +++ b/custom_components/better_thermostat/utils/const.py @@ -55,7 +55,7 @@ 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" diff --git a/requirements.dev.txt b/requirements.dev.txt index 2315a3a2..f61b3570 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -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 \ No newline at end of file +flake8==4.0.1