mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-26 17:27:40 +01:00
Only try remove callbacks when not None (#268)
This commit is contained in:
parent
fa41b09232
commit
a6f18ae9df
@ -421,8 +421,8 @@ class APIClient:
|
||||
)
|
||||
|
||||
def unsub() -> None:
|
||||
assert self._connection is not None
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
if self._connection is not None:
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
|
||||
return unsub
|
||||
|
||||
@ -442,8 +442,8 @@ class APIClient:
|
||||
)
|
||||
|
||||
def unsub() -> None:
|
||||
assert self._connection is not None
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
if self._connection is not None:
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
|
||||
return unsub
|
||||
|
||||
@ -474,8 +474,8 @@ class APIClient:
|
||||
)
|
||||
|
||||
def unsub() -> None:
|
||||
assert self._connection is not None
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
if self._connection is not None:
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
|
||||
try:
|
||||
async with async_timeout.timeout(timeout):
|
||||
@ -633,7 +633,9 @@ class APIClient:
|
||||
)
|
||||
|
||||
async def stop_notify() -> None:
|
||||
assert self._connection is not None
|
||||
if self._connection is None:
|
||||
return
|
||||
|
||||
self._connection.remove_message_callback(on_msg)
|
||||
|
||||
self._check_authenticated()
|
||||
|
Loading…
Reference in New Issue
Block a user