niceboygithub / AqaraGateway

Aqara Gateway/Hub integration for Home Assistant
523 stars 66 forks source link

fail to enable telnet for m1s #177

Closed doveccl closed 7 months ago

doveccl commented 1 year ago
  1. miiocli device --ip 192.168.1.201 --token xxxx info
    Model: lumi.gateway.acn01
    Hardware version: Linux
    Firmware version: 4.0.3_0012
  2. miiocli -d device --ip 192.168.1.201 --token xxxx raw_command set_ip_info '{"ssid":"\"\"","pswd":"123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd"}'
    
    INFO:miio.cli:Debug mode active
    Running command raw_command
    DEBUG:miio.click_common:Unknown model, trying autodetection. None None
    DEBUG:miio.miioprotocol:Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x1b\xa7E\xb7\x00\x00\x15w' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('1ba745b7')
            ts = 1970-01-01 01:31:35
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
    DEBUG:miio.miioprotocol:Discovered 1ba745b7 with ts: 1970-01-01 01:31:35, token: b'ffffffffffffffffffffffffffffffff'
    DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
    DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:36, id: 1) << {'id': 1, 'result': {'life': 5496, 'uid': 117262706, 'model': 'lumi.gateway.acn01', 'token': 'xxxx', 'ipflag': 1, 'miio_ver': '0.0.9', 'mac': '54:EF:44:3B:48:6E', 'fw_ver': '4.0.3_0012', 'hw_ver': 'Linux', 'bootloader_ver': '59bb3c476949dbf35940c613cc48cbd6', 'miio_client_ver': '4.1.8', 'VmPeak': 12432, 'VmRSS': 1728, 'MemFree': 42512, 'ap': {'ssid': 'CDevice', 'bssid': 'd4:da:21:5f:c6:be', 'rssi': '-28', 'freq': 2462}, 'netif': {'localIp': '192.168.1.201', 'mask': '255.255.255.0', 'gw': '192.168.1.1'}, 'miio_times': [5495, 16, 0, 5478]}, 'exe_time': 1}
    DEBUG:miio.device:Detected model lumi.gateway.acn01
    DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 2, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}
    DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:40, id: 2) << {'id': 2, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}
    DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 3
    DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 3, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}
    DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:44, id: 3) << {'id': 3, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}
    DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 2
    DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 4, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}
    DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:48, id: 4) << {'id': 4, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}
    DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 1
    DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 5, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}
    DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:52, id: 5) << {'id': 5, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}
    ERROR:miio.miioprotocol:Got error when receiving: {'code': -9999, 'message': 'user ack timeout'}
    DEBUG:miio.click_common:Exception: Unable to recover failed command
    Traceback (most recent call last):
    File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send
    self._handle_error(payload["error"])
    File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error
    raise RecoverableError(error)
    miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send self._handle_error(payload["error"]) File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error raise RecoverableError(error) miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send self._handle_error(payload["error"]) File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error raise RecoverableError(error) miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send self._handle_error(payload["error"]) File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error raise RecoverableError(error) miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 51, in call return self.main(args, kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 305, in wrap kwargs["result"] = func(*args, *kwargs) File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func return ctx.invoke(f, obj, args, kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke return __callback(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 270, in command_callback return miio_command.call(miio_device, *args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 217, in call return method(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 184, in _wrap return func(self, *args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/miio/device.py", line 126, in raw_command return self.send(command, parameters) File "/usr/local/lib/python3.10/dist-packages/miio/device.py", line 107, in send return self._protocol.send( File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 248, in send raise DeviceException("Unable to recover failed command") from ex miio.exceptions.DeviceException: Unable to recover failed command Error: Unable to recover failed command

niceboygithub commented 1 year ago
  1. miiocli device --ip 192.168.1.201 --token xxxx info

Model: lumi.gateway.acn01

Hardware version: Linux

Firmware version: 4.0.3_0012
  1. miiocli -d device --ip 192.168.1.201 --token xxxx raw_command set_ip_info '{"ssid":"\"\"","pswd":"123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd"}'

INFO:miio.cli:Debug mode active

Running command raw_command

DEBUG:miio.click_common:Unknown model, trying autodetection. None None

DEBUG:miio.miioprotocol:Got a response: Container:

    data = Container:

        data = b'' (total 0)

        value = b'' (total 0)

        offset1 = 32

        offset2 = 32

        length = 0

    header = Container:

        data = b'!1\x00 \x00\x00\x00\x00\x1b\xa7E\xb7\x00\x00\x15w' (total 16)

        value = Container:

            length = 32

            unknown = 0

            device_id = unhexlify('1ba745b7')

            ts = 1970-01-01 01:31:35

        offset1 = 0

        offset2 = 16

        length = 16

    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)

DEBUG:miio.miioprotocol:Discovered 1ba745b7 with ts: 1970-01-01 01:31:35, token: b'ffffffffffffffffffffffffffffffff'

DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}

DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:36, id: 1) << {'id': 1, 'result': {'life': 5496, 'uid': 117262706, 'model': 'lumi.gateway.acn01', 'token': 'xxxx', 'ipflag': 1, 'miio_ver': '0.0.9', 'mac': '54:EF:44:3B:48:6E', 'fw_ver': '4.0.3_0012', 'hw_ver': 'Linux', 'bootloader_ver': '59bb3c476949dbf35940c613cc48cbd6', 'miio_client_ver': '4.1.8', 'VmPeak': 12432, 'VmRSS': 1728, 'MemFree': 42512, 'ap': {'ssid': 'CDevice', 'bssid': 'd4:da:21:5f:c6:be', 'rssi': '-28', 'freq': 2462}, 'netif': {'localIp': '192.168.1.201', 'mask': '255.255.255.0', 'gw': '192.168.1.1'}, 'miio_times': [5495, 16, 0, 5478]}, 'exe_time': 1}

DEBUG:miio.device:Detected model lumi.gateway.acn01

DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 2, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}

DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:40, id: 2) << {'id': 2, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}

DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 3

DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 3, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}

DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:44, id: 3) << {'id': 3, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}

DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 2

DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 4, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}

DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:48, id: 4) << {'id': 4, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}

DEBUG:miio.miioprotocol:Retrying to send failed command, retries left: 1

DEBUG:miio.miioprotocol:192.168.1.201:54321 >>: {'id': 5, 'method': 'set_ip_info', 'params': {'ssid': '""', 'pswd': '123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd'}}

DEBUG:miio.miioprotocol:192.168.1.201:54321 (ts: 1970-01-01 01:31:52, id: 5) << {'id': 5, 'error': {'code': -9999, 'message': 'user ack timeout'}, 'exe_time': 4000}

ERROR:miio.miioprotocol:Got error when receiving: {'code': -9999, 'message': 'user ack timeout'}

DEBUG:miio.click_common:Exception: Unable to recover failed command

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send

    self._handle_error(payload["error"])

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error

    raise RecoverableError(error)

miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send

    self._handle_error(payload["error"])

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error

    raise RecoverableError(error)

miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send

    self._handle_error(payload["error"])

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error

    raise RecoverableError(error)

miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 214, in send

    self._handle_error(payload["error"])

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 274, in _handle_error

    raise RecoverableError(error)

miio.exceptions.RecoverableError: {'code': -9999, 'message': 'user ack timeout'}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 51, in __call__

    return self.main(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main

    rv = self.invoke(ctx)

  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke

    return __callback(*args, **kwargs)

  File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 305, in wrap

    kwargs["result"] = func(*args, **kwargs)

  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func

    return ctx.invoke(f, obj, *args, **kwargs)

  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke

    return __callback(*args, **kwargs)

  File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 270, in command_callback

    return miio_command.call(miio_device, *args, **kwargs)

  File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 217, in call

    return method(*args, **kwargs)

  File "/usr/local/lib/python3.10/dist-packages/miio/click_common.py", line 184, in _wrap

    return func(self, *args, **kwargs)

  File "/usr/local/lib/python3.10/dist-packages/miio/device.py", line 126, in raw_command

    return self.send(command, parameters)

  File "/usr/local/lib/python3.10/dist-packages/miio/device.py", line 107, in send

    return self._protocol.send(

  File "/usr/local/lib/python3.10/dist-packages/miio/miioprotocol.py", line 248, in send

    raise DeviceException("Unable to recover failed command") from ex

miio.exceptions.DeviceException: Unable to recover failed command

Error: Unable to recover failed command

This error happened in some windows. Try to check firewall. Or better solutions use that use Linux (in HA terminal) or MacOS (need to install python-miio)

doveccl commented 1 year ago

@niceboygithub

The error above was appeared on my ubuntu 22.04 (192.168.1.10, ufw disabled) The HA is running on Docker with host network

  homeassistant:
    image: homeassistant/home-assistant
    network_mode: host
    privileged: true
    restart: unless-stopped
    volumes:
      - /data/hass:/config
saltbo commented 1 year ago

same error: user ack timeout

VikeDragon commented 1 year ago

Same error "user ack timeout", are there any other methods to gain access to the hub?

miniknife88 commented 1 year ago

same error

niceboygithub commented 1 year ago

flash modified fw (which enable telnetd and change mosquitto to public only)

niceboygithub commented 1 year ago

After checked, set_ip_info was removed in mi ver 4.0.3_0012.

miniknife88 commented 1 year ago

This means that the modified firmware can only be flashed in through the TTL method ?

niceboygithub commented 1 year ago

It means

  1. The m1s which shipped with new firmware can not enable telnet by set_ip_info.
  2. The m1s which already upgraded to new firmware can not enable telnet by set_ip_info. But if already enabled telnet and post_init.sh was saved to /data/scripts, it will keep telnet.
  3. The m1s which already upgraded to new firmware and there is no post_init.sh. The only way to enable telnet is flash firmware which enable telnet.
daydy16 commented 1 year ago

For me enabling telnet manually worked perfectly. https://github.com/niceboygithub/AqaraGateway#manually-enable-telnet

I had to click no as fast as the guy in the video, but afterwards it blinked green two times and telnet was enabled with username admin and no password.