mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-27 17:37:39 +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:
|
def unsub() -> None:
|
||||||
assert self._connection is not None
|
if self._connection is not None:
|
||||||
self._connection.remove_message_callback(on_msg)
|
self._connection.remove_message_callback(on_msg)
|
||||||
|
|
||||||
return unsub
|
return unsub
|
||||||
|
|
||||||
@ -442,8 +442,8 @@ class APIClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def unsub() -> None:
|
def unsub() -> None:
|
||||||
assert self._connection is not None
|
if self._connection is not None:
|
||||||
self._connection.remove_message_callback(on_msg)
|
self._connection.remove_message_callback(on_msg)
|
||||||
|
|
||||||
return unsub
|
return unsub
|
||||||
|
|
||||||
@ -474,8 +474,8 @@ class APIClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def unsub() -> None:
|
def unsub() -> None:
|
||||||
assert self._connection is not None
|
if self._connection is not None:
|
||||||
self._connection.remove_message_callback(on_msg)
|
self._connection.remove_message_callback(on_msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
@ -633,7 +633,9 @@ class APIClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def stop_notify() -> None:
|
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._connection.remove_message_callback(on_msg)
|
||||||
|
|
||||||
self._check_authenticated()
|
self._check_authenticated()
|
||||||
|
Loading…
Reference in New Issue
Block a user