Skip to content

Commit

Permalink
Fixes deprecation warnings in HA 2024.2.x (#74)
Browse files Browse the repository at this point in the history
* First pass at trying to fix TURN_OFF and TURN_ON compatibility from 2024.2

Implementing new TURN_OFF, TURN_ON feature flags to squelch warnings in 2024.2 forward.

Still struggling with the async_turn_on and off calls.  They don't work.  I.e. calling home assistant generic turn on/off on a warmup climate object.

* First pass at supporting new turn off/on

Supported the new flags to quell warnings from HA after https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded

* Bump version and update readme

Bumped version and updated README with logger information (it was not straightforward to figure out both settings)
  • Loading branch information
robchandhok authored Feb 21, 2024
1 parent cd817c5 commit bf778a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,17 @@ If you are winding up having to do multiple restarts because Home Assistant won'

Alternatively, with the menu restructuring, the menu entry for _Stop Server_ isn't accessible. However you can use the keyboard short cut 'c' and type restart to find that choice. Once the server has stopped you can move the config entry in and do a `ha core start`

#### Debugging flags

If you do encounter issues, here are the logger settings in the Home Assistant configuration file you use to set debug or other levels of logging.

```
logger:
default: warning
logs:
custom_components.warmup.climate: debug
custom_components.warmup.warmup4ie.warmup4ie: debug
```
### Add your devices to the dashboard
Our wiki has some [ideas on how to configure warmup
Expand Down
16 changes: 15 additions & 1 deletion custom_components/warmup/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
CONF_USERNAME,
PRECISION_HALVES,
UnitOfTemperature,
MAJOR_VERSION,
MINOR_VERSION,
)

from homeassistant.exceptions import InvalidStateError, PlatformNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
Expand Down Expand Up @@ -67,7 +70,7 @@
CONST_MODE_OFF: HVACMode.OFF,
}

SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
SUPPORT_FLAGS = ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TURN_ON |ClimateEntityFeature.TURN_OFF
SUPPORT_HVAC_HEAT = [HVACMode.HEAT, HVACMode.AUTO, HVACMode.OFF]
SUPPORT_PRESET = [PRESET_AWAY, PRESET_HOME, PRESET_BOOST]

Expand Down Expand Up @@ -152,6 +155,9 @@ def __init__(self, hass, device: Warmup4IEDevice, client: WarmupClient):
self._away = False
self._on = True

# https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded
self._enable_turn_on_off_backwards_compatibility = False

@property
def name(self):
"""Return the name of the climate device."""
Expand Down Expand Up @@ -250,6 +256,14 @@ def set_hvac_mode(self, hvac_mode):
else:
raise InvalidStateError

def turn_on(self) -> None:
"""Turn the entity on."""
self.set_hvac_mode(HVACMode.AUTO)

def turn_off(self) -> None:
"""Turn the entity off."""
self.set_hvac_mode(HVACMode.OFF)

def set_override(self, temperature, until):
"""Set a temperature override for this thermostat."""
self._device.set_override(temperature, until)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/warmup/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/ha-warmup/warmup/issues/",
"requirements": [],
"version": "2024.2.7"
"version": "2024.2.8"
}

0 comments on commit bf778a8

Please sign in to comment.