Skip to content

Commit

Permalink
async_timeout.timeout with loop keyword argument
Browse files Browse the repository at this point in the history
Fix HA warning: Detected integration that called async_timeout.timeout with loop keyword argument. The loop keyword argument is deprecated and calls will fail after Home Assistant 2022.2.
  • Loading branch information
tmjo committed Jan 16, 2022
1 parent 840456d commit c70643c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions custom_components/norwegiantide/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import pytz
import aiohttp
import async_timeout
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
Expand Down Expand Up @@ -170,11 +169,12 @@ async def api_wrapper(
):
"""Get information from the API."""
try:
async with async_timeout.timeout(TIMEOUT, loop=asyncio.get_event_loop()):
if method == "get":
response = await self._session.get(url, headers=headers)
_LOGGER.debug(f"Response: {response.status} from URL: {url}")
return response
if method == "get":
response = await self._session.get(
url, headers=headers, timeout=aiohttp.ClientTimeout(total=TIMEOUT)
)
_LOGGER.debug(f"Response: {response.status} from URL: {url}")
return response

except asyncio.TimeoutError as exception:
_LOGGER.error(f"Timeout fetching information from API")
Expand Down

0 comments on commit c70643c

Please sign in to comment.