Lazy load zwave_js platforms when the first entity needs to be created (#49016)

* Lazy load zwave_js platforms when the first entity needs to be created

* switch order to make things easier to understand

* await task instead of using wait_for_done callback

* gather tasks

* switch from asyncio.create_task to hass.async_create_task

* unsubscribe from callbacks before unloading platforms

* Clean up as much as possible during entry unload, even if a platform unload fails
This commit is contained in:
Raman Gupta 2021-04-12 20:26:49 -04:00 committed by GitHub
parent 53853f035d
commit cc40e681e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 58 deletions

View file

@ -8,20 +8,10 @@ CONF_NETWORK_KEY = "network_key"
CONF_USB_PATH = "usb_path"
CONF_USE_ADDON = "use_addon"
DOMAIN = "zwave_js"
PLATFORMS = [
"binary_sensor",
"climate",
"cover",
"fan",
"light",
"lock",
"number",
"sensor",
"switch",
]
DATA_CLIENT = "client"
DATA_UNSUBSCRIBE = "unsubs"
DATA_PLATFORM_SETUP = "platform_setup"
EVENT_DEVICE_ADDED_TO_REGISTRY = f"{DOMAIN}_device_added_to_registry"