From 2430e7dd8c3c1a2e7a3d2ba46319839cab5fdf75 Mon Sep 17 00:00:00 2001 From: Jean-Marc Collin Date: Wed, 20 Mar 2024 18:57:49 +0100 Subject: [PATCH] [#388] - remove climate warning (#415) Co-authored-by: Jean-Marc Collin --- .../versatile_thermostat/base_thermostat.py | 12 ++++++++++++ custom_components/versatile_thermostat/const.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 36b1bea..2ecf905 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -214,6 +214,9 @@ class BaseThermostat(ClimateEntity, RestoreEntity): super().__init__() + # To remove some silly warning event if code is fixed + self._enable_turn_on_off_backwards_compatibility = False + self._hass = hass self._entry_infos = None self._attr_extra_state_attributes = {} @@ -2700,3 +2703,12 @@ class BaseThermostat(ClimateEntity, RestoreEntity): await self._async_set_preset_mode_internal(self._attr_preset_mode, True) self.hass.create_task(self._check_initial_state()) + + async def async_turn_off(self) -> None: + await self.async_set_hvac_mode(HVACMode.OFF) + + async def async_turn_on(self) -> None: + if self._ac_mode: + await self.async_set_hvac_mode(HVACMode.COOL) + else: + await self.async_set_hvac_mode(HVACMode.HEATING) diff --git a/custom_components/versatile_thermostat/const.py b/custom_components/versatile_thermostat/const.py index 9bdee52..60125c0 100644 --- a/custom_components/versatile_thermostat/const.py +++ b/custom_components/versatile_thermostat/const.py @@ -329,7 +329,7 @@ CONF_WINDOW_ACTIONS = [ CONF_WINDOW_ECO_TEMP, ] -SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE +SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON SERVICE_SET_PRESENCE = "set_presence" SERVICE_SET_PRESET_TEMPERATURE = "set_preset_temperature"