Add storage for cacheable homekit entity maps.#23191
Add storage for cacheable homekit entity maps.#23191balloob merged 1 commit intohome-assistant:devfrom
Conversation
|
|
||
| hass.data[CONTROLLER] = controller = homekit.Controller() | ||
|
|
||
| for hkid, pairing_data in load_old_pairings(hass).items(): |
There was a problem hiding this comment.
This does I/O, which isn't allowed in a coroutine. Please add it as an executor job.
There was a problem hiding this comment.
Oops. We already made this async in config flow and hadn't originally split this PR apart from config flow. Will fix this one now.
| return | ||
| for accessory in data: | ||
|
|
||
| self.hass.data[ENTITY_MAP].async_create_or_update_map( |
There was a problem hiding this comment.
Don't call async functions from sync context and vice versa.
There was a problem hiding this comment.
It's not actually a coroutine, but it does call store.async_delay_save and is, I believe, 'async safe'. So I could mark it with @callback or drop the async_ prefix?
There was a problem hiding this comment.
Async callbacks should also only be executed in the event loop.
|
I would recommend not adding this to 0.92. Let it go out in 0.93 and the config entry can come in 0.94. |
Description:
Non-breaking change to cache the output of
/accessoriesin a storage. This data should be refreshed when a change is announced by the device (the c# zeroconf field for IP, the same field in the Manufacturer Data field for BLE). The goal of this is:I've tested pairing from a clean env, and i've tested upgrading an existing env. Works as expected in both cases.
This is the last change before the main homekit_controller config entries pull request. I'd like to get this PR into a release and then do config entries in release after. After config entires is merged coverage will be high enough to remove homekit_controller from coveragerc!
Checklist:
tox. Your PR cannot be merged unless tests pass