From 7542b7c2c8e0708d34ea1004d9d55fbe37958da2 Mon Sep 17 00:00:00 2001 From: Eran Kutner <5628151+ekutner@users.noreply.github.com> Date: Wed, 8 Nov 2023 00:21:26 +0200 Subject: [PATCH] Fix state fetch logic for OperationState==Inactive --- home_connect_async/appliance.py | 14 ++++++++++++-- setup.py | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/home_connect_async/appliance.py b/home_connect_async/appliance.py index b7d704a..3ce43f9 100644 --- a/home_connect_async/appliance.py +++ b/home_connect_async/appliance.py @@ -575,8 +575,18 @@ async def async_update_data(self, data:dict) -> None: self.active_program = None self._active_program_fail_count = 0 self.selected_program = None - self.available_programs = None - self.commands = {} + # It appears that there are appliances, like Hood that can be inactive, or even powered off, + # but still have available programs that can be started with a call to start_program. + # However, we only want to fetch the available program if we we're in a state that already fetched them + if "BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value != "BSH.Common.EnumType.OperationState.Ready": + self.available_programs = await self._async_fetch_programs("available") + + # Update the commands only if they weren't updated in the previous state + if "BSH.Common.Status.OperationState" not in self.status or \ + self.status["BSH.Common.Status.OperationState"].value not in \ + ["BSH.Common.EnumType.OperationState.Finished", "BSH.Common.EnumType.OperationState.Ready"]: + self.commands = await self._async_fetch_commands() + await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED) elif key == "BSH.Common.Status.OperationState" and value == "BSH.Common.EnumType.OperationState.Pause" \ diff --git a/setup.py b/setup.py index 0dd3705..13b5777 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = 'home-connect-async', packages = ['home_connect_async'], - version = '0.7.14', + version = '0.7.15', license='MIT', description = 'Async SDK for BSH Home Connect API', author = 'Eran Kutner',