mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Pass in the config_entry in azure_devops coordinator init (#137722)
explicitly pass in the config_entry in azure_devops coordinator init
This commit is contained in:
parent
9a202b5e56
commit
2eb6a03640
@ -9,9 +9,7 @@ from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import CONF_PAT, CONF_PROJECT
|
||||
from .coordinator import AzureDevOpsDataUpdateCoordinator
|
||||
|
||||
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
|
||||
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -22,11 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AzureDevOpsConfigEntry)
|
||||
"""Set up Azure DevOps from a config entry."""
|
||||
|
||||
# Create the data update coordinator
|
||||
coordinator = AzureDevOpsDataUpdateCoordinator(
|
||||
hass,
|
||||
_LOGGER,
|
||||
entry=entry,
|
||||
)
|
||||
coordinator = AzureDevOpsDataUpdateCoordinator(hass, entry, _LOGGER)
|
||||
|
||||
# Store the coordinator in runtime data
|
||||
entry.runtime_data = coordinator
|
||||
|
@ -28,6 +28,8 @@ from .data import AzureDevOpsData
|
||||
BUILDS_QUERY: Final = "?queryOrder=queueTimeDescending&maxBuildsPerDefinition=1"
|
||||
IGNORED_CATEGORIES: Final[list[Category]] = [Category.COMPLETED, Category.REMOVED]
|
||||
|
||||
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
|
||||
|
||||
|
||||
def ado_exception_none_handler(func: Callable) -> Callable:
|
||||
"""Handle exceptions or None to always return a value or raise."""
|
||||
@ -50,28 +52,29 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
|
||||
"""Class to manage and fetch Azure DevOps data."""
|
||||
|
||||
client: DevOpsClient
|
||||
config_entry: AzureDevOpsConfigEntry
|
||||
organization: str
|
||||
project: Project
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: AzureDevOpsConfigEntry,
|
||||
logger: logging.Logger,
|
||||
*,
|
||||
entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Initialize global Azure DevOps data updater."""
|
||||
self.title = entry.title
|
||||
self.title = config_entry.title
|
||||
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=logger,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=300),
|
||||
)
|
||||
|
||||
self.client = DevOpsClient(session=async_get_clientsession(hass))
|
||||
self.organization = entry.data[CONF_ORG]
|
||||
self.organization = config_entry.data[CONF_ORG]
|
||||
|
||||
@ado_exception_none_handler
|
||||
async def authorize(
|
||||
|
@ -21,8 +21,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import AzureDevOpsConfigEntry
|
||||
from .coordinator import AzureDevOpsDataUpdateCoordinator
|
||||
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
|
||||
from .entity import AzureDevOpsEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user