mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
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:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user