mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Defer esphome persistent storage writes until after startup (#42600)
Avoid disk I/O during startup as it can cause delays when a user has many esphome devices.
This commit is contained in:
parent
2bbd2a6e70
commit
8a403cde00
@ -31,6 +31,8 @@ if TYPE_CHECKING:
|
||||
|
||||
DATA_KEY = "esphome"
|
||||
|
||||
SAVE_DELAY = 120
|
||||
|
||||
# Mapping from ESPHome info type to HA platform
|
||||
INFO_TYPE_TO_PLATFORM = {
|
||||
BinarySensorInfo: "binary_sensor",
|
||||
@ -159,7 +161,7 @@ class RuntimeEntryData:
|
||||
for service in self.services.values():
|
||||
store_data["services"].append(service.to_dict())
|
||||
|
||||
await self.store.async_save(store_data)
|
||||
self.store.async_delay_save(lambda: store_data, SAVE_DELAY)
|
||||
|
||||
|
||||
def _attr_obj_from_dict(cls, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user