Skip to content

Commit 008d373

Browse files
committed
Use changeset feature to switch hvac_mode
This speeds up the switch-on cycle by setting mode & power simultaneously instead of sequentially
1 parent 4a56a9f commit 008d373

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

custom_components/mitsubishi/climate.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,16 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
188188
f"set HVAC mode to {hvac_mode}", self.coordinator.controller.set_power, False
189189
)
190190
else:
191+
changeset = self.coordinator.controller.changeset()
192+
changeset.set_power(PowerOnOff.ON)
193+
changeset.set_mode(MODE_HA_TO_MITSUBISHI[hvac_mode])
191194
# Set the mode
192195
await self._execute_command_with_refresh(
193196
f"set HVAC mode to {hvac_mode}",
194-
self.coordinator.controller.set_mode,
195-
MODE_HA_TO_MITSUBISHI[hvac_mode],
197+
self.coordinator.controller.apply_changeset,
198+
changeset,
196199
)
197200

198-
# Turn on if currently off
199-
# Set mode before setting power, so the unit can start in the correct mode
200-
if self.hvac_mode == HVACMode.OFF:
201-
await self._execute_command_with_refresh(
202-
"turn on device before setting mode",
203-
self.coordinator.controller.set_power,
204-
True,
205-
)
206-
207201
@property
208202
def hvac_action(self) -> HVACAction | None:
209203
"""Return the current running hvac operation."""

custom_components/mitsubishi/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"pymitsubishi"
1414
],
1515
"requirements": [
16-
"pymitsubishi==0.3.0"
16+
"pymitsubishi==0.4.0"
1717
],
1818
"version": "0.2.0"
1919
}

0 commit comments

Comments
 (0)