msg = f"Builtin provider {prov_manifest.name} can not be removed."
raise RuntimeError(msg)
self.remove(conf_key)
- await self.mass.unload_provider(instance_id)
+ await self.mass.unload_provider(instance_id, True)
if existing["type"] == "music":
# cleanup entries in library
await self.mass.music.cleanup_provider(instance_id)
if dep_prov.manifest.depends_on == prov_conf.domain:
await self.unload_provider(dep_prov.instance_id)
- async def unload_provider(self, instance_id: str) -> None:
+ async def unload_provider(self, instance_id: str, is_removed: bool = False) -> None:
"""Unload a provider."""
if provider := self._providers.get(instance_id):
# remove mdns discovery if needed
player.available = False
self.players.update(player.player_id)
try:
- await provider.unload()
+ await provider.unload(is_removed)
except Exception as err:
LOGGER.warning("Error while unload provider %s: %s", provider.name, str(err))
finally:
async def loaded_in_mass(self) -> None:
"""Call after the provider has been loaded."""
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
Called when provider is deregistered (e.g. MA exiting or config reloading).
+ is_removed will be set to True when the provider is removed from the configuration.
"""
async def on_mdns_service_state_change(
# relevant or leave out completely if not needed.
# In most cases this can be omitted for music providers.
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
Called when provider is deregistered (e.g. MA exiting or config reloading).
+ is_removed will be set to True when the provider is removed from the configuration.
"""
# OPTIONAL
# This is an optional method that you can implement if
# you can use this for instance to trigger custom (non-mdns) discovery of players
# or any other logic that needs to run after the provider is fully loaded.
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
Called when provider is deregistered (e.g. MA exiting or config reloading).
+ is_removed will be set to True when the provider is removed from the configuration.
"""
# OPTIONAL
# this is an optional method that you can implement if
# handle new player
await self._setup_player(player_id, display_name, info)
- async def unload(self) -> None:
- """Handle close/cleanup of the provider."""
+ async def unload(self, is_removed: bool = False) -> None:
+ """Handle unload/close of the provider."""
# power off all players (will disconnect and close cliraop)
for player_id in self._players:
await self.cmd_power(player_id, False)
# start discovery in executor
await self.mass.loop.run_in_executor(None, self.browser.start_discovery)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Handle close/cleanup of the provider."""
if not self.browser:
return
self.upnp_factory = UpnpFactory(self.requester, non_strict=True)
self.notify_server = DLNANotifyServer(self.requester, self.mass)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
await self.check_write_access()
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
raise SetupFailedError(err_msg) from err
self._listen_task = self.mass.create_task(self._hass_listener())
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
self.mass.subscribe(self._on_mass_player_added_event, EventType.PLAYER_ADDED)
)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
self.logger.debug(f"SXM Proxy server running at {bind_ip}:{bind_port}")
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""
Handle unload/close of the provider.
"/slimproto/multi", self._serve_multi_client_stream
)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Handle close/cleanup of the provider."""
self.mass.streams.unregister_dynamic_route("/slimproto/multi")
await self.slimproto.stop()
# initial load of players
self._handle_update()
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Handle close/cleanup of the provider."""
self._stop_called = True
for snap_client_id in self._snapserver.clients:
)
)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Unload the player (disconnect + cleanup)."""
await self._disconnect()
self.mass.players.remove(self.player_id, False)
"/sonos_queue/v2.3/timePlayed", self._handle_sonos_queue_time_played
)
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Handle close/cleanup of the provider."""
# disconnect all players
await asyncio.gather(*(player.unload() for player in self.sonos_players.values()))
self.creation_lock = asyncio.Lock()
self._known_invisible: set[SoCo] = set()
- async def unload(self) -> None:
+ async def unload(self, is_removed: bool = False) -> None:
"""Handle close/cleanup of the provider."""
if self._discovery_reschedule_timer:
self._discovery_reschedule_timer.cancel()