mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 07:05:48 +01:00
Move typed ConfigEntry to coordinator module in point (#160786)
This commit is contained in:
@@ -7,7 +7,6 @@ from aiohttp import ClientError, ClientResponseError, web
|
||||
from pypoint import PointSession
|
||||
|
||||
from homeassistant.components import webhook
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_WEBHOOK_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
@@ -21,14 +20,12 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
from . import api
|
||||
from .const import CONF_WEBHOOK_URL, DOMAIN, EVENT_RECEIVED, SIGNAL_WEBHOOK
|
||||
from .coordinator import PointDataUpdateCoordinator
|
||||
from .coordinator import PointConfigEntry, PointDataUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
type PointConfigEntry = ConfigEntry[PointDataUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: PointConfigEntry) -> bool:
|
||||
"""Set up Minut Point from a config entry."""
|
||||
|
||||
@@ -16,8 +16,8 @@ from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import PointConfigEntry
|
||||
from .const import DOMAIN, SIGNAL_WEBHOOK
|
||||
from .coordinator import PointConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import PointConfigEntry
|
||||
from .const import SIGNAL_WEBHOOK
|
||||
from .coordinator import PointDataUpdateCoordinator
|
||||
from .coordinator import PointConfigEntry, PointDataUpdateCoordinator
|
||||
from .entity import MinutPointEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -3,29 +3,29 @@
|
||||
from collections.abc import Callable
|
||||
from datetime import datetime
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import Any
|
||||
|
||||
from pypoint import PointSession
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.util.dt import parse_datetime
|
||||
|
||||
from .const import DOMAIN, SCAN_INTERVAL
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import PointConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type PointConfigEntry = ConfigEntry[PointDataUpdateCoordinator]
|
||||
|
||||
|
||||
class PointDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict[str, Any]]]):
|
||||
"""Class to manage fetching Point data from the API."""
|
||||
|
||||
config_entry: "PointConfigEntry"
|
||||
config_entry: PointConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, point: PointSession, config_entry: "PointConfigEntry"
|
||||
self, hass: HomeAssistant, point: PointSession, config_entry: PointConfigEntry
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(
|
||||
|
||||
@@ -14,8 +14,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import PointConfigEntry
|
||||
from .coordinator import PointDataUpdateCoordinator
|
||||
from .coordinator import PointConfigEntry, PointDataUpdateCoordinator
|
||||
from .entity import MinutPointEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
Reference in New Issue
Block a user