mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-13 04:16:29 +00:00
Update example with async_config_entry_first_refresh (#870)
This commit is contained in:
parent
a3fbbee6ea
commit
b1a3b5dc17
@ -76,8 +76,16 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||||||
update_interval=timedelta(seconds=30),
|
update_interval=timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#
|
||||||
# Fetch initial data so we have data when entities subscribe
|
# 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(
|
async_add_entities(
|
||||||
MyEntity(coordinator, idx) for idx, ent in enumerate(coordinator.data)
|
MyEntity(coordinator, idx) for idx, ent in enumerate(coordinator.data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user