Skip to content

Commit

Permalink
Don't raise an error if preset mode is un-set
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
tonyroberts committed Nov 15, 2023
1 parent a7b0e8a commit c8888be
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions custom_components/wundasmart/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,26 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode):
await self.coordinator.async_request_refresh()

async def async_set_preset_mode(self, preset_mode) -> None:
state_key = PRESET_MODE_STATE_KEYS.get(preset_mode)
if state_key is None:
raise NotImplementedError(f"Unsupported Preset mode {preset_mode}")

t_preset = float(self.__state[state_key])

await send_command(
self._session,
self._wunda_ip,
self._wunda_user,
self._wunda_pass,
params={
"cmd": 1,
"roomid": self._wunda_id,
"temp": t_preset,
"locktt": 0,
"time": 0,
},
)
if preset_mode:
state_key = PRESET_MODE_STATE_KEYS.get(preset_mode)
if state_key is None:
raise NotImplementedError(f"Unsupported Preset mode {preset_mode}")

t_preset = float(self.__state[state_key])

await send_command(
self._session,
self._wunda_ip,
self._wunda_user,
self._wunda_pass,
params={
"cmd": 1,
"roomid": self._wunda_id,
"temp": t_preset,
"locktt": 0,
"time": 0,
},
)

# Fetch the updated state
await self.coordinator.async_request_refresh()

0 comments on commit c8888be

Please sign in to comment.