Convert person start to be a callback function (#111571)

Nothing was being awaited here so there was no need to create
a task per person at the start event.

The async_update_config coro remains since its required
by the collection but is now a wrapper around a callback
_async_update_config
This commit is contained in:
J. Nick Koston 2024-02-26 16:04:33 -10:00 committed by GitHub
parent ebdfff4037
commit 1e3af1b48f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -482,18 +482,24 @@ class Person(collection.CollectionEntity, RestoreEntity):
if self.hass.is_running: if self.hass.is_running:
# Update person now if hass is already running. # Update person now if hass is already running.
await self.async_update_config(self._config) self._async_update_config(self._config)
else: else:
# Wait for hass start to not have race between person # Wait for hass start to not have race between person
# and device trackers finishing setup. # and device trackers finishing setup.
async def person_start_hass(_: Event) -> None: @callback
await self.async_update_config(self._config) def _async_person_start_hass(_: Event) -> None:
self._async_update_config(self._config)
self.hass.bus.async_listen_once( self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, person_start_hass EVENT_HOMEASSISTANT_START, _async_person_start_hass
) )
async def async_update_config(self, config: ConfigType) -> None: async def async_update_config(self, config: ConfigType) -> None:
"""Handle when the config is updated."""
self._async_update_config(config)
@callback
def _async_update_config(self, config: ConfigType) -> None:
"""Handle when the config is updated.""" """Handle when the config is updated."""
self._config = config self._config = config