Skip to content

Commit

Permalink
fix: await async_forward_entry_setup and async_forward_entry_unload t…
Browse files Browse the repository at this point in the history
…asks during setup/unload (#50)
  • Loading branch information
luuuis authored Mar 7, 2024
1 parent facaa54 commit 0a8bad0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/omie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import timedelta

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.util import utcnow

Expand All @@ -13,6 +14,8 @@

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up from a config entry."""
Expand Down Expand Up @@ -66,12 +69,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
adjustment=OMIESources(today=adjustment, tomorrow=adjustment_next, yesterday=adjustment_previous)
)

hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, "sensor"))
await hass.config_entries.async_forward_entry_setup(entry, PLATFORMS)
return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
hass.data.pop(DOMAIN)
hass.async_create_task(hass.config_entries.async_forward_entry_unload(entry, "sensor"))
return True
unload_ok = await hass.config_entries.async_forward_entry_unload(entry, PLATFORMS)
return unload_ok

0 comments on commit 0a8bad0

Please sign in to comment.