Skip to content

Commit

Permalink
links
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Feb 12, 2023
1 parent 273b6dd commit 6aab126
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 6 additions & 10 deletions custom_components/integration_blueprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,27 +22,24 @@
]


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],
password=entry.data[CONF_PASSWORD],
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


Expand Down
1 change: 1 addition & 0 deletions custom_components/integration_blueprint/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 6aab126

Please sign in to comment.