Update zhong_hong to use async_add_executor_job (#41846)

This commit is contained in:
J. Nick Koston 2020-10-15 15:39:48 -05:00 committed by GitHub
parent 9270585a44
commit a220e74154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -87,6 +87,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
hub_is_initialized = False
def _start_hub():
"""Start the hub socket and query status of all devices."""
hub.start_listen()
hub.query_all_status()
async def startup():
"""Start hub socket after all climate entity is set up."""
nonlocal hub_is_initialized
@ -97,8 +102,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
return
_LOGGER.debug("zhong_hong hub start listen event")
await hass.async_add_job(hub.start_listen)
await hass.async_add_job(hub.query_all_status)
await hass.async_add_executor_job(_start_hub)
hub_is_initialized = True
async_dispatcher_connect(hass, SIGNAL_DEVICE_ADDED, startup)