Upgrade aioazuredevops to 2.0.0 (#114537)
* Upgrade aioazuredevops to 2.0.0 * Refactor Azure DevOps config flow to use async_get_clientsession * Wrap conditional in parentesis
This commit is contained in:
parent
2e11a61726
commit
429b5d22cf
6 changed files with 24 additions and 11 deletions
|
@ -16,6 +16,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
|
@ -43,7 +44,8 @@ class AzureDevOpsEntityDescription(EntityDescription):
|
|||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Azure DevOps from a config entry."""
|
||||
client = DevOpsClient()
|
||||
aiohttp_session = async_get_clientsession(hass)
|
||||
client = DevOpsClient(session=aiohttp_session)
|
||||
|
||||
if entry.data.get(CONF_PAT) is not None:
|
||||
await client.authorize(entry.data[CONF_PAT], entry.data[CONF_ORG])
|
||||
|
@ -62,7 +64,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
"""Fetch data from Azure DevOps."""
|
||||
|
||||
try:
|
||||
return await client.get_builds(
|
||||
builds = await client.get_builds(
|
||||
entry.data[CONF_ORG],
|
||||
entry.data[CONF_PROJECT],
|
||||
BUILDS_QUERY,
|
||||
|
@ -70,6 +72,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
except aiohttp.ClientError as exception:
|
||||
raise UpdateFailed from exception
|
||||
|
||||
if builds is None:
|
||||
raise UpdateFailed("No builds found")
|
||||
|
||||
return builds
|
||||
|
||||
coordinator = DataUpdateCoordinator(
|
||||
hass,
|
||||
_LOGGER,
|
||||
|
|
|
@ -10,6 +10,7 @@ import aiohttp
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
|
||||
|
||||
|
@ -56,7 +57,8 @@ class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
"""Check the setup of the flow."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
client = DevOpsClient()
|
||||
aiohttp_session = async_get_clientsession(self.hass)
|
||||
client = DevOpsClient(session=aiohttp_session)
|
||||
|
||||
try:
|
||||
if self._pat is not None:
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/azure_devops",
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["aioazuredevops"],
|
||||
"requirements": ["aioazuredevops==1.4.3"]
|
||||
"requirements": ["aioazuredevops==2.0.0"]
|
||||
}
|
||||
|
|
|
@ -39,19 +39,23 @@ async def async_setup_entry(
|
|||
AzureDevOpsSensor(
|
||||
coordinator,
|
||||
AzureDevOpsSensorEntityDescription(
|
||||
key=f"{build.project.id}_{build.definition.id}_latest_build",
|
||||
key=f"{build.project.project_id}_{build.definition.build_id}_latest_build",
|
||||
translation_key="latest_build",
|
||||
translation_placeholders={"definition_name": build.definition.name},
|
||||
attrs=lambda build: {
|
||||
"definition_id": build.definition.id,
|
||||
"definition_name": build.definition.name,
|
||||
"id": build.id,
|
||||
"definition_id": (
|
||||
build.definition.build_id if build.definition else None
|
||||
),
|
||||
"definition_name": (
|
||||
build.definition.name if build.definition else None
|
||||
),
|
||||
"id": build.build_id,
|
||||
"reason": build.reason,
|
||||
"result": build.result,
|
||||
"source_branch": build.source_branch,
|
||||
"source_version": build.source_version,
|
||||
"status": build.status,
|
||||
"url": build.links.web,
|
||||
"url": build.links.web if build.links else None,
|
||||
"queue_time": build.queue_time,
|
||||
"start_time": build.start_time,
|
||||
"finish_time": build.finish_time,
|
||||
|
|
|
@ -206,7 +206,7 @@ aioasuswrt==1.4.0
|
|||
aioautomower==2024.3.4
|
||||
|
||||
# homeassistant.components.azure_devops
|
||||
aioazuredevops==1.4.3
|
||||
aioazuredevops==2.0.0
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.9.0
|
||||
|
|
|
@ -185,7 +185,7 @@ aioasuswrt==1.4.0
|
|||
aioautomower==2024.3.4
|
||||
|
||||
# homeassistant.components.azure_devops
|
||||
aioazuredevops==1.4.3
|
||||
aioazuredevops==2.0.0
|
||||
|
||||
# homeassistant.components.baf
|
||||
aiobafi6==0.9.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue