diff --git a/miio/device.py b/miio/device.py index 855a2d2d8..8f2509a03 100644 --- a/miio/device.py +++ b/miio/device.py @@ -33,6 +33,23 @@ class UpdateState(Enum): Idle = "idle" +def _info_output(result): + """Format the output for info command.""" + s = f"Model: {result.model}\n" + s += f"Hardware version: {result.hardware_version}\n" + s += f"Firmware version: {result.firmware_version}\n" + + from .devicefactory import DeviceFactory + + cls = DeviceFactory.class_for_model(result.model) + dev = DeviceFactory.create(result.ip_address, result.token, force_generic_miot=True) + s += f"Supported using: {cls.__name__}\n" + s += f"Command: miiocli {cls.__name__.lower()} --ip {result.ip_address} --token {result.token}\n" + s += f"Supported by genericmiot: {dev.supports_miot()}" + + return s + + class Device(metaclass=DeviceGroupMeta): """Base class for all device implementations. @@ -121,12 +138,7 @@ def raw_command(self, command, parameters): return self.send(command, parameters) @command( - default_output=format_output( - "", - "Model: {result.model}\n" - "Hardware version: {result.hardware_version}\n" - "Firmware version: {result.firmware_version}\n", - ), + default_output=format_output(result_msg_fmt=_info_output), skip_autodetect=True, ) def info(self, *, skip_cache=False) -> DeviceInfo: