From f089e4f23647ab20eb048662f95f7ab68ea73290 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 18 Jun 2018 08:34:57 +0200 Subject: [PATCH] Add discover method to miiocli --- miio/click_common.py | 3 ++- miio/device.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/miio/click_common.py b/miio/click_common.py index 55ddf828d..fe9d6611c 100644 --- a/miio/click_common.py +++ b/miio/click_common.py @@ -210,7 +210,8 @@ def __init__(self, device_class, name=None, invoke_without_command=False, self.device_class = device_class self.device_pass = click.make_pass_decorator(device_class) - attrs.setdefault('params', self.DEFAULT_PARAMS) + # FIXME: Must be made optional for the "discover" command + #attrs.setdefault('params', self.DEFAULT_PARAMS) attrs.setdefault('callback', click.pass_context(self.group_callback)) if result_callback_pass_device and callable(result_callback): result_callback = self.device_pass(result_callback) diff --git a/miio/device.py b/miio/device.py index a1c9598f7..56990df4d 100644 --- a/miio/device.py +++ b/miio/device.py @@ -163,8 +163,10 @@ def do_discover(self) -> Message: return m - @staticmethod - def discover(addr: str=None) -> Any: + @command( + default_output=format_output("Discovering"), + ) + def discover(self, addr: str=None) -> Any: """Scan for devices in the network. This method is used to discover supported devices by sending a handshake message to the broadcast address on port 54321.