From 410f95bc816b560b10b09aa4d1ece5f8adc8f1b0 Mon Sep 17 00:00:00 2001 From: CyrilP <5814027+CyrilP@users.noreply.github.com> Date: Fri, 9 Feb 2024 20:05:45 +0100 Subject: [PATCH] Fix warnings introduced in HA 2024.2 (#51) * fix Warnings introduced in HA 2024.2 * remove buggy error log --- .../deltadore_tydom/ha_entities.py | 40 ++++++++----------- custom_components/deltadore_tydom/hub.py | 1 - 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/custom_components/deltadore_tydom/ha_entities.py b/custom_components/deltadore_tydom/ha_entities.py index c54be5f..be79615 100644 --- a/custom_components/deltadore_tydom/ha_entities.py +++ b/custom_components/deltadore_tydom/ha_entities.py @@ -25,17 +25,11 @@ from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, - SUPPORT_CLOSE, - SUPPORT_OPEN, - SUPPORT_SET_POSITION, - SUPPORT_STOP, - SUPPORT_SET_TILT_POSITION, - SUPPORT_OPEN_TILT, - SUPPORT_CLOSE_TILT, - SUPPORT_STOP_TILT, CoverEntity, CoverDeviceClass, + CoverEntityFeature, ) + from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass, SensorEntity from homeassistant.components.light import LightEntity from homeassistant.components.lock import LockEntity @@ -455,18 +449,18 @@ def __init__(self, device: TydomShutter, hass) -> None: if hasattr(device, "position"): self.supported_features = ( self.supported_features - | SUPPORT_SET_POSITION - | SUPPORT_OPEN - | SUPPORT_CLOSE - | SUPPORT_STOP + | CoverEntityFeature.SET_POSITION + | CoverEntityFeature.OPEN + | CoverEntityFeature.CLOSE + | CoverEntityFeature.STOP ) if hasattr(device, "slope"): self.supported_features = ( self.supported_features - | SUPPORT_SET_TILT_POSITION - | SUPPORT_OPEN_TILT - | SUPPORT_CLOSE_TILT - | SUPPORT_STOP_TILT + | CoverEntityFeature.SET_TILT_POSITION + | CoverEntityFeature.OPEN_TILT + | CoverEntityFeature.CLOSE_TILT + | CoverEntityFeature.STOP_TILT ) @property @@ -613,6 +607,13 @@ def __init__(self, device: TydomBoiler, hass) -> None: self._device._ha_device = self self._attr_unique_id = f"{self._device.device_id}_climate" self._attr_name = self._device.device_name + self._enable_turn_on_off_backwards_compatibility = False + self._attr_supported_features = ( + self._attr_supported_features + | ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.TURN_OFF + | ClimateEntityFeature.TURN_ON + ) # self._attr_preset_modes = ["NORMAL", "STOP", "ANTI_FROST"] self._attr_hvac_modes = [ @@ -628,13 +629,6 @@ def __init__(self, device: TydomBoiler, hass) -> None: if "max" in self._device._metadata["setpoint"]: self._attr_max_temp = self._device._metadata["setpoint"]["max"] - @property - def supported_features(self) -> ClimateEntityFeature: - """Return the list of supported features.""" - features = ClimateEntityFeature(0) - features = features | ClimateEntityFeature.TARGET_TEMPERATURE #| ClimateEntityFeature.PRESET_MODE - return features - @property def device_info(self) -> DeviceInfo: """Information about this entity/device.""" diff --git a/custom_components/deltadore_tydom/hub.py b/custom_components/deltadore_tydom/hub.py index fa26f3f..38b2129 100644 --- a/custom_components/deltadore_tydom/hub.py +++ b/custom_components/deltadore_tydom/hub.py @@ -143,7 +143,6 @@ async def create_ha_device(self, device): match device: case Tydom(): LOGGER.debug("Create Tydom gateway %s", device.device_id) - LOGGER.error("Tydom gateway %s", device._tydom_client) self.devices[device.device_id] = device ha_device = HATydom(device, self._hass, self._entry) self.ha_devices[device.device_id] = ha_device