Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions homewizard_energy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""HomeWizard Energy API library."""

from aiohttp import ClientSession
from aiohttp import ClientSession, ClientTimeout

from .errors import DisabledError, InvalidStateError, RequestError, UnsupportedError
from .homewizard_energy import HomeWizardEnergy
Expand All @@ -27,7 +27,12 @@ async def has_v2_api(host: str, websession: ClientSession | None = None) -> bool
# v2 api is https only and returns a 401 Unauthorized when no key provided,
# no connection can be made if the device is not v2
url = f"https://{host}/api"
res = await websession.get(url, ssl=False, raise_for_status=False, timeout=5)
Comment thread
hoefnageltom marked this conversation as resolved.
Resolved
res = await websession.get(
url,
ssl=False,
raise_for_status=False,
timeout=ClientTimeout(total=5),
)
res.close()

return res.status == 401
Expand Down
Loading