Explicitly pass in the config_entry in justnimbus coordinator (#138128)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 20:50:38 +01:00 committed by GitHub
parent b533cd3107
commit b9828c5edd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -13,7 +13,7 @@ from .coordinator import JustNimbusCoordinator
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up JustNimbus from a config entry."""
if "zip_code" in entry.data:
coordinator = JustNimbusCoordinator(hass=hass, entry=entry)
coordinator = JustNimbusCoordinator(hass, entry)
else:
raise ConfigEntryAuthFailed
await coordinator.async_config_entry_first_refresh()

View File

@ -20,16 +20,20 @@ _LOGGER = logging.getLogger(__name__)
class JustNimbusCoordinator(DataUpdateCoordinator[justnimbus.JustNimbusModel]):
"""Data update coordinator."""
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
config_entry: ConfigEntry
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Initialize the coordinator."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(minutes=1),
)
self._client = justnimbus.JustNimbusClient(
client_id=entry.data[CONF_CLIENT_ID], zip_code=entry.data[CONF_ZIP_CODE]
client_id=config_entry.data[CONF_CLIENT_ID],
zip_code=config_entry.data[CONF_ZIP_CODE],
)
async def _async_update_data(self) -> justnimbus.JustNimbusModel: