Skip to content

Commit 2a9d3d2

Browse files
authored
Add PRESET_NONE to supported preset modes (#54)
Fixes #49
1 parent aa53d7b commit 2a9d3d2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

custom_components/wundasmart/climate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
HVACAction,
1313
HVACMode,
1414
PRESET_ECO,
15-
PRESET_COMFORT
15+
PRESET_COMFORT,
16+
PRESET_NONE
1617
)
1718
from homeassistant.config_entries import ConfigEntry
1819
from homeassistant.const import (
@@ -43,6 +44,7 @@
4344
PRESET_REDUCED = "reduced"
4445

4546
SUPPORTED_PRESET_MODES = [
47+
PRESET_NONE,
4648
PRESET_REDUCED,
4749
PRESET_ECO,
4850
PRESET_COMFORT
@@ -140,7 +142,7 @@ def __init__(
140142
self._attr_target_temperature = None
141143
self._attr_current_humidity = None
142144
self._attr_hvac_mode = HVACMode.AUTO
143-
self._attr_preset_mode = None
145+
self._attr_preset_mode = PRESET_NONE
144146
self._timeout = timeout
145147

146148
# Update with initial state
@@ -227,7 +229,7 @@ def __set_preset_mode(self):
227229
except (ValueError, TypeError):
228230
_LOGGER.warning(f"Unexpected {state_key} value '{state[state_key]}' for {self._attr_name}")
229231
else:
230-
self._attr_preset_mode = None
232+
self._attr_preset_mode = PRESET_NONE
231233

232234
def __set_hvac_state(self):
233235
"""Set the hvac action and hvac mode from the coordinator data."""
@@ -373,7 +375,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode):
373375
await self.coordinator.async_request_refresh()
374376

375377
async def async_set_preset_mode(self, preset_mode) -> None:
376-
if preset_mode:
378+
if preset_mode and preset_mode != PRESET_NONE:
377379
state_key = PRESET_MODE_STATE_KEYS.get(preset_mode)
378380
if state_key is None:
379381
raise NotImplementedError(f"Unsupported Preset mode {preset_mode}")

0 commit comments

Comments
 (0)