[SOLVED] Openhab2 - Xiaomi Mi Gateway - does not respond

restore from /etc/rc.local.mi, cmd: vi /etc/rc.local->:r rc.local.mi->Esc->:wq

Managed to empty out my rc.local file and save it by accident, had some putty terminal issue. Does anyone have a copy for the aqara gateway, its the one with all the RX, TX, GDN pins on the side of gateway? @cadavre

I dont even have such a file unfortunately to try…

If you want to restore things what you need to do is:

  1. login with root and your password
  2. execute the following command: ./reset.sh

This will do lots of things and do a factory reset, including restoration of rc.local file to its original form. Does not reset bound devices as it turns out or your root password and username.

The issue was that Rx and Tx were reversed from the description.
With a CP2102 module, it worked for me with this wiring :

  • Gateway GND - CP2102 GND
  • Gateway Tx - CP2102 TxD
  • Gateway Rx - CP2102 RxD

Now, I am stuck with SSH access not working with Putty,
I have done what is suggested here :

I don’t know how to have Putty using the dropbear public key.

So. I´m back. I managed to get the xiaomi gatway v3 connected to openhab. I know it´s solved already, but I found it hard to follow as an absolute beginner. That´s why I will explain it again so that maybe more beginners are confident to try.

Beginner to Beginner: How to connect xiaomi gateway to openhab

You need:

  • A special bit to open the housing of the gateway. Picture 1. It´s called “security bit” I went to local “Würth” dealer in Germany where they had one and opened it for me. Then replace by normal screws of similar size.
  • UART to USB tool. I used this one.
  • Maybe the driver to run it. I needed this one for windows.
  • PuTTY. A software to send commands via UART to the gateway. Also to communicate to openhab if desired.
  • nmap / zenmap. This software is used to scan the network.
  • Soldering equipment

Steps

  1. UART and gateway power off.
  2. Get your gatway running with the xiaomi app (I used Ios/Iphone). Click on the gateway, top right “…” will bring you to settings. Click “About”. Click 5 times on the white area until the secret menu/developer mode pops up. Looks like picture 2. Enable the switch and note or screenshot your password. Picture 3.
  3. Start soldering like picture 4. Connect the blue cable to"GND" on the UART. Connect the brown cable to “RXD” (Receiver) on the UART.
  4. Connect UART to Computer.
  5. Check the device on your device list to find the COM. If your device doesn´t show the COM number you might need the driver. See above. Picture 5.
  6. Open PuTTY. Select serial and your COM port of the UART. Set Speed 115200. Don´t open yet.
  7. Turn on the gateway / connect to power. I recommend to put it in a power plug with flip switch for the time.
  8. Press open in PuTTY. A Window opens. You will see the messages of the gateway. Wait until the gateway finnished booting.
  9. Connect the red cable to “TXD” (transmitter) of the UART. Now you are able to send commands to the gateway.
  10. Send command: psm-set network.open_pf 3 send it a few times to be sure.
  11. Check for success with command psm-get network.open_pf. It will say something like networkopen = 3
  12. Turn gateway off. Wait. Turn it on again.
  13. Open nmap. Picture 6. Put nmap -sU -p 9898 -Pn 192.168.178.48 in the action line and execute. You have to take your gateways IP adress. You should see that the port is open. If not, try again.

Video. You may find these two videos usefull. Video 1. Video 2.

This is not my knowledge. I just try to describe it with other words like it would have made it easier for me as non-tekkie. Thanks to all of you for sharing your knowledge.

3 Likes

I have followed this procedure :

But when I want to enter the " psm-set network.open_pf 3" command, I get “-sh; psm-set: command not found”.
I was logged in as root.

Any idea of what is happening ?

Does anybody know where are located the psm-get and psm-set commands ?
find . -name psm doesn’t return an answer.


Hi cadavre,

I followed your description to change root password.
My gateway is still fonctionning but I can’t reproduce some instructions.
nmap -Pn -sU 192.168.1.25 -p 22,9898 gives
22/udp closed ssh
9898/ udp closed monkeycom

As port 22 is closed I can’t ssh

Furthermore the psm-set and psm-get commands are not known
-sh: psm-set: command not found

Do you have any idea of what is going on ?

Can someone tell me why i can’t write te command in putty? I see all the messages. It doesnt stop and i can’t write anything. Thx

I had the same. Then I found out my cable (step 9) was not properly connected. Check your connection, soldering or try a new cable.

1 Like

Are you connected to VCC?
I also used VCC for the first time,and the messages doesnt stop,later I plugged it into a socket ,then putty displays information normally,TRY it

Hi @selbolder, are you resolve hieroglyphs problem?

first of all sorry for my english.
I followed the procedure to the letter but impossible to have the hand in putty.
I can’t get the # to be able to enter the commands:
psm-set network.open_pf 3 and psm-get network.open_pf
for information I am in version 1.4.1_175.0220

thanks for your help i’m going crazy: '(

sorry everything is ok and it was my fault thanks for your tutorial i spent the day for some bullshit when i could have done it in 5 minutes :sob::sob::sob:

Hi! I have aqara gateway. I can connect succesfully to the gateway with uart. But i can’t really modify the “bootargs” parameters. After i modify it and add “init=/bin/bash” and reboot the gateway, always put the original boot. I use the latest firmware. What can i do?

Hi,

Thanks for all of your hard work. I got the UK version of the plug with the board similar to yours. I managed to gain root access but even after adding dropbear before the fac_test line, and restarting the device, I still get connection refused when trying to ssh into the gateway.

Can anyone help please?

There might be more than one rc. file. Please add dropbear to each, because UK gateway might use another one.

BTW First try to run dropbear just from command line. See if it starts ok and if you can connect via SSH to the gateway from another computer (even if still connected to RX/TX).

Thanks will try adding it to all rc files. Did try that from the CLi and it showed a new line, without any errors, but still could not ssh into it :no_mouth:

Hello, i am stuck at trying to start the ssh server by running /etc/init.d/dropbear start but all i get is:

Starting Dropbear SSH server: Pseudo-terminal will not be allocated because stdin is not a terminal.
dropbearkey: Could not resolve hostname rsa: Name or service not known

Running the command dropbear -p 22 returns the “help” for the dropbear command:

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J [user@]host[:port]] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] destination [command]

Do you have any clue how to move forward? I would like to transfer by SCP the client from rothm.

Thanks!

Just an update, was able to initialize dropbear on boot. Here are the last few lines of my rc.local file for reference:

echo "========== start mi================="
echo "===================================="
/lumi/app/miio/start_ot.sh > /dev/null 2>&1 &
/home/root/gw > /dev/null 2>&1 &
/etc/init.d/dropbear start &
/home/root/fac/fac_test

I have ssh enabled. YEESS!! Now for the rest :slight_smile:

Did you try to do this as a root user while connected to the hub via serial?