Add try_connect_all to allow initialisation without udp broadcast (#1171)

- Try all valid combinations of protocol/transport/device class and attempt to connect. 
- Add cli command `discover config` to return the connection options after connecting via `try_connect_all`.
- The cli command does not return the actual device for processing as this is not a recommended way to regularly connect to devices.
This commit is contained in:
Steven B.
2024-10-22 14:33:46 +01:00
committed by GitHub
parent 852116795c
commit 3c865b5fb6
5 changed files with 231 additions and 3 deletions

View File

@@ -39,6 +39,7 @@ TYPES = [
]
ENCRYPT_TYPES = [encrypt_type.value for encrypt_type in DeviceEncryptionType]
DEFAULT_TARGET = "255.255.255.255"
def _legacy_type_to_class(_type):
@@ -115,7 +116,7 @@ def _legacy_type_to_class(_type):
@click.option(
"--target",
envvar="KASA_TARGET",
default="255.255.255.255",
default=DEFAULT_TARGET,
required=False,
show_default=True,
help="The broadcast address to be used for discovery.",
@@ -256,6 +257,9 @@ async def cli(
ctx.obj = object()
return
if target != DEFAULT_TARGET and host:
error("--target is not a valid option for single host discovery")
if experimental:
from kasa.experimental.enabled import Enabled