mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Explicitly pass in the config_entry in motion_blinds coordinator (#138080)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
474d8bbd65
commit
659032c4d8
@ -1,7 +1,6 @@
|
|||||||
"""The motion_blinds component."""
|
"""The motion_blinds component."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
@ -25,7 +24,6 @@ from .const import (
|
|||||||
KEY_SETUP_LOCK,
|
KEY_SETUP_LOCK,
|
||||||
KEY_UNSUB_STOP,
|
KEY_UNSUB_STOP,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
UPDATE_INTERVAL,
|
|
||||||
)
|
)
|
||||||
from .coordinator import DataUpdateCoordinatorMotionBlinds
|
from .coordinator import DataUpdateCoordinatorMotionBlinds
|
||||||
from .gateway import ConnectMotionGateway
|
from .gateway import ConnectMotionGateway
|
||||||
@ -94,13 +92,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
}
|
}
|
||||||
|
|
||||||
coordinator = DataUpdateCoordinatorMotionBlinds(
|
coordinator = DataUpdateCoordinatorMotionBlinds(
|
||||||
hass,
|
hass, entry, _LOGGER, coordinator_info
|
||||||
_LOGGER,
|
|
||||||
coordinator_info,
|
|
||||||
# Name of the data. For logging purposes.
|
|
||||||
name=entry.title,
|
|
||||||
# Polling interval. Will only be polled if there are subscribers.
|
|
||||||
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Fetch initial data so we have data when entities subscribe
|
# Fetch initial data so we have data when entities subscribe
|
||||||
|
@ -7,6 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
from motionblinds import DEVICE_TYPES_WIFI, ParseException
|
from motionblinds import DEVICE_TYPES_WIFI, ParseException
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
@ -25,21 +26,22 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator):
|
class DataUpdateCoordinatorMotionBlinds(DataUpdateCoordinator):
|
||||||
"""Class to manage fetching data from single endpoint."""
|
"""Class to manage fetching data from single endpoint."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
logger: logging.Logger,
|
logger: logging.Logger,
|
||||||
coordinator_info: dict[str, Any],
|
coordinator_info: dict[str, Any],
|
||||||
*,
|
|
||||||
name: str,
|
|
||||||
update_interval: timedelta,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize global data updater."""
|
"""Initialize global data updater."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
logger,
|
logger,
|
||||||
name=name,
|
config_entry=config_entry,
|
||||||
update_interval=update_interval,
|
name=config_entry.title,
|
||||||
|
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.api_lock = coordinator_info[KEY_API_LOCK]
|
self.api_lock = coordinator_info[KEY_API_LOCK]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user