This guide will help you fix OTA error by setting up a local Apache server using XAMPP or any other tool to spoof the address for Sonoff OTA updates. By utilizing OpenWRT, Pihole, or Adguard, you can redirect requests from the official server to your local server.
For more details, check the GitHub issue.
- Install XAMPP
- Clone the Repository
- Move Files to htdocs Folder
- Start Apache Server
- Open your web browser and visit http://127.0.0.1/ to confirm that the Apache server is up and running.
Navigate to your OpenWRT interface:
- Go to Network.
- Select DHCP and DNS.
- Under Addresses, add a new entry:
/apid.coolkit.cn/192.168.1.101
. (Replace192.168.1.101
with the IP address of your local server)
- IP:
52.57.118.192
(Optional) - Domain:
ec2-52-57-118-192.eu-central-1.compute.amazonaws.com
(Optional) Ensure Spoofing is Working:
- Confirm the spoofing is effective by opening your browser.
- Visit http://apid.coolkit.cn/v2/d/otaflash.
- Check if you receive a 422 error as a response.
If the spoofing is successful and you get the expected 422 error, you can proceed with the next steps.
-
Install and Start AdGuard Docker
-
Go to the Filter section and then navigate to DNS Rewrites.
-
Add the following domain:
- Domain:
apid.coolkit.cn
- Domain:
-
Set the IP address to your mock server, where you have hosted Docker or Apache server.
- Domain:
apid.coolkit.cn
- IP Address:
<your_mock_server_ip>
- Domain:
-
Save and Enable Protection
-
Configure your AdGuard machine IP as the DNS address in your router.
There are two OTA scripts available:
To flash Sonoff devices using the OTA script, follow these steps:
-
Prepare the Device:
- Put the device into compatible pairing mode.
- Press and hold the onboard button for 5 seconds, release, and repeat for an additional 5 seconds.
- Connect to the new AP "ITEAD-XXX" with the password
12345678
. - Open http://10.10.7.1/ to configure WiFi credentials.
-
Run the OTA Script:
- Clone the respective OTA script repository.
- Execute the script using the following command:
./sonoff-ota-flash.sh -i 192.168.1.111
Alternatively, you can run it directly without manual input
curl -O https://raw.githubusercontent.com/mahipat99/sonoff-ota/main/sonoff-ota-flash-unlock.sh && chmod +x sonoff-ota-flash-unlock.sh && ./sonoff-ota-flash-unlock.sh -i 192.168.1.87
If you have unlocked it through any other method, you can use this command, which skips the OTA unlock process
curl -O https://raw.githubusercontent.com/mahipat99/sonoff-ota/main/sonoff-ota-flash.sh && chmod +x sonoff-ota-flash.sh && ./sonoff-ota-flash.sh -i 192.168.1.87
Ensure you replace 192.168.1.111
with the actual IP address of your Sonoff device.
Feel free to refer to the script repositories for more detailed instructions.