From 3994bbb8a79efe36ba5fa4e2f87c47858a5d2a1b Mon Sep 17 00:00:00 2001 From: Eran Kutner <5628151+ekutner@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:27:45 +0200 Subject: [PATCH] Fix event handling bugs --- home_connect_async/appliance.py | 12 ++++++------ setup.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/home_connect_async/appliance.py b/home_connect_async/appliance.py index d43dff4..b7d704a 100644 --- a/home_connect_async/appliance.py +++ b/home_connect_async/appliance.py @@ -510,7 +510,7 @@ async def async_update_data(self, data:dict) -> None: #self.available_programs = await self._async_fetch_programs("available") await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED) self._active_program_fail_count = 0 - + elif ( # (key == "BSH.Common.Root.ActiveProgram" and value) or # NOTE: It seems that the ActiveProgam event is received before the API returns the active program so let's try to ignore it and rely on the OperationState only # Apparently it is possible to get progress notifications without getting the Run OperationState first so we handle that # but we want to give the OperationState event a chance to be received so we wait until the second progress event before we handle it as an active program @@ -557,7 +557,7 @@ async def async_update_data(self, data:dict) -> None: await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED) elif key == "BSH.Common.Status.OperationState" and value == "BSH.Common.EnumType.OperationState.Ready" \ - and self.status.get("BSH.Common.Status.OperationState", {"value": None}).value != value: # ignore repeating events + and ("BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value != value): # ignore repeating events prev_prog = self.active_program.key if self.active_program else None self.active_program = None self._active_program_fail_count = 0 @@ -571,7 +571,7 @@ async def async_update_data(self, data:dict) -> None: await self._callbacks.async_broadcast_event(self, Events.PROGRAM_FINISHED, prev_prog) elif key == "BSH.Common.Status.OperationState" and value == "BSH.Common.EnumType.OperationState.Inactive" \ - and self.status.get("BSH.Common.Status.OperationState", {"value": None}).value != value: + and ("BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value != value): self.active_program = None self._active_program_fail_count = 0 self.selected_program = None @@ -580,12 +580,12 @@ async def async_update_data(self, data:dict) -> None: await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED) elif key == "BSH.Common.Status.OperationState" and value == "BSH.Common.EnumType.OperationState.Pause" \ - and self.status.get("BSH.Common.Status.OperationState", {"value": None}).value != value: + and ("BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value != value): self.commands = await self._async_fetch_commands() elif key == "BSH.Common.Status.OperationState" \ and value in [ "BSH.Common.EnumType.OperationState.ActionRequired", "BSH.Common.EnumType.OperationState.Error", "BSH.Common.EnumType.OperationState.Aborting" ] \ - and self.status.get("BSH.Common.Status.OperationState", {"value": None}).value != value: + and ("BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value != value): _LOGGER.debug("The appliance entered and error operation state: %s", data) elif key =="BSH.Common.Status.RemoteControlStartAllowed": @@ -610,7 +610,7 @@ async def async_update_data(self, data:dict) -> None: self.selected_program.options[key].displayvalue = data.get("displayvalue") elif "programs/selected" in uri and key != "BSH.Common.Root.SelectedProgram": _LOGGER.debug("Got event for unknown property: %s", data) - self.active_program = await self._async_fetch_programs("selected") + self.selected_program = await self._async_fetch_programs("selected") await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED) if self.active_program and self.active_program.options and key in self.active_program.options: diff --git a/setup.py b/setup.py index fce3331..0dd3705 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = 'home-connect-async', packages = ['home_connect_async'], - version = '0.7.13', + version = '0.7.14', license='MIT', description = 'Async SDK for BSH Home Connect API', author = 'Eran Kutner',