Bump to aiohttp 3.8.0 (#58974)
This commit is contained in:
parent
23cb396aad
commit
10d6247fee
106 changed files with 221 additions and 142 deletions
67
homeassistant/async_timeout_backcompat.py
Normal file
67
homeassistant/async_timeout_backcompat.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
"""Provide backwards compat for async_timeout."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import contextlib
|
||||||
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import async_timeout
|
||||||
|
|
||||||
|
from homeassistant.helpers.frame import (
|
||||||
|
MissingIntegrationFrame,
|
||||||
|
get_integration_frame,
|
||||||
|
report_integration,
|
||||||
|
)
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def timeout(
|
||||||
|
delay: float | None, loop: asyncio.AbstractEventLoop | None = None
|
||||||
|
) -> async_timeout.Timeout:
|
||||||
|
"""Backwards compatible timeout context manager that warns with loop usage."""
|
||||||
|
if loop is None:
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
|
else:
|
||||||
|
_report(
|
||||||
|
"called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2"
|
||||||
|
)
|
||||||
|
if delay is not None:
|
||||||
|
deadline: float | None = loop.time() + delay
|
||||||
|
else:
|
||||||
|
deadline = None
|
||||||
|
return async_timeout.Timeout(deadline, loop)
|
||||||
|
|
||||||
|
|
||||||
|
def current_task(loop: asyncio.AbstractEventLoop) -> asyncio.Task[Any] | None:
|
||||||
|
"""Backwards compatible current_task."""
|
||||||
|
_report(
|
||||||
|
"called async_timeout.current_task. The current_task call is deprecated and calls will fail after Home Assistant 2022.2; use asyncio.current_task instead"
|
||||||
|
)
|
||||||
|
return asyncio.current_task()
|
||||||
|
|
||||||
|
|
||||||
|
def enable() -> None:
|
||||||
|
"""Enable backwards compat transitions."""
|
||||||
|
async_timeout.timeout = timeout
|
||||||
|
async_timeout.current_task = current_task # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
|
def _report(what: str) -> None:
|
||||||
|
"""Report incorrect usage.
|
||||||
|
|
||||||
|
Async friendly.
|
||||||
|
"""
|
||||||
|
integration_frame = None
|
||||||
|
|
||||||
|
with contextlib.suppress(MissingIntegrationFrame):
|
||||||
|
integration_frame = get_integration_frame()
|
||||||
|
|
||||||
|
if not integration_frame:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Detected code that %s; Please report this issue", what, stack_info=True
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
report_integration(what, integration_frame)
|
|
@ -307,7 +307,7 @@ class AdsEntity(Entity):
|
||||||
self._ads_hub.add_device_notification, ads_var, plctype, update
|
self._ads_hub.add_device_notification, ads_var, plctype, update
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await self._event.wait()
|
await self._event.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.debug("Variable %s: Timeout during first update", ads_var)
|
_LOGGER.debug("Variable %s: Timeout during first update", ads_var)
|
||||||
|
|
|
@ -140,7 +140,7 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
||||||
async def _async_update_data(self):
|
async def _async_update_data(self):
|
||||||
data = {}
|
data = {}
|
||||||
with async_timeout.timeout(120):
|
async with async_timeout.timeout(120):
|
||||||
weather_response = await self._get_aemet_weather()
|
weather_response = await self._get_aemet_weather()
|
||||||
data = self._convert_weather_response(weather_response)
|
data = self._convert_weather_response(weather_response)
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -167,7 +167,7 @@ class AirlyDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
measurements = self.airly.create_measurements_session_point(
|
measurements = self.airly.create_measurements_session_point(
|
||||||
self.latitude, self.longitude
|
self.latitude, self.longitude
|
||||||
)
|
)
|
||||||
with async_timeout.timeout(20):
|
async with async_timeout.timeout(20):
|
||||||
try:
|
try:
|
||||||
await measurements.update()
|
await measurements.update()
|
||||||
except (AirlyError, ClientConnectorError) as error:
|
except (AirlyError, ClientConnectorError) as error:
|
||||||
|
|
|
@ -103,7 +103,7 @@ async def test_location(
|
||||||
measurements = airly.create_measurements_session_point(
|
measurements = airly.create_measurements_session_point(
|
||||||
latitude=latitude, longitude=longitude
|
latitude=latitude, longitude=longitude
|
||||||
)
|
)
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await measurements.update()
|
await measurements.update()
|
||||||
|
|
||||||
current = measurements.current
|
current = measurements.current
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Auth:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
session = aiohttp_client.async_get_clientsession(self.hass)
|
session = aiohttp_client.async_get_clientsession(self.hass)
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await session.post(
|
response = await session.post(
|
||||||
LWA_TOKEN_URI,
|
LWA_TOKEN_URI,
|
||||||
headers=LWA_HEADERS,
|
headers=LWA_HEADERS,
|
||||||
|
|
|
@ -132,7 +132,7 @@ async def async_send_changereport_message(
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(DEFAULT_TIMEOUT):
|
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
||||||
response = await session.post(
|
response = await session.post(
|
||||||
config.endpoint,
|
config.endpoint,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
@ -263,7 +263,7 @@ async def async_send_doorbell_event_message(hass, config, alexa_entity):
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(DEFAULT_TIMEOUT):
|
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
||||||
response = await session.post(
|
response = await session.post(
|
||||||
config.endpoint,
|
config.endpoint,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
|
|
|
@ -192,7 +192,7 @@ async def _configure_almond_for_ha(
|
||||||
|
|
||||||
# Store token in Almond
|
# Store token in Almond
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
await api.async_create_device(
|
await api.async_create_device(
|
||||||
{
|
{
|
||||||
"kind": "io.home-assistant",
|
"kind": "io.home-assistant",
|
||||||
|
|
|
@ -24,7 +24,7 @@ async def async_verify_local_connection(hass: core.HomeAssistant, host: str):
|
||||||
api = WebAlmondAPI(AlmondLocalAuth(host, websession))
|
api = WebAlmondAPI(AlmondLocalAuth(host, websession))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await api.async_list_apps()
|
await api.async_list_apps()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -255,7 +255,7 @@ class Analytics:
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
response = await self.session.post(self.endpoint, json=payload)
|
response = await self.session.post(self.endpoint, json=payload)
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
|
|
|
@ -131,7 +131,7 @@ class APIEventStream(HomeAssistantView):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(STREAM_PING_INTERVAL):
|
async with async_timeout.timeout(STREAM_PING_INTERVAL):
|
||||||
payload = await to_write.get()
|
payload = await to_write.get()
|
||||||
|
|
||||||
if payload is stop_obj:
|
if payload is stop_obj:
|
||||||
|
|
|
@ -85,7 +85,7 @@ async def _run_client(hass, client, interval):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(interval):
|
async with async_timeout.timeout(interval):
|
||||||
await client.start()
|
await client.start()
|
||||||
|
|
||||||
_LOGGER.debug("Client connected %s", client.host)
|
_LOGGER.debug("Client connected %s", client.host)
|
||||||
|
|
|
@ -29,7 +29,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
async def _async_update_data():
|
async def _async_update_data():
|
||||||
"""Update data via library."""
|
"""Update data via library."""
|
||||||
with async_timeout.timeout(20):
|
async with async_timeout.timeout(20):
|
||||||
try:
|
try:
|
||||||
await atag.update()
|
await atag.update()
|
||||||
except AtagException as err:
|
except AtagException as err:
|
||||||
|
|
|
@ -58,7 +58,7 @@ class AwairDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
||||||
async def _async_update_data(self) -> Any | None:
|
async def _async_update_data(self) -> Any | None:
|
||||||
"""Update data via Awair client library."""
|
"""Update data via Awair client library."""
|
||||||
with timeout(API_TIMEOUT):
|
async with timeout(API_TIMEOUT):
|
||||||
try:
|
try:
|
||||||
LOGGER.debug("Fetching users and devices")
|
LOGGER.debug("Fetching users and devices")
|
||||||
user = await self._awair.user()
|
user = await self._awair.user()
|
||||||
|
|
|
@ -280,7 +280,7 @@ async def get_device(hass, host, port, username, password):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
await device.vapix.initialize()
|
await device.vapix.initialize()
|
||||||
|
|
||||||
return device
|
return device
|
||||||
|
|
|
@ -358,7 +358,7 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
websession = async_get_clientsession(self._hass)
|
websession = async_get_clientsession(self._hass)
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await websession.get(url)
|
response = await websession.get(url)
|
||||||
|
|
||||||
if response.status == HTTPStatus.OK:
|
if response.status == HTTPStatus.OK:
|
||||||
|
@ -400,7 +400,7 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
with async_timeout.timeout(125):
|
async with async_timeout.timeout(125):
|
||||||
response = await self._polling_session.get(
|
response = await self._polling_session.get(
|
||||||
url, headers={CONNECTION: KEEP_ALIVE}
|
url, headers={CONNECTION: KEEP_ALIVE}
|
||||||
)
|
)
|
||||||
|
|
|
@ -88,7 +88,7 @@ class BrData:
|
||||||
resp = None
|
resp = None
|
||||||
try:
|
try:
|
||||||
websession = async_get_clientsession(self.hass)
|
websession = async_get_clientsession(self.hass)
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
resp = await websession.get(url)
|
resp = await websession.get(url)
|
||||||
|
|
||||||
result[STATUS_CODE] = resp.status
|
result[STATUS_CODE] = resp.status
|
||||||
|
|
|
@ -135,7 +135,7 @@ async def async_citybikes_request(hass, uri, schema):
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
|
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
req = await session.get(DEFAULT_ENDPOINT.format(uri=uri))
|
req = await session.get(DEFAULT_ENDPOINT.format(uri=uri))
|
||||||
|
|
||||||
json_response = await req.json()
|
json_response = await req.json()
|
||||||
|
|
|
@ -313,7 +313,7 @@ class AlexaConfig(alexa_config.AbstractConfig):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED)
|
await asyncio.wait(tasks, return_when=asyncio.ALL_COMPLETED)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -204,7 +204,7 @@ class CloudLogoutView(HomeAssistantView):
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
|
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
await cloud.logout()
|
await cloud.logout()
|
||||||
|
|
||||||
return self.json_message("ok")
|
return self.json_message("ok")
|
||||||
|
@ -230,7 +230,7 @@ class CloudRegisterView(HomeAssistantView):
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
|
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
await cloud.auth.async_register(data["email"], data["password"])
|
await cloud.auth.async_register(data["email"], data["password"])
|
||||||
|
|
||||||
return self.json_message("ok")
|
return self.json_message("ok")
|
||||||
|
@ -249,7 +249,7 @@ class CloudResendConfirmView(HomeAssistantView):
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
|
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
await cloud.auth.async_resend_email_confirm(data["email"])
|
await cloud.auth.async_resend_email_confirm(data["email"])
|
||||||
|
|
||||||
return self.json_message("ok")
|
return self.json_message("ok")
|
||||||
|
@ -268,7 +268,7 @@ class CloudForgotPasswordView(HomeAssistantView):
|
||||||
hass = request.app["hass"]
|
hass = request.app["hass"]
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
|
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
await cloud.auth.async_forgot_password(data["email"])
|
await cloud.auth.async_forgot_password(data["email"])
|
||||||
|
|
||||||
return self.json_message("ok")
|
return self.json_message("ok")
|
||||||
|
@ -314,7 +314,7 @@ async def websocket_subscription(hass, connection, msg):
|
||||||
"""Handle request for account info."""
|
"""Handle request for account info."""
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
data = await cloud_api.async_subscription_info(cloud)
|
data = await cloud_api.async_subscription_info(cloud)
|
||||||
except aiohttp.ClientError:
|
except aiohttp.ClientError:
|
||||||
connection.send_error(
|
connection.send_error(
|
||||||
|
@ -353,7 +353,7 @@ async def websocket_update_prefs(hass, connection, msg):
|
||||||
if changes.get(PREF_ALEXA_REPORT_STATE):
|
if changes.get(PREF_ALEXA_REPORT_STATE):
|
||||||
alexa_config = await cloud.client.get_alexa_config()
|
alexa_config = await cloud.client.get_alexa_config()
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await alexa_config.async_get_access_token()
|
await alexa_config.async_get_access_token()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
connection.send_error(
|
connection.send_error(
|
||||||
|
@ -574,7 +574,7 @@ async def alexa_sync(hass, connection, msg):
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
alexa_config = await cloud.client.get_alexa_config()
|
alexa_config = await cloud.client.get_alexa_config()
|
||||||
|
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
try:
|
try:
|
||||||
success = await alexa_config.async_sync_entities()
|
success = await alexa_config.async_sync_entities()
|
||||||
except alexa_errors.NoTokenAvailable:
|
except alexa_errors.NoTokenAvailable:
|
||||||
|
@ -597,7 +597,7 @@ async def thingtalk_convert(hass, connection, msg):
|
||||||
"""Convert a query."""
|
"""Convert a query."""
|
||||||
cloud = hass.data[DOMAIN]
|
cloud = hass.data[DOMAIN]
|
||||||
|
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
try:
|
try:
|
||||||
connection.send_result(
|
connection.send_result(
|
||||||
msg["id"], await thingtalk.async_convert(cloud, msg["query"])
|
msg["id"], await thingtalk.async_convert(cloud, msg["query"])
|
||||||
|
|
|
@ -113,7 +113,7 @@ async def async_setup(hass, hass_config):
|
||||||
try:
|
try:
|
||||||
session = aiohttp_client.async_get_clientsession(hass)
|
session = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await session.get(url)
|
response = await session.get(url)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
|
||||||
|
|
|
@ -104,7 +104,7 @@ class ComedHourlyPricingSensor(SensorEntity):
|
||||||
else:
|
else:
|
||||||
url_string += "?type=currenthouraverage"
|
url_string += "?type=currenthouraverage"
|
||||||
|
|
||||||
with async_timeout.timeout(60):
|
async with async_timeout.timeout(60):
|
||||||
response = await self.websession.get(url_string)
|
response = await self.websession.get(url_string)
|
||||||
# The API responds with MIME type 'text/html'
|
# The API responds with MIME type 'text/html'
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
|
|
|
@ -66,7 +66,7 @@ async def get_coordinator(
|
||||||
return hass.data[DOMAIN]
|
return hass.data[DOMAIN]
|
||||||
|
|
||||||
async def async_get_cases():
|
async def async_get_cases():
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
return {
|
return {
|
||||||
case.country: case
|
case.country: case
|
||||||
for case in await coronavirus.get_cases(
|
for case in await coronavirus.get_cases(
|
||||||
|
|
|
@ -65,7 +65,7 @@ async def daikin_api_setup(hass, host, key, uuid, password):
|
||||||
|
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
try:
|
try:
|
||||||
with timeout(TIMEOUT):
|
async with timeout(TIMEOUT):
|
||||||
device = await Appliance.factory(
|
device = await Appliance.factory(
|
||||||
host, session, key=key, uuid=uuid, password=password
|
host, session, key=key, uuid=uuid, password=password
|
||||||
)
|
)
|
||||||
|
|
|
@ -70,7 +70,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
password = None
|
password = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with timeout(TIMEOUT):
|
async with timeout(TIMEOUT):
|
||||||
device = await Appliance.factory(
|
device = await Appliance.factory(
|
||||||
host,
|
host,
|
||||||
self.hass.helpers.aiohttp_client.async_get_clientsession(),
|
self.hass.helpers.aiohttp_client.async_get_clientsession(),
|
||||||
|
|
|
@ -85,7 +85,7 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
session = aiohttp_client.async_get_clientsession(self.hass)
|
session = aiohttp_client.async_get_clientsession(self.hass)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
self.bridges = await deconz_discovery(session)
|
self.bridges = await deconz_discovery(session)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, ResponseError):
|
except (asyncio.TimeoutError, ResponseError):
|
||||||
|
@ -141,7 +141,7 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
api_key = await deconz_session.get_api_key()
|
api_key = await deconz_session.get_api_key()
|
||||||
|
|
||||||
except (ResponseError, RequestError, asyncio.TimeoutError):
|
except (ResponseError, RequestError, asyncio.TimeoutError):
|
||||||
|
@ -159,7 +159,7 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
session = aiohttp_client.async_get_clientsession(self.hass)
|
session = aiohttp_client.async_get_clientsession(self.hass)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
self.bridge_id = await deconz_get_bridge_id(
|
self.bridge_id = await deconz_get_bridge_id(
|
||||||
session, **self.deconz_config
|
session, **self.deconz_config
|
||||||
)
|
)
|
||||||
|
|
|
@ -276,7 +276,7 @@ async def get_gateway(
|
||||||
connection_status=async_connection_status_callback,
|
connection_status=async_connection_status_callback,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await deconz.refresh_state()
|
await deconz.refresh_state()
|
||||||
return deconz
|
return deconz
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ class DoorBirdCamera(DoorBirdEntity, Camera):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
websession = async_get_clientsession(self.hass)
|
websession = async_get_clientsession(self.hass)
|
||||||
with async_timeout.timeout(_TIMEOUT):
|
async with async_timeout.timeout(_TIMEOUT):
|
||||||
response = await websession.get(self._url)
|
response = await websession.get(self._url)
|
||||||
|
|
||||||
self._last_image = await response.read()
|
self._last_image = await response.read()
|
||||||
|
|
|
@ -319,7 +319,7 @@ async def async_wait_for_elk_to_sync(elk, timeout, conf_host):
|
||||||
elk.add_handler("login", login_status)
|
elk.add_handler("login", login_status)
|
||||||
elk.add_handler("sync_complete", sync_complete)
|
elk.add_handler("sync_complete", sync_complete)
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
await event.wait()
|
await event.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
|
|
@ -56,7 +56,7 @@ class FAADataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
||||||
async def _async_update_data(self):
|
async def _async_update_data(self):
|
||||||
try:
|
try:
|
||||||
with timeout(10):
|
async with timeout(10):
|
||||||
await self.data.update()
|
await self.data.update()
|
||||||
except ClientConnectionError as err:
|
except ClientConnectionError as err:
|
||||||
raise UpdateFailed(err) from err
|
raise UpdateFailed(err) from err
|
||||||
|
|
|
@ -45,7 +45,7 @@ class FlickConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(60):
|
async with async_timeout.timeout(60):
|
||||||
token = await auth.async_get_access_token()
|
token = await auth.async_get_access_token()
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
raise CannotConnect() from err
|
raise CannotConnect() from err
|
||||||
|
|
|
@ -67,7 +67,7 @@ class FlickPricingSensor(SensorEntity):
|
||||||
if self._price and self._price.end_at >= utcnow():
|
if self._price and self._price.end_at >= utcnow():
|
||||||
return # Power price data is still valid
|
return # Power price data is still valid
|
||||||
|
|
||||||
with async_timeout.timeout(60):
|
async with async_timeout.timeout(60):
|
||||||
self._price = await self._api.getPricing()
|
self._price = await self._api.getPricing()
|
||||||
|
|
||||||
self._attributes[ATTR_START_AT] = self._price.start_at
|
self._attributes[ATTR_START_AT] = self._price.start_at
|
||||||
|
|
|
@ -41,7 +41,7 @@ class FlockNotificationService(BaseNotificationService):
|
||||||
_LOGGER.debug("Attempting to call Flock at %s", self._url)
|
_LOGGER.debug("Attempting to call Flock at %s", self._url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await self._session.post(self._url, json=payload)
|
response = await self._session.post(self._url, json=payload)
|
||||||
result = await response.json()
|
result = await response.json()
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ async def _update_freedns(hass, session, url, auth_token):
|
||||||
params[auth_token] = ""
|
params[auth_token] = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(TIMEOUT):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
resp = await session.get(url, params=params)
|
resp = await session.get(url, params=params)
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ async def get_coordinator(
|
||||||
return hass.data[DOMAIN]
|
return hass.data[DOMAIN]
|
||||||
|
|
||||||
async def async_get_garages():
|
async def async_get_garages():
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
return {
|
return {
|
||||||
garage.garage_name: garage
|
garage.garage_name: garage
|
||||||
for garage in await garages_amsterdam.get_garages(
|
for garage in await garages_amsterdam.get_garages(
|
||||||
|
|
|
@ -87,7 +87,7 @@ class GiosDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
async def _async_update_data(self) -> dict[str, Any]:
|
async def _async_update_data(self) -> dict[str, Any]:
|
||||||
"""Update data via library."""
|
"""Update data via library."""
|
||||||
try:
|
try:
|
||||||
with timeout(API_TIMEOUT):
|
async with timeout(API_TIMEOUT):
|
||||||
return cast(Dict[str, Any], await self.gios.async_update())
|
return cast(Dict[str, Any], await self.gios.async_update())
|
||||||
except (
|
except (
|
||||||
ApiError,
|
ApiError,
|
||||||
|
|
|
@ -37,7 +37,7 @@ class GiosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
websession = async_get_clientsession(self.hass)
|
websession = async_get_clientsession(self.hass)
|
||||||
|
|
||||||
with timeout(API_TIMEOUT):
|
async with timeout(API_TIMEOUT):
|
||||||
gios = Gios(user_input[CONF_STATION_ID], websession)
|
gios = Gios(user_input[CONF_STATION_ID], websession)
|
||||||
await gios.async_update()
|
await gios.async_update()
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ class GoogleCloudTTSProvider(Provider):
|
||||||
)
|
)
|
||||||
# pylint: enable=no-member
|
# pylint: enable=no-member
|
||||||
|
|
||||||
with async_timeout.timeout(10, loop=self.hass.loop):
|
async with async_timeout.timeout(10):
|
||||||
response = await self.hass.async_add_executor_job(
|
response = await self.hass.async_add_executor_job(
|
||||||
self._client.synthesize_speech, synthesis_input, voice, audio_config
|
self._client.synthesize_speech, synthesis_input, voice, audio_config
|
||||||
)
|
)
|
||||||
|
|
|
@ -65,7 +65,7 @@ async def _update_google_domains(hass, session, domain, user, password, timeout)
|
||||||
params = {"hostname": domain}
|
params = {"hostname": domain}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
resp = await session.get(url, params=params)
|
resp = await session.get(url, params=params)
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ class HueBridge:
|
||||||
async def authenticate_bridge(hass: core.HomeAssistant, bridge: aiohue.Bridge):
|
async def authenticate_bridge(hass: core.HomeAssistant, bridge: aiohue.Bridge):
|
||||||
"""Create a bridge object and verify authentication."""
|
"""Create a bridge object and verify authentication."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
# Create username if we don't have one
|
# Create username if we don't have one
|
||||||
if not bridge.username:
|
if not bridge.username:
|
||||||
device_name = unicode_slug.slugify(
|
device_name = unicode_slug.slugify(
|
||||||
|
|
|
@ -84,7 +84,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
# Find / discover bridges
|
# Find / discover bridges
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
bridges = await discover_nupnp(
|
bridges = await discover_nupnp(
|
||||||
websession=aiohttp_client.async_get_clientsession(self.hass)
|
websession=aiohttp_client.async_get_clientsession(self.hass)
|
||||||
)
|
)
|
||||||
|
|
|
@ -227,7 +227,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
async def async_safe_fetch(bridge, fetch_method):
|
async def async_safe_fetch(bridge, fetch_method):
|
||||||
"""Safely fetch data."""
|
"""Safely fetch data."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(4):
|
async with async_timeout.timeout(4):
|
||||||
return await bridge.async_request_call(fetch_method)
|
return await bridge.async_request_call(fetch_method)
|
||||||
except aiohue.Unauthorized as err:
|
except aiohue.Unauthorized as err:
|
||||||
await bridge.handle_unauthorized_error()
|
await bridge.handle_unauthorized_error()
|
||||||
|
|
|
@ -61,7 +61,7 @@ class SensorManager:
|
||||||
async def async_update_data(self):
|
async def async_update_data(self):
|
||||||
"""Update sensor data."""
|
"""Update sensor data."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(4):
|
async with async_timeout.timeout(4):
|
||||||
return await self.bridge.async_request_call(
|
return await self.bridge.async_request_call(
|
||||||
self.bridge.api.sensors.update
|
self.bridge.api.sensors.update
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,7 +42,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
config_port = config[CONF_PORT]
|
config_port = config[CONF_PORT]
|
||||||
config_name = config[CONF_NAME]
|
config_name = config[CONF_NAME]
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(PLATFORM_TIMEOUT):
|
async with async_timeout.timeout(PLATFORM_TIMEOUT):
|
||||||
api = await real_time_api(config_host, config_port)
|
api = await real_time_api(config_host, config_port)
|
||||||
except (IamMeterError, asyncio.TimeoutError) as err:
|
except (IamMeterError, asyncio.TimeoutError) as err:
|
||||||
_LOGGER.error("Device is not ready")
|
_LOGGER.error("Device is not ready")
|
||||||
|
@ -50,7 +50,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
async def async_update_data():
|
async def async_update_data():
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(PLATFORM_TIMEOUT):
|
async with async_timeout.timeout(PLATFORM_TIMEOUT):
|
||||||
return await api.get_data()
|
return await api.get_data()
|
||||||
except (IamMeterError, asyncio.TimeoutError) as err:
|
except (IamMeterError, asyncio.TimeoutError) as err:
|
||||||
raise UpdateFailed from err
|
raise UpdateFailed from err
|
||||||
|
|
|
@ -134,7 +134,7 @@ class ImapSensor(SensorEntity):
|
||||||
idle = await self._connection.idle_start()
|
idle = await self._connection.idle_start()
|
||||||
await self._connection.wait_server_push()
|
await self._connection.wait_server_push()
|
||||||
self._connection.idle_done()
|
self._connection.idle_done()
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await idle
|
await idle
|
||||||
else:
|
else:
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
|
@ -142,7 +142,7 @@ async def async_get_api(hass):
|
||||||
|
|
||||||
async def async_get_location(hass, api, latitude, longitude):
|
async def async_get_location(hass, api, latitude, longitude):
|
||||||
"""Retrieve pyipma location, location name to be used as the entity name."""
|
"""Retrieve pyipma location, location name to be used as the entity name."""
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
location = await Location.get(api, float(latitude), float(longitude))
|
location = await Location.get(api, float(latitude), float(longitude))
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
|
@ -172,7 +172,7 @@ class IPMAWeather(WeatherEntity):
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Update Condition and Forecast."""
|
"""Update Condition and Forecast."""
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
new_observation = await self._location.observation(self._api)
|
new_observation = await self._location.observation(self._api)
|
||||||
new_forecast = await self._location.forecast(self._api)
|
new_forecast = await self._location.forecast(self._api)
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
isy_conf_xml = await isy_conn.test_connection()
|
isy_conf_xml = await isy_conn.test_connection()
|
||||||
except ISYInvalidAuthError as error:
|
except ISYInvalidAuthError as error:
|
||||||
raise InvalidAuth from error
|
raise InvalidAuth from error
|
||||||
|
|
|
@ -53,7 +53,7 @@ class KaiterraApiData:
|
||||||
"""Get the data from Kaiterra API."""
|
"""Get the data from Kaiterra API."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
data = await self._api.get_latest_sensor_readings(self._devices)
|
data = await self._api.get_latest_sensor_readings(self._devices)
|
||||||
except (ClientResponseError, asyncio.TimeoutError):
|
except (ClientResponseError, asyncio.TimeoutError):
|
||||||
_LOGGER.debug("Couldn't fetch data from Kaiterra API")
|
_LOGGER.debug("Couldn't fetch data from Kaiterra API")
|
||||||
|
|
|
@ -38,7 +38,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
try:
|
try:
|
||||||
httpsession = async_get_clientsession(hass)
|
httpsession = async_get_clientsession(hass)
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
scenes_resp = await httpsession.get(url, headers=headers)
|
scenes_resp = await httpsession.get(url, headers=headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
@ -81,7 +81,7 @@ class LifxCloudScene(Scene):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
httpsession = async_get_clientsession(self.hass)
|
httpsession = async_get_clientsession(self.hass)
|
||||||
with async_timeout.timeout(self._timeout):
|
async with async_timeout.timeout(self._timeout):
|
||||||
await httpsession.put(url, headers=self._headers)
|
await httpsession.put(url, headers=self._headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
|
|
@ -147,7 +147,7 @@ async def async_setup_entry(hass, entry):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(_TIMEOUT):
|
async with async_timeout.timeout(_TIMEOUT):
|
||||||
# Ensure the cameras property returns the same Camera objects for
|
# Ensure the cameras property returns the same Camera objects for
|
||||||
# all devices. Performs implicit login and session validation.
|
# all devices. Performs implicit login and session validation.
|
||||||
await logi_circle.synchronize_cameras()
|
await logi_circle.synchronize_cameras()
|
||||||
|
|
|
@ -158,7 +158,7 @@ class LogiCircleFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(_TIMEOUT):
|
async with async_timeout.timeout(_TIMEOUT):
|
||||||
await logi_session.authorize(code)
|
await logi_session.authorize(code)
|
||||||
except AuthorizationFailed:
|
except AuthorizationFailed:
|
||||||
(self.hass.data[DATA_FLOW_IMPL][DOMAIN][EXTERNAL_ERRORS]) = "invalid_auth"
|
(self.hass.data[DATA_FLOW_IMPL][DOMAIN][EXTERNAL_ERRORS]) = "invalid_auth"
|
||||||
|
|
|
@ -250,7 +250,7 @@ class MailboxMediaView(MailboxView):
|
||||||
mailbox = self.get_mailbox(platform)
|
mailbox = self.get_mailbox(platform)
|
||||||
|
|
||||||
with suppress(asyncio.CancelledError, asyncio.TimeoutError):
|
with suppress(asyncio.CancelledError, asyncio.TimeoutError):
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
try:
|
try:
|
||||||
stream = await mailbox.async_get_media(msgid)
|
stream = await mailbox.async_get_media(msgid)
|
||||||
except StreamError as err:
|
except StreamError as err:
|
||||||
|
|
|
@ -145,7 +145,7 @@ async def mel_devices_setup(hass, token) -> list[MelCloudDevice]:
|
||||||
"""Query connected devices from MELCloud."""
|
"""Query connected devices from MELCloud."""
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
session = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
try:
|
try:
|
||||||
with timeout(10):
|
async with timeout(10):
|
||||||
all_devices = await get_devices(
|
all_devices = await get_devices(
|
||||||
token,
|
token,
|
||||||
session,
|
session,
|
||||||
|
|
|
@ -42,7 +42,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with timeout(10):
|
async with timeout(10):
|
||||||
if (acquired_token := token) is None:
|
if (acquired_token := token) is None:
|
||||||
acquired_token = await pymelcloud.login(
|
acquired_token = await pymelcloud.login(
|
||||||
username,
|
username,
|
||||||
|
|
|
@ -299,7 +299,7 @@ class MicrosoftFace:
|
||||||
payload = None
|
payload = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(self.timeout):
|
async with async_timeout.timeout(self.timeout):
|
||||||
response = await getattr(self.websession, method)(
|
response = await getattr(self.websession, method)(
|
||||||
url, data=payload, headers=headers, params=params
|
url, data=payload, headers=headers, params=params
|
||||||
)
|
)
|
||||||
|
|
|
@ -122,7 +122,7 @@ class MjpegCamera(Camera):
|
||||||
|
|
||||||
websession = async_get_clientsession(self.hass, verify_ssl=self._verify_ssl)
|
websession = async_get_clientsession(self.hass, verify_ssl=self._verify_ssl)
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await websession.get(self._still_image_url, auth=self._auth)
|
response = await websession.get(self._still_image_url, auth=self._auth)
|
||||||
|
|
||||||
image = await response.read()
|
image = await response.read()
|
||||||
|
|
|
@ -149,7 +149,7 @@ class MobileAppNotificationService(BaseNotificationService):
|
||||||
target_data["registration_info"] = reg_info
|
target_data["registration_info"] = reg_info
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await async_get_clientsession(self._hass).post(
|
response = await async_get_clientsession(self._hass).post(
|
||||||
push_url, json=target_data
|
push_url, json=target_data
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: dict) -> bool:
|
||||||
"""Set up Mullvad VPN integration."""
|
"""Set up Mullvad VPN integration."""
|
||||||
|
|
||||||
async def async_get_mullvad_api_data():
|
async def async_get_mullvad_api_data():
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
api = await hass.async_add_executor_job(MullvadAPI)
|
api = await hass.async_add_executor_job(MullvadAPI)
|
||||||
return api.data
|
return api.data
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ async def try_connect(
|
||||||
connect_task = None
|
connect_task = None
|
||||||
try:
|
try:
|
||||||
connect_task = asyncio.create_task(gateway.start())
|
connect_task = asyncio.create_task(gateway.start())
|
||||||
with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
async with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
||||||
await gateway_ready.wait()
|
await gateway_ready.wait()
|
||||||
return True
|
return True
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
@ -319,7 +319,7 @@ async def _gw_start(
|
||||||
# Gatways connected via mqtt doesn't send gateway ready message.
|
# Gatways connected via mqtt doesn't send gateway ready message.
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
async with async_timeout.timeout(GATEWAY_READY_TIMEOUT):
|
||||||
await gateway_ready.wait()
|
await gateway_ready.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
|
|
|
@ -100,7 +100,7 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
# Device firmware uses synchronous code and doesn't respond to http queries
|
# Device firmware uses synchronous code and doesn't respond to http queries
|
||||||
# when reading data from sensors. The nettigo-air-quality library tries to
|
# when reading data from sensors. The nettigo-air-quality library tries to
|
||||||
# get the data 4 times, so we use a longer than usual timeout here.
|
# get the data 4 times, so we use a longer than usual timeout here.
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
data = await self.nam.async_update()
|
data = await self.nam.async_update()
|
||||||
except (ApiError, ClientConnectorError, InvalidSensorData) as error:
|
except (ApiError, ClientConnectorError, InvalidSensorData) as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(error) from error
|
||||||
|
|
|
@ -120,5 +120,5 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
# Device firmware uses synchronous code and doesn't respond to http queries
|
# Device firmware uses synchronous code and doesn't respond to http queries
|
||||||
# when reading data from sensors. The nettigo-air-monitor library tries to get
|
# when reading data from sensors. The nettigo-air-monitor library tries to get
|
||||||
# the data 4 times, so we use a longer than usual timeout here.
|
# the data 4 times, so we use a longer than usual timeout here.
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
return await nam.async_get_mac_address()
|
return await nam.async_get_mac_address()
|
||||||
|
|
|
@ -211,7 +211,7 @@ class NestFlowHandler(
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
tokens = await flow["convert_code"](user_input["code"])
|
tokens = await flow["convert_code"](user_input["code"])
|
||||||
return self._entry_from_tokens(
|
return self._entry_from_tokens(
|
||||||
f"Nest (via {flow['name']})", flow, tokens
|
f"Nest (via {flow['name']})", flow, tokens
|
||||||
|
@ -228,7 +228,7 @@ class NestFlowHandler(
|
||||||
_LOGGER.exception("Unexpected error resolving code")
|
_LOGGER.exception("Unexpected error resolving code")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
url = await flow["gen_authorize_url"](self.flow_id)
|
url = await flow["gen_authorize_url"](self.flow_id)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return self.async_abort(reason="authorize_url_timeout")
|
return self.async_abort(reason="authorize_url_timeout")
|
||||||
|
|
|
@ -96,7 +96,7 @@ async def _update_no_ip(
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
resp = await session.get(url, params=params, headers=headers)
|
resp = await session.get(url, params=params, headers=headers)
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class OpenAlprCloudEntity(ImageProcessingAlprEntity):
|
||||||
body = {"image_bytes": str(b64encode(image), "utf-8")}
|
body = {"image_bytes": str(b64encode(image), "utf-8")}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(self.timeout):
|
async with async_timeout.timeout(self.timeout):
|
||||||
request = await websession.post(
|
request = await websession.post(
|
||||||
OPENALPR_API_URL, params=params, data=body
|
OPENALPR_API_URL, params=params, data=body
|
||||||
)
|
)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
|
||||||
|
|
||||||
async def _async_update_data(self):
|
async def _async_update_data(self):
|
||||||
data = {}
|
data = {}
|
||||||
with async_timeout.timeout(20):
|
async with async_timeout.timeout(20):
|
||||||
try:
|
try:
|
||||||
weather_response = await self._get_owm_weather()
|
weather_response = await self._get_owm_weather()
|
||||||
data = self._convert_weather_response(weather_response)
|
data = self._convert_weather_response(weather_response)
|
||||||
|
|
|
@ -93,7 +93,7 @@ class PointFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "follow_link"
|
errors["base"] = "follow_link"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
url = await self._get_authorization_url()
|
url = await self._get_authorization_url()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return self.async_abort(reason="authorize_url_timeout")
|
return self.async_abort(reason="authorize_url_timeout")
|
||||||
|
|
|
@ -90,7 +90,7 @@ class PoolSenseDataUpdateCoordinator(DataUpdateCoordinator):
|
||||||
async def _async_update_data(self):
|
async def _async_update_data(self):
|
||||||
"""Update data via library."""
|
"""Update data via library."""
|
||||||
data = {}
|
data = {}
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
try:
|
try:
|
||||||
data = await self.poolsense.get_poolsense_data()
|
data = await self.poolsense.get_poolsense_data()
|
||||||
except (PoolSenseError) as error:
|
except (PoolSenseError) as error:
|
||||||
|
|
|
@ -56,7 +56,7 @@ class ProwlNotificationService(BaseNotificationService):
|
||||||
session = async_get_clientsession(self._hass)
|
session = async_get_clientsession(self._hass)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
response = await session.post(url, data=payload)
|
response = await session.post(url, data=payload)
|
||||||
result = await response.text()
|
result = await response.text()
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
async def handle_webhook(hass, webhook_id, request):
|
async def handle_webhook(hass, webhook_id, request):
|
||||||
"""Handle incoming webhook POST with image files."""
|
"""Handle incoming webhook POST with image files."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
data = dict(await request.post())
|
data = dict(await request.post())
|
||||||
except (asyncio.TimeoutError, aiohttp.web.HTTPException) as error:
|
except (asyncio.TimeoutError, aiohttp.web.HTTPException) as error:
|
||||||
_LOGGER.error("Could not get information from POST <%s>", error)
|
_LOGGER.error("Could not get information from POST <%s>", error)
|
||||||
|
|
|
@ -50,7 +50,7 @@ async def async_get_type(hass, cloud_id, install_code, host):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
meters = await hub.get_device_list()
|
meters = await hub.get_device_list()
|
||||||
except aioeagle.BadAuth as err:
|
except aioeagle.BadAuth as err:
|
||||||
raise InvalidAuth from err
|
raise InvalidAuth from err
|
||||||
|
|
|
@ -210,7 +210,7 @@ class RestSwitch(SwitchEntity):
|
||||||
rendered_headers = render_templates(self._headers)
|
rendered_headers = render_templates(self._headers)
|
||||||
rendered_params = render_templates(self._params)
|
rendered_params = render_templates(self._params)
|
||||||
|
|
||||||
with async_timeout.timeout(self._timeout):
|
async with async_timeout.timeout(self._timeout):
|
||||||
req = await getattr(websession, self._method)(
|
req = await getattr(websession, self._method)(
|
||||||
self._resource,
|
self._resource,
|
||||||
auth=self._auth,
|
auth=self._auth,
|
||||||
|
@ -236,7 +236,7 @@ class RestSwitch(SwitchEntity):
|
||||||
rendered_headers = render_templates(self._headers)
|
rendered_headers = render_templates(self._headers)
|
||||||
rendered_params = render_templates(self._params)
|
rendered_params = render_templates(self._params)
|
||||||
|
|
||||||
with async_timeout.timeout(self._timeout):
|
async with async_timeout.timeout(self._timeout):
|
||||||
req = await websession.get(
|
req = await websession.get(
|
||||||
self._state_resource,
|
self._state_resource,
|
||||||
auth=self._auth,
|
auth=self._auth,
|
||||||
|
|
|
@ -270,7 +270,7 @@ async def async_setup(hass, config):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(CONNECTION_TIMEOUT):
|
async with async_timeout.timeout(CONNECTION_TIMEOUT):
|
||||||
transport, protocol = await connection
|
transport, protocol = await connection
|
||||||
|
|
||||||
except (
|
except (
|
||||||
|
|
|
@ -80,7 +80,7 @@ async def async_connect_or_timeout(hass, roomba):
|
||||||
"""Connect to vacuum."""
|
"""Connect to vacuum."""
|
||||||
try:
|
try:
|
||||||
name = None
|
name = None
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
_LOGGER.debug("Initialize connection to vacuum")
|
_LOGGER.debug("Initialize connection to vacuum")
|
||||||
await hass.async_add_executor_job(roomba.connect)
|
await hass.async_add_executor_job(roomba.connect)
|
||||||
while not roomba.roomba_connected or name is None:
|
while not roomba.roomba_connected or name is None:
|
||||||
|
@ -104,7 +104,7 @@ async def async_connect_or_timeout(hass, roomba):
|
||||||
async def async_disconnect_or_timeout(hass, roomba):
|
async def async_disconnect_or_timeout(hass, roomba):
|
||||||
"""Disconnect to vacuum."""
|
"""Disconnect to vacuum."""
|
||||||
_LOGGER.debug("Disconnect vacuum")
|
_LOGGER.debug("Disconnect vacuum")
|
||||||
with async_timeout.timeout(3):
|
async with async_timeout.timeout(3):
|
||||||
await hass.async_add_executor_job(roomba.disconnect)
|
await hass.async_add_executor_job(roomba.disconnect)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
)
|
)
|
||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(TIMEOUT):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
for dev in await client.async_get_devices(_INITIAL_FETCH_FIELDS):
|
for dev in await client.async_get_devices(_INITIAL_FETCH_FIELDS):
|
||||||
if config[CONF_ID] == ALL or dev["id"] in config[CONF_ID]:
|
if config[CONF_ID] == ALL or dev["id"] in config[CONF_ID]:
|
||||||
devices.append(
|
devices.append(
|
||||||
|
@ -363,7 +363,7 @@ class SensiboClimate(ClimateEntity):
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(TIMEOUT):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
data = await self._client.async_get_device(self._id, _FETCH_FIELDS)
|
data = await self._client.async_get_device(self._id, _FETCH_FIELDS)
|
||||||
except (
|
except (
|
||||||
aiohttp.client_exceptions.ClientError,
|
aiohttp.client_exceptions.ClientError,
|
||||||
|
@ -389,7 +389,7 @@ class SensiboClimate(ClimateEntity):
|
||||||
async def _async_set_ac_state_property(self, name, value, assumed_state=False):
|
async def _async_set_ac_state_property(self, name, value, assumed_state=False):
|
||||||
"""Set AC state."""
|
"""Set AC state."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(TIMEOUT):
|
async with async_timeout.timeout(TIMEOUT):
|
||||||
await self._client.async_set_ac_state_property(
|
await self._client.async_set_ac_state_property(
|
||||||
self._id, name, value, self._ac_states, assumed_state
|
self._id, name, value, self._ac_states, assumed_state
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CannotConnect(exceptions.HomeAssistantError):
|
||||||
async def async_connect_or_timeout(ayla_api: AylaApi) -> bool:
|
async def async_connect_or_timeout(ayla_api: AylaApi) -> bool:
|
||||||
"""Connect to vacuum."""
|
"""Connect to vacuum."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(API_TIMEOUT):
|
async with async_timeout.timeout(API_TIMEOUT):
|
||||||
_LOGGER.debug("Initialize connection to Ayla networks API")
|
_LOGGER.debug("Initialize connection to Ayla networks API")
|
||||||
await ayla_api.async_sign_in()
|
await ayla_api.async_sign_in()
|
||||||
except SharkIqAuthError:
|
except SharkIqAuthError:
|
||||||
|
@ -71,7 +71,8 @@ async def async_setup_entry(hass, config_entry):
|
||||||
async def async_disconnect_or_timeout(coordinator: SharkIqUpdateCoordinator):
|
async def async_disconnect_or_timeout(coordinator: SharkIqUpdateCoordinator):
|
||||||
"""Disconnect to vacuum."""
|
"""Disconnect to vacuum."""
|
||||||
_LOGGER.debug("Disconnecting from Ayla Api")
|
_LOGGER.debug("Disconnecting from Ayla Api")
|
||||||
with async_timeout.timeout(5), suppress(
|
async with async_timeout.timeout(5):
|
||||||
|
with suppress(
|
||||||
SharkIqAuthError, SharkIqAuthExpiringError, SharkIqNotAuthedError
|
SharkIqAuthError, SharkIqAuthExpiringError, SharkIqNotAuthedError
|
||||||
):
|
):
|
||||||
await coordinator.ayla_api.async_sign_out()
|
await coordinator.ayla_api.async_sign_out()
|
||||||
|
|
|
@ -27,7 +27,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
_LOGGER.debug("Initialize connection to Ayla networks API")
|
_LOGGER.debug("Initialize connection to Ayla networks API")
|
||||||
await ayla_api.async_sign_in()
|
await ayla_api.async_sign_in()
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as errors:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as errors:
|
||||||
|
|
|
@ -54,7 +54,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator):
|
||||||
"""Asynchronously update the data for a single vacuum."""
|
"""Asynchronously update the data for a single vacuum."""
|
||||||
dsn = sharkiq.serial_number
|
dsn = sharkiq.serial_number
|
||||||
_LOGGER.debug("Updating sharkiq data for device DSN %s", dsn)
|
_LOGGER.debug("Updating sharkiq data for device DSN %s", dsn)
|
||||||
with timeout(API_TIMEOUT):
|
async with timeout(API_TIMEOUT):
|
||||||
await sharkiq.async_update()
|
await sharkiq.async_update()
|
||||||
|
|
||||||
async def _async_update_data(self) -> bool:
|
async def _async_update_data(self) -> bool:
|
||||||
|
|
|
@ -125,7 +125,7 @@ class SmhiWeather(WeatherEntity):
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Refresh the forecast data from SMHI weather API."""
|
"""Refresh the forecast data from SMHI weather API."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
self._forecasts = await self.get_weather_forecast()
|
self._forecasts = await self.get_weather_forecast()
|
||||||
self._fail_count = 0
|
self._fail_count = 0
|
||||||
|
|
||||||
|
|
|
@ -972,7 +972,7 @@ class SonosSpeaker:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
while not _test_groups(groups):
|
while not _test_groups(groups):
|
||||||
await hass.data[DATA_SONOS].topology_condition.wait()
|
await hass.data[DATA_SONOS].topology_condition.wait()
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
|
|
@ -44,7 +44,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
# Fetch srp_energy data
|
# Fetch srp_energy data
|
||||||
start_date = datetime.now() + timedelta(days=-1)
|
start_date = datetime.now() + timedelta(days=-1)
|
||||||
end_date = datetime.now()
|
end_date = datetime.now()
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
hourly_usage = await hass.async_add_executor_job(
|
hourly_usage = await hass.async_add_executor_job(
|
||||||
api.usage,
|
api.usage,
|
||||||
start_date,
|
start_date,
|
||||||
|
|
|
@ -193,7 +193,7 @@ class StartcaData:
|
||||||
"""Get the Start.ca bandwidth data from the web service."""
|
"""Get the Start.ca bandwidth data from the web service."""
|
||||||
_LOGGER.debug("Updating Start.ca usage data")
|
_LOGGER.debug("Updating Start.ca usage data")
|
||||||
url = f"https://www.start.ca/support/usage/api?key={self.api_key}"
|
url = f"https://www.start.ca/support/usage/api?key={self.api_key}"
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
req = await self.websession.get(url)
|
req = await self.websession.get(url)
|
||||||
if req.status != HTTPStatus.OK:
|
if req.status != HTTPStatus.OK:
|
||||||
_LOGGER.error("Request failed with status: %u", req.status)
|
_LOGGER.error("Request failed with status: %u", req.status)
|
||||||
|
|
|
@ -64,7 +64,7 @@ async def get_integration_info(
|
||||||
):
|
):
|
||||||
"""Get integration system health."""
|
"""Get integration system health."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(INFO_CALLBACK_TIMEOUT):
|
async with async_timeout.timeout(INFO_CALLBACK_TIMEOUT):
|
||||||
data = await registration.info_callback(hass)
|
data = await registration.info_callback(hass)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
data = {"error": {"type": "failed", "error": "timeout"}}
|
data = {"error": {"type": "failed", "error": "timeout"}}
|
||||||
|
|
|
@ -106,7 +106,7 @@ class TadoDeviceScanner(DeviceScanner):
|
||||||
last_results = []
|
last_results = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
# Format the URL here, so we can log the template URL if
|
# Format the URL here, so we can log the template URL if
|
||||||
# anything goes wrong without exposing username and password.
|
# anything goes wrong without exposing username and password.
|
||||||
url = self.tadoapiurl.format(
|
url = self.tadoapiurl.format(
|
||||||
|
|
|
@ -92,7 +92,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
auth_url = await self.hass.async_add_executor_job(self._get_auth_url)
|
auth_url = await self.hass.async_add_executor_job(self._get_auth_url)
|
||||||
if not auth_url:
|
if not auth_url:
|
||||||
return self.async_abort(reason="unknown_authorize_url_generation")
|
return self.async_abort(reason="unknown_authorize_url_generation")
|
||||||
|
|
|
@ -124,7 +124,7 @@ class TtnDataStorage:
|
||||||
"""Get the current state from The Things Network Data Storage."""
|
"""Get the current state from The Things Network Data Storage."""
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(self._hass)
|
session = async_get_clientsession(self._hass)
|
||||||
with async_timeout.timeout(DEFAULT_TIMEOUT):
|
async with async_timeout.timeout(DEFAULT_TIMEOUT):
|
||||||
response = await session.get(self._url, headers=self._headers)
|
response = await session.get(self._url, headers=self._headers)
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
|
|
@ -174,7 +174,7 @@ async def authenticate(
|
||||||
api_factory = await APIFactory.init(host, psk_id=identity)
|
api_factory = await APIFactory.init(host, psk_id=identity)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
key = await api_factory.generate_psk(security_code)
|
key = await api_factory.generate_psk(security_code)
|
||||||
except RequestError as err:
|
except RequestError as err:
|
||||||
raise AuthError("invalid_security_code") from err
|
raise AuthError("invalid_security_code") from err
|
||||||
|
|
|
@ -419,7 +419,7 @@ class UniFiController:
|
||||||
async def async_reconnect(self) -> None:
|
async def async_reconnect(self) -> None:
|
||||||
"""Try to reconnect UniFi session."""
|
"""Try to reconnect UniFi session."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(5):
|
async with async_timeout.timeout(5):
|
||||||
await self.api.login()
|
await self.api.login()
|
||||||
self.api.start_websocket()
|
self.api.start_websocket()
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ async def get_controller(
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
await controller.check_unifi_os()
|
await controller.check_unifi_os()
|
||||||
await controller.login()
|
await controller.login()
|
||||||
return controller
|
return controller
|
||||||
|
|
|
@ -125,7 +125,7 @@ async def get_newest_version(hass):
|
||||||
"""Get the newest Home Assistant version."""
|
"""Get the newest Home Assistant version."""
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
|
|
||||||
with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
req = await session.get(UPDATER_URL)
|
req = await session.get(UPDATER_URL)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -70,7 +70,7 @@ async def async_http_request(hass, uri):
|
||||||
"""Perform actual request."""
|
"""Perform actual request."""
|
||||||
try:
|
try:
|
||||||
session = hass.helpers.aiohttp_client.async_get_clientsession(hass)
|
session = hass.helpers.aiohttp_client.async_get_clientsession(hass)
|
||||||
with async_timeout.timeout(REQUEST_TIMEOUT):
|
async with async_timeout.timeout(REQUEST_TIMEOUT):
|
||||||
req = await session.get(uri)
|
req = await session.get(uri)
|
||||||
if req.status != HTTPStatus.OK:
|
if req.status != HTTPStatus.OK:
|
||||||
return {"error": req.status}
|
return {"error": req.status}
|
||||||
|
|
|
@ -196,7 +196,7 @@ class VoiceRSSProvider(Provider):
|
||||||
form_data["hl"] = language
|
form_data["hl"] = language
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
request = await websession.post(VOICERSS_API_URL, data=form_data)
|
request = await websession.post(VOICERSS_API_URL, data=form_data)
|
||||||
|
|
||||||
if request.status != HTTPStatus.OK:
|
if request.status != HTTPStatus.OK:
|
||||||
|
|
|
@ -176,7 +176,7 @@ class WebSocketHandler:
|
||||||
|
|
||||||
# Auth Phase
|
# Auth Phase
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
msg = await wsock.receive()
|
msg = await wsock.receive()
|
||||||
except asyncio.TimeoutError as err:
|
except asyncio.TimeoutError as err:
|
||||||
disconnect_warn = "Did not receive auth message within 10 seconds"
|
disconnect_warn = "Did not receive auth message within 10 seconds"
|
||||||
|
|
|
@ -85,7 +85,7 @@ class WorxLandroidSensor(SensorEntity):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
session = async_get_clientsession(self.hass)
|
session = async_get_clientsession(self.hass)
|
||||||
with async_timeout.timeout(self.timeout):
|
async with async_timeout.timeout(self.timeout):
|
||||||
auth = aiohttp.helpers.BasicAuth("admin", self.pin)
|
auth = aiohttp.helpers.BasicAuth("admin", self.pin)
|
||||||
mower_response = await session.get(self.url, auth=auth)
|
mower_response = await session.get(self.url, auth=auth)
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
|
|
|
@ -121,7 +121,7 @@ class YandexSpeechKitProvider(Provider):
|
||||||
options = options or {}
|
options = options or {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
url_param = {
|
url_param = {
|
||||||
"text": message,
|
"text": message,
|
||||||
"lang": actual_language,
|
"lang": actual_language,
|
||||||
|
|
|
@ -25,7 +25,7 @@ import attr
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
import yarl
|
import yarl
|
||||||
|
|
||||||
from homeassistant import block_async_io, loader, util
|
from homeassistant import async_timeout_backcompat, block_async_io, loader, util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DOMAIN,
|
ATTR_DOMAIN,
|
||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
|
@ -82,7 +82,7 @@ STAGE_1_SHUTDOWN_TIMEOUT = 100
|
||||||
STAGE_2_SHUTDOWN_TIMEOUT = 60
|
STAGE_2_SHUTDOWN_TIMEOUT = 60
|
||||||
STAGE_3_SHUTDOWN_TIMEOUT = 30
|
STAGE_3_SHUTDOWN_TIMEOUT = 30
|
||||||
|
|
||||||
|
async_timeout_backcompat.enable()
|
||||||
block_async_io.enable()
|
block_async_io.enable()
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
|
@ -123,7 +123,7 @@ async def async_aiohttp_proxy_web(
|
||||||
) -> web.StreamResponse | None:
|
) -> web.StreamResponse | None:
|
||||||
"""Stream websession request to aiohttp web response."""
|
"""Stream websession request to aiohttp web response."""
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
req = await web_coro
|
req = await web_coro
|
||||||
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
@ -164,7 +164,7 @@ async def async_aiohttp_proxy_stream(
|
||||||
# Suppressing something went wrong fetching data, closed connection
|
# Suppressing something went wrong fetching data, closed connection
|
||||||
with suppress(asyncio.TimeoutError, aiohttp.ClientError):
|
with suppress(asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
while hass.is_running:
|
while hass.is_running:
|
||||||
with async_timeout.timeout(timeout):
|
async with async_timeout.timeout(timeout):
|
||||||
data = await stream.read(buffer_size)
|
data = await stream.read(buffer_size)
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
|
|
|
@ -270,7 +270,7 @@ class AbstractOAuth2FlowHandler(config_entries.ConfigFlow, metaclass=ABCMeta):
|
||||||
return self.async_external_step_done(next_step_id="creation")
|
return self.async_external_step_done(next_step_id="creation")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with async_timeout.timeout(10):
|
async with async_timeout.timeout(10):
|
||||||
url = await self.flow_impl.async_generate_authorize_url(self.flow_id)
|
url = await self.flow_impl.async_generate_authorize_url(self.flow_id)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return self.async_abort(reason="authorize_url_timeout")
|
return self.async_abort(reason="authorize_url_timeout")
|
||||||
|
|
|
@ -476,7 +476,10 @@ class _ScriptRun:
|
||||||
def async_script_wait(entity_id, from_s, to_s):
|
def async_script_wait(entity_id, from_s, to_s):
|
||||||
"""Handle script after template condition is true."""
|
"""Handle script after template condition is true."""
|
||||||
wait_var = self._variables["wait"]
|
wait_var = self._variables["wait"]
|
||||||
wait_var["remaining"] = to_context.remaining if to_context else timeout
|
if to_context and to_context.deadline:
|
||||||
|
wait_var["remaining"] = to_context.deadline - self._hass.loop.time()
|
||||||
|
else:
|
||||||
|
wait_var["remaining"] = timeout
|
||||||
wait_var["completed"] = True
|
wait_var["completed"] = True
|
||||||
done.set()
|
done.set()
|
||||||
|
|
||||||
|
@ -777,7 +780,10 @@ class _ScriptRun:
|
||||||
|
|
||||||
async def async_done(variables, context=None):
|
async def async_done(variables, context=None):
|
||||||
wait_var = self._variables["wait"]
|
wait_var = self._variables["wait"]
|
||||||
wait_var["remaining"] = to_context.remaining if to_context else timeout
|
if to_context and to_context.deadline:
|
||||||
|
wait_var["remaining"] = to_context.deadline - self._hass.loop.time()
|
||||||
|
else:
|
||||||
|
wait_var["remaining"] = timeout
|
||||||
wait_var["trigger"] = variables["trigger"]
|
wait_var["trigger"] = variables["trigger"]
|
||||||
done.set()
|
done.set()
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
PyJWT==2.1.0
|
PyJWT==2.1.0
|
||||||
PyNaCl==1.4.0
|
PyNaCl==1.4.0
|
||||||
aiodiscover==1.4.5
|
aiodiscover==1.4.5
|
||||||
aiohttp==3.7.4.post0
|
aiohttp==3.8.0
|
||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
astral==2.2
|
astral==2.2
|
||||||
async-upnp-client==0.22.11
|
async-upnp-client==0.22.11
|
||||||
async_timeout==3.0.1
|
async_timeout==4.0.0
|
||||||
attrs==21.2.0
|
attrs==21.2.0
|
||||||
awesomeversion==21.10.1
|
awesomeversion==21.10.1
|
||||||
backports.zoneinfo;python_version<"3.9"
|
backports.zoneinfo;python_version<"3.9"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
-c homeassistant/package_constraints.txt
|
-c homeassistant/package_constraints.txt
|
||||||
|
|
||||||
# Home Assistant Core
|
# Home Assistant Core
|
||||||
aiohttp==3.7.4.post0
|
aiohttp==3.8.0
|
||||||
astral==2.2
|
astral==2.2
|
||||||
async_timeout==3.0.1
|
async_timeout==4.0.0
|
||||||
attrs==21.2.0
|
attrs==21.2.0
|
||||||
awesomeversion==21.10.1
|
awesomeversion==21.10.1
|
||||||
backports.zoneinfo;python_version<"3.9"
|
backports.zoneinfo;python_version<"3.9"
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -32,9 +32,9 @@ PROJECT_URLS = {
|
||||||
PACKAGES = find_packages(exclude=["tests", "tests.*"])
|
PACKAGES = find_packages(exclude=["tests", "tests.*"])
|
||||||
|
|
||||||
REQUIRES = [
|
REQUIRES = [
|
||||||
"aiohttp==3.7.4.post0",
|
"aiohttp==3.8.0",
|
||||||
"astral==2.2",
|
"astral==2.2",
|
||||||
"async_timeout==3.0.1",
|
"async_timeout==4.0.0",
|
||||||
"attrs==21.2.0",
|
"attrs==21.2.0",
|
||||||
"awesomeversion==21.10.1",
|
"awesomeversion==21.10.1",
|
||||||
'backports.zoneinfo;python_version<"3.9"',
|
'backports.zoneinfo;python_version<"3.9"',
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue