Skip to content

Instantly share code, notes, and snippets.

View jamilg's full-sized avatar

Jamil Gasimov jamilg

  • Vilnius, Lithuania
View GitHub Profile
@jamilg
jamilg / rc4mi.py
Created August 23, 2023 22:15 — forked from socram8888/rc4mi.py
Encryption and decryption tool for Xiaomi Mi Home's API
from base64 import b64decode, b64encode
import hashlib, argparse
def rc4mi(data, key):
S, j, out = bytearray(range(256)), 0, bytearray()
for i in range(256):
j = (j + key[i % len(key)] + S[i]) % 256
S[i], S[j] = S[j], S[i]
@jamilg
jamilg / mi_home_external_automation.md
Last active August 25, 2023 14:44 — forked from Alienmario/mi_home_external_automation.md
Mi home external automation (Non rooted, Android 11 and Rooted Android 10)

This is forked gist from Alienmario with some additions for newer version of MI Home app (8.7.708) and Android 10 (Rooted)

  1. Create a manual scene in Mi Home for the device you'd like to control

    In my version of Mi Home the manual scene is called Batch Control.

  2. Use Http Toolkit to figure out the scene id.
    • Install the app on PC and Android, follow the instructions - install CA certificate and connect

      MI Home app did not trust automatically installed user certificate so I had to add system-wide certificate. To do so, you have to be rooted. Connect your phone to PC and open cmd. Run adb shell and then su -c whoami. Grant root access to shell from your phone. Run the same commands again, it should output root now. It means adb sees that you are rooted. >Open Http Toolkit on your PC and select "Android device via ADB" (it should be available now). System certificate is installed automatically at this point. On your phone Http Toolkit app

// Comment
public class Testing {
public Testing() {
}
public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}