From 6aab126225ec18815e392dc14fd45e8986eb99d1 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 12 Feb 2023 09:33:59 +0000 Subject: [PATCH] links --- .github/workflows/validate.yml | 8 ++++---- .../integration_blueprint/__init__.py | 16 ++++++---------- .../integration_blueprint/coordinator.py | 1 + 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3cb545c..1bd16eb 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -12,22 +12,22 @@ on: - "main" jobs: - hassfest: + hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest name: "Hassfest Validation" runs-on: "ubuntu-latest" steps: - name: "Checkout the repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v3.3.0" - name: "Run hassfest validation" uses: "home-assistant/actions/hassfest@master" - hacs: + hacs: # https://github.com/hacs/action name: "HACS Validation" runs-on: "ubuntu-latest" steps: - name: "Checkout the repository" - uses: "actions/checkout@v3" + uses: "actions/checkout@v3.3.0" - name: "Run HACS validation" uses: "hacs/action@main" diff --git a/custom_components/integration_blueprint/__init__.py b/custom_components/integration_blueprint/__init__.py index 4dde387..3388922 100644 --- a/custom_components/integration_blueprint/__init__.py +++ b/custom_components/integration_blueprint/__init__.py @@ -9,7 +9,6 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant -from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from .api import IntegrationBlueprintApiClient @@ -23,9 +22,11 @@ ] -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: +# https://developers.home-assistant.io/docs/config_entries_index/#setting-up-an-entry +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up this integration using UI.""" - coordinator = BlueprintDataUpdateCoordinator( + hass.data.setdefault(DOMAIN, {}) + hass.data[DOMAIN][entry.entry_id] = coordinator = BlueprintDataUpdateCoordinator( hass=hass, client=IntegrationBlueprintApiClient( username=entry.data[CONF_USERNAME], @@ -33,17 +34,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: session=async_get_clientsession(hass), ), ) - + # https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities await coordinator.async_config_entry_first_refresh() - if not coordinator.last_update_success: - raise ConfigEntryNotReady - - hass.data.setdefault(DOMAIN, {}) - hass.data[DOMAIN][entry.entry_id] = coordinator await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) - entry.async_on_unload(entry.add_update_listener(async_reload_entry)) + return True diff --git a/custom_components/integration_blueprint/coordinator.py b/custom_components/integration_blueprint/coordinator.py index 973adcf..d427a1a 100644 --- a/custom_components/integration_blueprint/coordinator.py +++ b/custom_components/integration_blueprint/coordinator.py @@ -19,6 +19,7 @@ from .const import DOMAIN, LOGGER +# https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities class BlueprintDataUpdateCoordinator(DataUpdateCoordinator): """Class to manage fetching data from the API."""