93
93
from pprint import pformat as pf
94
94
from typing import TYPE_CHECKING , Any , Callable , Dict , Optional , Type , cast
95
95
96
+ from aiohttp import ClientSession
97
+
96
98
# When support for cpython older than 3.11 is dropped
97
99
# async_timeout can be replaced with asyncio.timeout
98
100
from async_timeout import timeout as asyncio_timeout
@@ -533,6 +535,7 @@ async def try_connect_all(
533
535
port : int | None = None ,
534
536
timeout : int | None = None ,
535
537
credentials : Credentials | None = None ,
538
+ http_client : ClientSession | None = None ,
536
539
) -> Device | None :
537
540
"""Try to connect directly to a device with all possible parameters.
538
541
@@ -544,6 +547,7 @@ async def try_connect_all(
544
547
:param port: Optionally set a different port for legacy devices using port 9999
545
548
:param timeout: Timeout in seconds device for devices queries
546
549
:param credentials: Credentials for devices that require authentication.
550
+ :param http_client: Optional client session for devices that use http.
547
551
username and password are ignored if provided.
548
552
"""
549
553
from .device_factory import _connect
@@ -570,6 +574,8 @@ async def try_connect_all(
570
574
timeout = timeout ,
571
575
port_override = port ,
572
576
credentials = credentials ,
577
+ http_client = http_client ,
578
+ uses_http = encrypt is not Device .EncryptionType .Xor ,
573
579
)
574
580
)
575
581
and (protocol := get_protocol (config ))
0 commit comments