From d34c289691c6eca84ccce4b2f54da952371d1e00 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 9 Feb 2022 10:23:39 +0100 Subject: [PATCH] Clean up unneeded preset variable in Plugwise climate (#66151) --- homeassistant/components/plugwise/climate.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/plugwise/climate.py b/homeassistant/components/plugwise/climate.py index 5ecab66bbde..b3e7472369c 100644 --- a/homeassistant/components/plugwise/climate.py +++ b/homeassistant/components/plugwise/climate.py @@ -76,8 +76,6 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): self._loc_id = coordinator.data.devices[device_id]["location"] - self._presets = None - async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" temperature = kwargs.get(ATTR_TEMPERATURE) @@ -119,13 +117,13 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): async def async_set_preset_mode(self, preset_mode: str) -> None: """Set the preset mode.""" - if self._presets is None: + if not (presets := self.coordinator.data.devices[self._dev_id].get("presets")): raise ValueError("No presets available") try: await self.coordinator.api.set_preset(self._loc_id, preset_mode) self._attr_preset_mode = preset_mode - self._attr_target_temperature = self._presets.get(preset_mode, "none")[0] + self._attr_target_temperature = presets.get(preset_mode, "none")[0] self.async_write_ha_state() except PlugwiseException: LOGGER.error("Error while communicating to device") @@ -147,10 +145,8 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): # Presets handling self._attr_preset_mode = data.get("active_preset") if presets := data.get("presets"): - self._presets = presets self._attr_preset_modes = list(presets) else: - self._presets = None self._attr_preset_mode = None # Determine current hvac action