Run unsubscribe callbacks when Assist satellite entity is removed from HA (#127234)

* Unsubscribe when removed from HA

* Use builtin async_on_remove
This commit is contained in:
Michael Hansen 2024-10-01 16:58:47 -05:00 committed by Franck Nijhof
parent 8c8a2eef21
commit 49708196ac
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3

View file

@ -212,7 +212,7 @@ class EsphomeAssistSatellite(
)
if feature_flags & VoiceAssistantFeature.API_AUDIO:
# TCP audio
self.entry_data.disconnect_callbacks.add(
self.async_on_remove(
self.cli.subscribe_voice_assistant(
handle_start=self.handle_pipeline_start,
handle_stop=self.handle_pipeline_stop,
@ -222,7 +222,7 @@ class EsphomeAssistSatellite(
)
else:
# UDP audio
self.entry_data.disconnect_callbacks.add(
self.async_on_remove(
self.cli.subscribe_voice_assistant(
handle_start=self.handle_pipeline_start,
handle_stop=self.handle_pipeline_stop,
@ -235,7 +235,7 @@ class EsphomeAssistSatellite(
assert (self.registry_entry is not None) and (
self.registry_entry.device_id is not None
)
self.entry_data.disconnect_callbacks.add(
self.async_on_remove(
async_register_timer_handler(
self.hass, self.registry_entry.device_id, self.handle_timer_event
)