Skip to content

Commit

Permalink
Workaround for HC bug where updates are sent for the selected instead…
Browse files Browse the repository at this point in the history
… of active program
  • Loading branch information
ekutner committed Jan 15, 2025
1 parent 28ae2e9 commit 79532fe
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions home_connect_async/appliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,23 @@ async def async_update_data(self, data:dict) -> None:
self.commands = await self._async_fetch_commands()
await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED)

# elif ( not self.available_programs or len(self.available_programs) < 2) and \
# ( key in ["BSH.Common.Status.OperationState", "BSH.Common.Status.RemoteControlActive"] ) and \
# ( "BSH.Common.Status.OperationState" not in self.status or self.status["BSH.Common.Status.OperationState"].value == "BSH.Common.EnumType.OperationState.Ready" ) and \
# ( "BSH.Common.Status.RemoteControlActive" not in self.status or self.status["BSH.Common.Status.RemoteControlActive"].value):
# # Handle cases were the appliance data was loaded without getting all the programs (for example when HA is restarted while a program is active)
# # If the state is Ready and remote control is possible and we didn't load the available programs before then load them now
# available_programs = await self._async_fetch_programs("available")
# self.available_programs = available_programs
# await self._callbacks.async_broadcast_event(self, Events.PAIRED)
# await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED)


if self.selected_program and self.selected_program.options and key in self.selected_program.options:
self.selected_program.options[key].value = value
self.selected_program.options[key].name = data.get("name")
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.selected_program = await self._async_fetch_programs("selected")
await self._callbacks.async_broadcast_event(self, Events.DATA_CHANGED)
if not self.selected_program and \
self.active_program and self.active_program.options and key in self.active_program.options:
# This is a workaround for a HC bug where an event is reporting an option for the selected program
# instead of the active program but there is no selected program available
_LOGGER.debug("There is no select program, updating the active program instead with option: %s", data)
self.active_program.options[key].value = value
else:
_LOGGER.debug("Got event for unknown option: %s", data)
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:
self.active_program.options[key].value = value
Expand Down

0 comments on commit 79532fe

Please sign in to comment.