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

Commit

Permalink
fix: 🐛 #26 fix improper exception handling during automation calls (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyrak authored May 13, 2024
1 parent 15646f9 commit ff4d85b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/aladdin_connect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,15 @@ async def _set_door_status(self, door: DoorDevice, desired_status: DoorStatus) -

data = await response.json()
self.log.debug(f'[API] Genie {command} response: {data}')

except Exception as error:
self.log.error(f'[API] An error occurred sending command {command} to door {door.name}; {error}')
return False
# Ignore "Door is already open/closed" errors to maintain backwards compatibility
should_ignore = (
f'{{"code":400,"error":"Door is already {desired_status}"}}'
in str(error.args[0])
)
if not should_ignore:
self.log.error(f'[API] An error occurred sending command {command} to door {door.name}; {error}')
return False

await self._invalidate_door_cache(door)
door.status = desired_status
Expand Down

0 comments on commit ff4d85b

Please sign in to comment.