Get Tuya and Xiaomi OTA url
This guide explains how to retrieve a TuYa or Xiaomi OTA file for your device. This file can then be used to update your TuYa/Xiaomi device via Zigbee2MQTT.
Prerequisites:
- Docker
- TuYa bridge or Xiaomi gateway
- Android Studio
Step 1: running the proxy
Execute the following command: docker run --rm -it -p 8080:8080 mitmproxy/mitmproxy
Step 2: setup the Android emulator
Start Android Studio and create a new empty project:
- File -> New -> New Project...
- Phone and Tablet -> Empty Activity -> Next
- Finish
- Click on the emulator ("Pixel3a..." in the case below) -> Device Manager
- Click on the pencil icon of the device, under "Show Advanced Settings" change the "Internal Storage" to "2000". Click "Finish".
- Start the emulator by clicking the play icon.
- On the emulator, go to Settings -> Network & internet -> Internet -> AndroidWifi -> Edit (pencil right top) -> Advanced options -> Proxy -> Manual. For proxy host name fill in the IP address of your computer (e.g. 192.168.2.145), for port fill in 8080. Save.
- Open Chrome on the emulator, go to http://mitm.it and click on "Get mitmproxy-ca-cert.cer" under Android.
- Go to settings again, Security -> Encryption & credentials -> Install a certificate -> CA certificate -> Install anyway -> Drawer icon -> Downloads -> click on the downloaded certificate.
Step 3a: get the TuYa OTA url
- Download the TuYa app apk from this link (IMPORTANT: newer version don't work, tested with 3.12.6). Drag the downloaded apk on the emulator (which will install it).
- Open the TuYa Smart Life app in the emulator, log in with your account
- Make sure the TuYa bridge + the device you want to get the OTA of is already coupled to your account, this cannot be done from the emulator so use your phone for this. Make sure to use the same app on your phone, otherwise the device will not show up (e.g. for iOS use this, not this).
- Click on the device -> edit (pencil icon right top). Click "Check for Firmware Upgrade".
- If an firmware upgrade is available, quickly go back to the output of mitm (step 1), click on the latest request (yes you can click in the console window). This will show your the OTA url (see red box below).
- Tip: to go back to the overview of requests press the
Q
key on your keyboard.
- Tip: to go back to the overview of requests press the
Step 3b: get the Xiaomi OTA url
NOTE: This only works for native Aqara gateways which can be connected to the Aqara Home app (not the Xiaomi home app!)
- Works: ZHWG16LM/HE1-G0, ZHWG15LM, ZHWG12LM
- Doesn't work: ZNDMWG03LM, DGNWG02LM
- Download the Aqara home app apk from this link, tested with version 2.2.5. Drag the downloaded apk on the emulator (which will install it).
- Open the Aqara home app in the emulator, log in with your account
- Make sure the Aqara gateway + the device you want to get the OTA of is already coupled to your account, this cannot be done from the emulator so use your phone for this.
- Click on your device and check for a firmware upgrade.
- If an firmware upgrade is available, quickly go back to the output of mitm (step 1), click on the latest request (yes you can click in the console window). This will show your the OTA url (see screenshot of step 3a).
Step 4: add OTA to zigbee-ota
- Follow this guide to add the OTA to the zigbee-OTA repository.
- Enable the ota by adding
ota: ota.zigbeeOTA
to your device definition (example).