Skip to content

Commit

Permalink
Fix deprecation warnings on initialization (#24)
Browse files Browse the repository at this point in the history
* Fix deprecates uses of TEMP_CELSIUS

* Fix warning about ClimateEntityFeature usage

This adds ClimateEntityFeature.TURN_ON and ClimateEntityFeature.TURN_OFF
to supported features and disables the backwards compatibility flag
related to those. This prevents a warning at initialization.

Specific warning is:
Entity None (<class 'custom_components.wundasmart.climate.Device'>)
implements HVACMode(s): off, auto, heat and therefore implicitly
supports the turn_on/turn_off methods without setting the proper
ClimateEntityFeature. Please create a bug report at
https://github.com/tonyroberts/hawundasmart/issues

* Remove TURN_OFF and TURN_ON flags
  • Loading branch information
danelphick authored Mar 18, 2024
1 parent 74da2b5 commit e6b1165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions custom_components/wundasmart/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CONF_HOST,
CONF_USERNAME,
CONF_PASSWORD,
TEMP_CELSIUS,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -89,7 +89,7 @@ class Device(CoordinatorEntity[WundasmartDataUpdateCoordinator], ClimateEntity):
"""Representation of an Wundasmart climate."""

_attr_hvac_modes = SUPPORTED_HVAC_MODES
_attr_temperature_unit = TEMP_CELSIUS
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_preset_modes = SUPPORTED_PRESET_MODES
_attr_translation_key = DOMAIN

Expand All @@ -113,6 +113,10 @@ def __init__(
self._attr_unique_id = device["id"]
self._attr_type = device["device_type"]
self._attr_device_info = coordinator.device_info
# This flag needs to be set until 2025.1 to prevent warnings about
# implicitly supporting the turn_off/turn_on methods.
# https://developers.home-assistant.io/blog/2024/01/24/climate-climateentityfeatures-expanded/
self._enable_turn_on_off_backwards_compatibility = False
self._attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/wundasmart/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CONF_HOST,
CONF_USERNAME,
CONF_PASSWORD,
TEMP_CELSIUS,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import aiohttp_client, entity_platform
Expand Down Expand Up @@ -124,7 +124,7 @@ class Device(CoordinatorEntity[WundasmartDataUpdateCoordinator], WaterHeaterEnti

_attr_operation_list = list(sorted({ OPERATION_SET_AUTO } | HW_BOOST_OPERATIONS | HW_OFF_OPERATIONS, key=_split_operation))
_attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE
_attr_temperature_unit = TEMP_CELSIUS
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_translation_key = DOMAIN

def __init__(
Expand Down

0 comments on commit e6b1165

Please sign in to comment.