From da6fb8d32a69e72acb0d7fbfcda7ce5d5c2fca31 Mon Sep 17 00:00:00 2001 From: Jerome Garec Date: Thu, 3 Mar 2022 08:03:23 +0000 Subject: [PATCH] tetienne review --- .../atlantic_pass_apc_heating_zone.py | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/custom_components/tahoma/climate_devices/atlantic_pass_apc_heating_zone.py b/custom_components/tahoma/climate_devices/atlantic_pass_apc_heating_zone.py index f7167a07..e842c551 100644 --- a/custom_components/tahoma/climate_devices/atlantic_pass_apc_heating_zone.py +++ b/custom_components/tahoma/climate_devices/atlantic_pass_apc_heating_zone.py @@ -2,6 +2,8 @@ import logging from typing import List, Optional +from pyoverkiz.enums import OverkizState + from homeassistant.components.climate import ( SUPPORT_PRESET_MODE, SUPPORT_TARGET_TEMPERATURE, @@ -92,15 +94,15 @@ class AtlanticPassAPCHeatingZone(OverkizEntity, ClimateEntity): """Representation of Atlantic Pass APC Heating and Cooling Zone.""" _attr_hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_AUTO] + _attr_max_temp = 30 + _attr_min_temp = 5 _attr_supported_features = SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE _attr_temperature_unit = TEMP_CELSIUS def __init__(self, device_url: str, coordinator: OverkizDataUpdateCoordinator): """Init method.""" super().__init__(device_url, coordinator) - - self._temp_sensor_entity_id = None - self._current_temperature = None + self.temperature_device = self.executor.linked_device(8) @property def preset_modes(self) -> Optional[List[str]]: @@ -118,14 +120,14 @@ def preset_modes(self) -> Optional[List[str]]: CUSTOM_PRESET_STOP, PRESET_AWAY, ] - else: - return [ - PRESET_COMFORT, - PRESET_ECO, - CUSTOM_PRESET_AUTO, - CUSTOM_PRESET_STOP, - PRESET_AWAY, - ] + + return [ + PRESET_COMFORT, + PRESET_ECO, + CUSTOM_PRESET_AUTO, + CUSTOM_PRESET_STOP, + PRESET_AWAY, + ] @property def preset_mode(self) -> Optional[str]: @@ -228,20 +230,12 @@ def update_temp(self, state): except ValueError as ex: _LOGGER.error("Unable to update from sensor: %s", ex) - @property - def min_temp(self) -> float: - """Return the minimum temperature.""" - return 5 - - @property - def max_temp(self) -> float: - """Return the maximum temperature.""" - return 30 - @property def current_temperature(self) -> Optional[float]: """Return the current temperature.""" - return self._current_temperature + return float( + self.temperature_device.states.get(OverkizState.CORE_TEMPERATURE).value + ) @property def hvac_mode(self) -> str: