mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-09-27 04:22:46 +02:00
Fix voice assistant start task getting prematurely garbage collected (#753)
This commit is contained in:
parent
91b0f1abba
commit
b84a07cd0c
@ -1267,6 +1267,8 @@ class APIClient:
|
|||||||
self._connection.send_message(VoiceAssistantResponse(error=True))
|
self._connection.send_message(VoiceAssistantResponse(error=True))
|
||||||
|
|
||||||
def _on_voice_assistant_request(msg: VoiceAssistantRequest) -> None:
|
def _on_voice_assistant_request(msg: VoiceAssistantRequest) -> None:
|
||||||
|
nonlocal start_task
|
||||||
|
|
||||||
command = VoiceAssistantCommand.from_pb(msg)
|
command = VoiceAssistantCommand.from_pb(msg)
|
||||||
if command.start:
|
if command.start:
|
||||||
start_task = asyncio.create_task(
|
start_task = asyncio.create_task(
|
||||||
@ -1289,6 +1291,8 @@ class APIClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def unsub() -> None:
|
def unsub() -> None:
|
||||||
|
nonlocal start_task
|
||||||
|
|
||||||
if self._connection is not None:
|
if self._connection is not None:
|
||||||
remove_callback()
|
remove_callback()
|
||||||
self._connection.send_message(
|
self._connection.send_message(
|
||||||
|
Loading…
Reference in New Issue
Block a user