Reduce task overhead in homekit_controller (#111670)
This commit is contained in:
parent
147c261389
commit
e62b709dea
1 changed files with 11 additions and 2 deletions
|
@ -330,12 +330,19 @@ class HKDevice:
|
||||||
self.config_entry.async_on_unload(
|
self.config_entry.async_on_unload(
|
||||||
async_track_time_interval(
|
async_track_time_interval(
|
||||||
self.hass,
|
self.hass,
|
||||||
self.async_request_update,
|
self._async_schedule_update,
|
||||||
self.pairing.poll_interval,
|
self.pairing.poll_interval,
|
||||||
name=f"HomeKit Device {self.unique_id} availability check poll",
|
name=f"HomeKit Device {self.unique_id} availability check poll",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_schedule_update(self, now: datetime) -> None:
|
||||||
|
"""Schedule an update."""
|
||||||
|
self.hass.async_create_task(
|
||||||
|
self._debounced_update.async_call(), eager_start=True
|
||||||
|
)
|
||||||
|
|
||||||
async def async_add_new_entities(self) -> None:
|
async def async_add_new_entities(self) -> None:
|
||||||
"""Add new entities to Home Assistant."""
|
"""Add new entities to Home Assistant."""
|
||||||
await self.async_load_platforms()
|
await self.async_load_platforms()
|
||||||
|
@ -685,7 +692,9 @@ class HKDevice:
|
||||||
|
|
||||||
def process_config_changed(self, config_num: int) -> None:
|
def process_config_changed(self, config_num: int) -> None:
|
||||||
"""Handle a config change notification from the pairing."""
|
"""Handle a config change notification from the pairing."""
|
||||||
self.hass.async_create_task(self.async_update_new_accessories_state())
|
self.hass.async_create_task(
|
||||||
|
self.async_update_new_accessories_state(), eager_start=True
|
||||||
|
)
|
||||||
|
|
||||||
async def async_update_new_accessories_state(self) -> None:
|
async def async_update_new_accessories_state(self) -> None:
|
||||||
"""Process a change in the pairings accessories state."""
|
"""Process a change in the pairings accessories state."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue