mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Explicitly pass in the config_entry in slide_local coordinator (#137945)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
c17007e17b
commit
beb5c3b838
@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .coordinator import SlideCoordinator
|
from .coordinator import SlideConfigEntry, SlideCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.BUTTON, Platform.COVER, Platform.SWITCH]
|
PLATFORMS = [Platform.BUTTON, Platform.COVER, Platform.SWITCH]
|
||||||
type SlideConfigEntry = ConfigEntry[SlideCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: SlideConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: SlideConfigEntry) -> bool:
|
||||||
|
@ -15,9 +15,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import SlideConfigEntry
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import SlideCoordinator
|
from .coordinator import SlideConfigEntry, SlideCoordinator
|
||||||
from .entity import SlideEntity
|
from .entity import SlideEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
@ -20,8 +20,8 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
|
||||||
|
|
||||||
from . import SlideConfigEntry
|
|
||||||
from .const import CONF_INVERT_POSITION, DOMAIN
|
from .const import CONF_INVERT_POSITION, DOMAIN
|
||||||
|
from .coordinator import SlideConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from goslideapi.goslideapi import (
|
from goslideapi.goslideapi import (
|
||||||
AuthenticationFailed,
|
AuthenticationFailed,
|
||||||
@ -14,6 +14,7 @@ from goslideapi.goslideapi import (
|
|||||||
GoSlideLocal as SlideLocalApi,
|
GoSlideLocal as SlideLocalApi,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_VERSION,
|
CONF_API_VERSION,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
@ -31,23 +32,30 @@ from .const import DEFAULT_OFFSET, DOMAIN
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
type SlideConfigEntry = ConfigEntry[SlideCoordinator]
|
||||||
from . import SlideConfigEntry
|
|
||||||
|
|
||||||
|
|
||||||
class SlideCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class SlideCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Get and update the latest data."""
|
"""Get and update the latest data."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: SlideConfigEntry) -> None:
|
config_entry: SlideConfigEntry
|
||||||
|
|
||||||
|
def __init__(self, hass: HomeAssistant, config_entry: SlideConfigEntry) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass, _LOGGER, name="Slide", update_interval=timedelta(seconds=15)
|
hass,
|
||||||
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
|
name="Slide",
|
||||||
|
update_interval=timedelta(seconds=15),
|
||||||
)
|
)
|
||||||
self.slide = SlideLocalApi()
|
self.slide = SlideLocalApi()
|
||||||
self.api_version = entry.data[CONF_API_VERSION]
|
self.api_version = config_entry.data[CONF_API_VERSION]
|
||||||
self.mac = entry.data[CONF_MAC]
|
self.mac = config_entry.data[CONF_MAC]
|
||||||
self.host = entry.data[CONF_HOST]
|
self.host = config_entry.data[CONF_HOST]
|
||||||
self.password = entry.data[CONF_PASSWORD] if self.api_version == 1 else ""
|
self.password = (
|
||||||
|
config_entry.data[CONF_PASSWORD] if self.api_version == 1 else ""
|
||||||
|
)
|
||||||
|
|
||||||
async def _async_setup(self) -> None:
|
async def _async_setup(self) -> None:
|
||||||
"""Do initialization logic for Slide coordinator."""
|
"""Do initialization logic for Slide coordinator."""
|
||||||
|
@ -10,9 +10,8 @@ from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPENING
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import SlideConfigEntry
|
|
||||||
from .const import CONF_INVERT_POSITION, DEFAULT_OFFSET
|
from .const import CONF_INVERT_POSITION, DEFAULT_OFFSET
|
||||||
from .coordinator import SlideCoordinator
|
from .coordinator import SlideConfigEntry, SlideCoordinator
|
||||||
from .entity import SlideEntity
|
from .entity import SlideEntity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -8,7 +8,7 @@ from homeassistant.components.diagnostics import async_redact_data
|
|||||||
from homeassistant.const import CONF_PASSWORD
|
from homeassistant.const import CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import SlideConfigEntry
|
from .coordinator import SlideConfigEntry
|
||||||
|
|
||||||
TO_REDACT = [
|
TO_REDACT = [
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
|
@ -17,9 +17,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import SlideConfigEntry
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import SlideCoordinator
|
from .coordinator import SlideConfigEntry, SlideCoordinator
|
||||||
from .entity import SlideEntity
|
from .entity import SlideEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user