From b1a3b5dc17cdc44a2446f98081d07bc9e50a3a9e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 Mar 2021 12:51:52 -1000 Subject: [PATCH] Update example with async_config_entry_first_refresh (#870) --- docs/integration_fetching_data.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/integration_fetching_data.md b/docs/integration_fetching_data.md index d60fc921..7098fcb6 100644 --- a/docs/integration_fetching_data.md +++ b/docs/integration_fetching_data.md @@ -76,8 +76,16 @@ async def async_setup_entry(hass, entry, async_add_entities): update_interval=timedelta(seconds=30), ) + # # Fetch initial data so we have data when entities subscribe - await coordinator.async_refresh() + # + # If the refresh fails, async_config_entry_first_refresh will + # raise ConfigEntryNotReady and setup will try again later + # + # If you do not want to retry setup on failure, use + # coordinator.async_refresh() instead + # + await coordinator.async_config_entry_first_refresh() async_add_entities( MyEntity(coordinator, idx) for idx, ent in enumerate(coordinator.data)