Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix set quick mode from climate (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgermain authored May 10, 2022
1 parent 0648b31 commit 76266ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
33 changes: 25 additions & 8 deletions custom_components/multimatic/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def set_room_operating_mode(self, entity, mode):
room.quick_veto = None

if isinstance(mode, QuickMode):
await self._manager.set_quick_mode(mode)
await self._hard_set_quick_mode(mode)
self._quick_mode = mode
touch_system = True
else:
Expand All @@ -301,7 +301,7 @@ async def set_zone_operating_mode(self, entity, mode):
zone.quick_veto = None

if isinstance(mode, QuickMode):
await self._manager.set_quick_mode(mode)
await self._hard_set_quick_mode(mode)
self._quick_mode = mode
touch_system = True
else:
Expand Down Expand Up @@ -337,11 +337,7 @@ async def set_holiday_mode(self, start_date, end_date, temperature):
async def set_quick_mode(self, mode, duration):
"""Set quick mode (remove previous one)."""
await self._remove_quick_mode_no_refresh()
if duration is None and mode == QuickModes.COOLING_FOR_X_DAYS.name:
duration = 1
qmode = QuickModes.get(mode, duration)
await self._manager.set_quick_mode(qmode)
self._quick_mode = qmode
self._quick_mode = await self._hard_set_quick_mode(mode, duration)
await self._refresh_entities()

async def set_quick_veto(self, entity, temperature, duration=None):
Expand Down Expand Up @@ -380,7 +376,7 @@ async def set_fan_operating_mode(self, entity, mode: Mode):
touch_system = await self._remove_quick_mode_or_holiday(entity)

if isinstance(mode, QuickMode):
await self._manager.set_quick_mode(mode)
await self._hard_set_quick_mode(mode)
self._quick_mode = mode
touch_system = True
else:
Expand Down Expand Up @@ -416,6 +412,27 @@ async def _hard_remove_quick_mode(self):
await self._manager.remove_quick_mode()
self._quick_mode = None

async def _hard_set_quick_mode(
self, mode: str | QuickMode, duration: int = None
) -> QuickMode:
new_mode: QuickMode

if isinstance(mode, QuickMode):
new_mode = mode
if (
mode.name == QuickModes.COOLING_FOR_X_DAYS.name
and mode.duration is None
):
new_mode = QuickModes.get(mode.name, 1)
else:
new_duration = duration
if mode == QuickModes.COOLING_FOR_X_DAYS.name and duration is None:
new_duration = 1
new_mode = QuickModes.get(mode, new_duration)

await self._manager.set_quick_mode(new_mode)
return new_mode

async def _remove_holiday_mode_no_refresh(self):
await self._manager.remove_holiday_mode()
self._holiday_mode = HolidayMode(False)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/multimatic/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"codeowners": [
"@thomasgermain"
],
"version": "1.12.6",
"version": "1.12.7",
"iot_class": "cloud_polling"
}

0 comments on commit 76266ea

Please sign in to comment.