fix: Conditional imports of HA types
This prevents errors when trying to run without HA, since HA overwrites some async types in the background.
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
"""The corona_hessen component."""
|
||||
"""The covid19_augsburg component."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import re
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN
|
||||
from .crawler import CovidCrawler, IncidenceData
|
||||
@@ -18,8 +20,6 @@ __version__ = "0.1.0"
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
HYPHEN_PATTERN = re.compile(r"- (.)")
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict):
|
||||
"""Set up the Coronavirus Augsburg component."""
|
||||
@@ -60,7 +60,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||
return unload_ok
|
||||
|
||||
|
||||
async def get_coordinator(hass):
|
||||
async def get_coordinator(hass: HomeAssistant):
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
"""Get the data update coordinator."""
|
||||
if DOMAIN in hass.data:
|
||||
return hass.data[DOMAIN]
|
||||
|
||||
Reference in New Issue
Block a user