Fix async_config_entry_first_refresh used after config entry is loaded in speedtestdotcom (#129527)

* Fix async_config_entry_first_refresh used after config entry is loaded in speedtestdotcom

* is
This commit is contained in:
G Johansson 2024-10-30 21:17:03 +01:00 committed by Bram Kragten
parent bf3f1b4b49
commit d7e304badf

View File

@ -6,7 +6,7 @@ from functools import partial
import speedtest
from homeassistant.config_entries import ConfigEntry
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
@ -35,7 +35,10 @@ async def async_setup_entry(
async def _async_finish_startup(hass: HomeAssistant) -> None:
"""Run this only when HA has finished its startup."""
await coordinator.async_config_entry_first_refresh()
if config_entry.state is ConfigEntryState.LOADED:
await coordinator.async_refresh()
else:
await coordinator.async_config_entry_first_refresh()
# Don't start a speedtest during startup
async_at_started(hass, _async_finish_startup)