Clean up unneeded preset variable in Plugwise climate (#66151)
This commit is contained in:
parent
924bcdf269
commit
d34c289691
1 changed files with 2 additions and 6 deletions
|
@ -76,8 +76,6 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
||||||
|
|
||||||
self._loc_id = coordinator.data.devices[device_id]["location"]
|
self._loc_id = coordinator.data.devices[device_id]["location"]
|
||||||
|
|
||||||
self._presets = None
|
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temperature = kwargs.get(ATTR_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:
|
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||||
"""Set the preset mode."""
|
"""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")
|
raise ValueError("No presets available")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.coordinator.api.set_preset(self._loc_id, preset_mode)
|
await self.coordinator.api.set_preset(self._loc_id, preset_mode)
|
||||||
self._attr_preset_mode = 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()
|
self.async_write_ha_state()
|
||||||
except PlugwiseException:
|
except PlugwiseException:
|
||||||
LOGGER.error("Error while communicating to device")
|
LOGGER.error("Error while communicating to device")
|
||||||
|
@ -147,10 +145,8 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
|
||||||
# Presets handling
|
# Presets handling
|
||||||
self._attr_preset_mode = data.get("active_preset")
|
self._attr_preset_mode = data.get("active_preset")
|
||||||
if presets := data.get("presets"):
|
if presets := data.get("presets"):
|
||||||
self._presets = presets
|
|
||||||
self._attr_preset_modes = list(presets)
|
self._attr_preset_modes = list(presets)
|
||||||
else:
|
else:
|
||||||
self._presets = None
|
|
||||||
self._attr_preset_mode = None
|
self._attr_preset_mode = None
|
||||||
|
|
||||||
# Determine current hvac action
|
# Determine current hvac action
|
||||||
|
|
Loading…
Add table
Reference in a new issue