From 347cbfe3bdaa4c492ef74508bbe47bdfdc49e587 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Mon, 4 Dec 2023 16:44:27 +0100 Subject: [PATCH] Make timeout configurable for cli (#564) --- kasa/cli.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kasa/cli.py b/kasa/cli.py index e71c7b9f..c0a380dc 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -131,6 +131,13 @@ def json_formatter_cb(result, **kwargs): @click.option( "--json", default=False, is_flag=True, help="Output raw device response as JSON." ) +@click.option( + "--timeout", + envvar="KASA_TIMEOUT", + default=5, + required=False, + help="Timeout for device communications.", +) @click.option( "--discovery-timeout", envvar="KASA_DISCOVERY_TIMEOUT", @@ -163,6 +170,7 @@ async def cli( debug, type, json, + timeout, discovery_timeout, username, password, @@ -234,7 +242,7 @@ async def cli( if type is not None: device_type = DeviceType.from_value(type) dev = await SmartDevice.connect( - host, credentials=credentials, device_type=device_type + host, credentials=credentials, device_type=device_type, timeout=timeout ) else: echo("No --type defined, discovering..")