Xiaomi Universal IR remote commands retrieval: the easy way


Recently I’ve got Xiaomi Universal IR remote, and looked for an easier way to add the command codes to the Home Assistant config.

It turns out that when you configure the remote via the Mi Home application (it took me about 5 minutes for 25 commands, not a Chinese speaker), all these commands are stored on your phone in a JSON file.

If you have a rooted Android device (which is required for token retrieval, too) then you can find this file at /data/data/com.xiaomi.smarthome/files. The actual file name is randomized, but that’s not a problem, just sort them by date and look for the latest one.

The data is stored in human-readable format, e.g. here’s the TV power button entry:
{ "key": "power", "value": long_base64_string, "freq": 38400 }

Note: I’m using the famous Mi Home v5.0.19

Hope this will help to somebody

Hi lxgreen

I tried without success to the find the relevant json file. Can you confirm that the configured remote codes are still stored on the phone? I used a rooted android device and Mi Home v5.0.19.

Hi km2000us,

Just validated the file existence. The file is still there. In my case the file name is 88133571_device.json (looks like the file name is a combination of device ID followed by the ‘_device’ suffix), and its creation date is Jun 20 (the day I’ve installed the IR). Hope this will help you to find the file.

Thanks. I have found the file. The remote codes are for learnt codes. I was hoping to find pre-programmed codes for air conditioners that are in the database.

Thanks again.

No problem.

BTW, there are plenty of IR code databases available online, like irdb

Hello, I bought a Xiaomi Universal IR Remote, but cannot pair to my network. Seems there is a regional block code… Someone can watch the log and help me find out why the device does not pair with the wifi network?
Thanks in advance.
Here’s the log. https://pastebin.com/iQFAvbYt


there are multiple “No address associated with hostname” errors. The both failed hosts “api.io.mi.com” and “cnbj1.fds.api.xiaomi.com” are successfully resolved on my machine. I guess it may be a DNS issue. Please try to run nslookup on these hosts from different machines within your network, and see if they are resolved.

Also, please set your region to “China Mainland” unless you already set it in MI Home app. There are some devices available only for this region.

Hello lxgreen.

I already set the region on Xiaomi app to China Mainland… these are the responses of nslookup, both on computer and phone:

nslookup api.io.mi.com



Non-authoritative answer:

Name: api.io.mi.com


Name: api.io.mi.com



nslookup cnbj1.fds.api.xiaomi.com



Non-authoritative answer:

Name: cnbj1.fds.api.xiaomi.com


The most annoying thing is that the app doesn’t see the Univeral IR remote unless I turn on the GPS, if I don’t it just don’t see it. That’s why I thought there was a regional block.

Any suggestion?
By the way, thank you for answer this issue. :slight_smile:

Are there any preset codes in this file? If you add a device from the database program.

That was my hope. But, I could not find any preset codes. This file only contains learnt codes.

I was able to learn the codes for TV. But for the air conditioner, the learned commands do not work.
Although the teams inside Mi Home application work on AC.

As for my AC, it looks like the remote sends commands that contain data like the fan speed, temperature, mode, and so on. The Turn off command works OK (I think it is just constant code), and the learned Turn on command always sets 20 degrees, fan speed 3 even if the ac had other settings before. This feature can be useful to have a list of presets and apply them automatically. However, the commands like increase/decrease temperature cannot be learned.