python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Unable to discover the device

Open fra87 opened this issue 2 years ago • 4 comments

Describe the bug I'm trying to connect to a Mi Wifi- Range Extender Pro, but every time I try to use the miiocli tool it replies "Unable to discover the device"

Version information (please complete the following information):

  • OS: Windows 11, but tried also with Debian 12
  • python-miio: miiocli, version 0.6.0.dev0

Device information: Can't find it since the program always tell "Unable to discover the device

To Reproduce I downloaded the latest github version (as of 9 August 2023), then created a virtual environment and activated it (python -m venv .venv then .venv\Scripts\activate.bat), installed poetry inside (pip install poetry) and "compiled" the program (poetry install). Finally I run the commands in Console output.

Expected behavior My mi device is discovered and I can get the connected devices.

Console output

The discover command is not successful, but finds the repeater at 192.168.2.33:

(.venv) D:\programming\Python\python-miio>miiocli discover 
INFO:miio.miioprotocol:Sending discovery to <broadcast> with timeout of 5s..
WARNING:miio.miioprotocol:error while reading discover results: Error in path (parsing) -> header
parsing expected 8497 but parsed 0
INFO:miio.discovery:Discovering devices with mDNS for 5 seconds...
INFO:miio.discovery:Found 'xiaomi.repeater.v3' at 192.168.2.33, performing handshake
WARNING:miio.miioprotocol:error while reading discover results: Error in path (parsing) -> header
parsing expected 8497 but parsed 0
WARNING:miio.discovery:Handshake failed: Unable to discover the device 192.168.2.33

The cloud command finds the device and token, and shows a strange localip (my home network is 192.168.2.x):

(.venv) D:\programming\Python\python-miio>miiocli cloud   
Username: ##EMAIL##
Password: ##PASSWORD##
== Mi Wi-Fi Range Extender Pro (1 dispositivi connessi ) ==
        Model: xiaomi.repeater.v3
        Token: ##TOKEN##
        IP: 192.168.1.194 (mac: ##MAC##)
        DID: ##DID##
        Locale: de
        Other fields:
                longitude: 0.0
                uid: ##UID##
                pid: 0
                latitude: 0.0
                family_id: 0
                show_mode: 1
                password:
                prop: {'conn_sta_num': '1'}
                p2p_id: 
                extra: {'isSetPincode': 0, 'pincodeType': 0, 'fw_version': '3.2.10', 'needVerifyCode': 0, 'isPasswordEncrypt': 0, 'mcu_version': '1000'}
                reset_flag: 0
                adminFlag: 1
                pd_id: 466
                shareFlag: 0
                permitLevel: 16

(I masked some info I thought was sensitive; if you need something just ask)

Then if I try to get any information I get the exception:

(.venv) D:\programming\Python\python-miio>miiocli device --ip 192.168.2.30 --token ##TOKEN## info
ERROR:miio.click_common:Exception: Unable to discover the device 192.168.2.30
Traceback (most recent call last):
  File "D:\programming\Python\python-miio\miio\click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\click_common.py", line 305, in wrap
    result = kwargs["result"] = func(*args, **kwargs)
                                ^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\.venv\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\click_common.py", line 270, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\click_common.py", line 218, in call
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\click_common.py", line 184, in _wrap
    self._fetch_info()
  File "D:\programming\Python\python-miio\miio\device.py", line 163, in _fetch_info
    devinfo = DeviceInfo(self.send("miIO.info"))
                         ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\device.py", line 122, in send
    return self._protocol.send(
           ^^^^^^^^^^^^^^^^^^^^
  File "D:\programming\Python\python-miio\miio\miioprotocol.py", line 162, in send
    self.send_handshake()
  File "D:\programming\Python\python-miio\miio\miioprotocol.py", line 75, in send_handshake
    raise DeviceException("Unable to discover the device %s" % self.ip)
miio.exceptions.DeviceException: Unable to discover the device 192.168.2.30

I tried with 192.168.2.30, which is the IP my router associates to the device, 192.168.2.33, which is the IP returned by discover, and 192.168.1.194, which is the IP returned by cloud. I also tried different commands, such as wifirepeater status or configuration, found in #1151, but with the same result.

Note: I tried using the --debug flag, but the result was:

Usage: miiocli device info [OPTIONS]
Try 'miiocli device info --help' for help.

Error: No such option: --debug

Thank you for any help

fra87 avatar Aug 09 '23 07:08 fra87

I tried reproducing the same with the latest version on github (commit 9b17d906d3829dd861d4cb73982dad7d9a5a8e95) which includes the fix #1812, but I get the same results.

Again, but I don't know if it is normal, if I check with miiocli cloud the IP I get is "strange" (it is not in my home network subnet)

fra87 avatar Oct 25 '23 12:10 fra87

Just a question for the other people having the same device. Is it ok that a different IP is reported?

I was trying to see if it was possible to change the device's IP address, but was not able to find anything, and I'm afraid this can be linked to #422

fra87 avatar Nov 08 '23 16:11 fra87

Nope, that's not linked to that issue. Today I switched IP so I'm in the same network but I don't get any improvement.

I noticed that in my home router its IP is 192.168.1.195, while the one reported from the cloud is 192.168.1.194.

Honestly I have no clue on why this happens and/or how to properly debug it. Why cannot I communicate with it? Is this a common issue with the repeater v3?

fra87 avatar Nov 25 '23 20:11 fra87

me,too

yefansky avatar Dec 21 '23 12:12 yefansky