OTA Updates - Resinchem/YouTube-to-HomeAssistant GitHub Wiki
Over-the-Air Updates
After completing the initial upload via USB, it is possible to then update the bridge .ino file via over-the-air (OTA) updates, eliminating the need to power down the bridge and reconnect it to your computer via USB. There are a few prerequisites for making this work.
Prerequisites
- You must complete the initial upload, with your local settings, via USB the first time
- Your bridge must be on local wifi and the source device for sending the update must be on the same network/subnet
- Your network and source device must support and recognize Multicast DNS (mDNS)*
- You need to know the current IP address of the bridge (get from router or other tools if you do not have this already)
*The mDNS requirement is a requirement of the Arduino IDE, which will only recognize network ports via mDNS. The most recent builds of Windows 10 support mDNS. If you have an older build or operating system (or if you cannot get the bridge port to show up), you may need to install Apple's Bonjour for Windows on the machine where you are using the Arduino IDE.
Performing an OTA Update
- Launch the Arudino IDE and open the updated .ino file you wish to upload.
- Verify you have the right board selected
- For the port, select the network port 'ota_host_name at your-bridge-ip-address' (ota_host_name is the name you defined in the Settings file)
If you do not see the bridge IP address listed under network ports, see the mDNS prerequisites above. You might also try restarting the bridge and relaunching the Arduino IDE. I have found that on occasion, the port disappears. But a restart of the bridge generally resolves this issue. You may also need to increase the ota_boot_time_window
in the settings file (see the Credentials and Settings wiki topic).
- Verify your code via the Arduino IDE to assure there are no errors.
- Open a web browser and enter the IP address of your bridge followed by /otaupdate (example: http://192.168.1.237/otaupdate)
- The web browser should return a message that the bridge is ready to accept an upload:
- Click the Upload button in the Arduino IDE to upload your new file. If a successful connection is made, the output window of the IDE should show Uploading..........
- After the upload completes, the bridge will automatically reboot and execute your new code.
NOTE: If the bridge does not beginning receiving data within the time you defined in the Settings file, it will leave the upload mode and return to the previous bridge mode. If this happens, simply reissue the browser /otaupdate command to enter the OTA update mode again. Since this window needs to be kept relatively short to avoid watchdog resets, it is recommended that you already have the Arduino IDE open and your code verified and ready to upload prior to putting the bridge in update mode.
Performing an OTA Reboot/Restart
In addition to uploading code to the bridge, you can also remotely issue a reboot or restart of the bridge. The reboot will occur within a few seconds of issuing the restart command.
To reboot the bridge remotely, simply enter the IP address of the bridge, followed by /restart (Example: http://192.168.1.103/restart)
If something goes wrong...
In the event that something in the new code prevents the bridge from successfully booting, fixes obviously cannot be pushed over-the-air. In this case, unless the memory of the board has been corrupted or the board is stuck in an unrecoverable boot loop, it should be possible to reflash it via USB with a known good .ino file. Worst case, you can flash a replacement board with a known good version.