Skip to content

Commit

Permalink
Fix Vera race condition on start (#45535)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavoni authored Jan 26, 2021
1 parent ad677b9 commit d110d42
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions homeassistant/components/vera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
# Initialize the Vera controller.
subscription_registry = SubscriptionRegistry(hass)
controller = veraApi.VeraController(base_url, subscription_registry)
await hass.async_add_executor_job(controller.start)

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, controller.stop)

try:
all_devices = await hass.async_add_executor_job(controller.get_devices)
Expand Down Expand Up @@ -151,6 +148,13 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
hass.config_entries.async_forward_entry_setup(config_entry, platform)
)

def stop_subscription(event):
"""Stop SubscriptionRegistry updates."""
controller.stop()

await hass.async_add_executor_job(controller.start)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription)

return True


Expand Down

0 comments on commit d110d42

Please sign in to comment.