Skip to content

Commit

Permalink
Fix callbacks list update
Browse files Browse the repository at this point in the history
  • Loading branch information
kvj committed Apr 16, 2022
1 parent 87f4d4a commit 5f75bac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/nuki_ng/nuki.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ async def bridge_check_callback(self, callback: str):
callbacks_list = callbacks.get("callbacks", [])
if len(callbacks_list) and callbacks_list[0]["url"] == callback:
_LOGGER.debug("Callback is set")
return callbacks
return callbacks_list
add_callbacks = [callback]
for item in callbacks.get("callbacks", []):
for item in callbacks_list:
if item["url"] != callback:
add_callbacks.append(item["url"])
await self.bridge_remove_callback(item["url"])
Expand All @@ -164,9 +164,10 @@ async def bridge_check_callback(self, callback: str):
if not result.get("success", True):
raise ConnectionError(result.get("message"))
_LOGGER.debug("Callback is set - re-added")
return await self.async_json(
callbacks = await self.async_json(
lambda r: r.get(self.bridge_url("/callback/list"))
)
return callbacks.get("callbacks", [])

def web_url(self, path):
return f"https://api.nuki.io{path}"
Expand Down

0 comments on commit 5f75bac

Please sign in to comment.