@@ -3695,8 +3695,9 @@ void setup_OtaFirmware(){
36953695
36963696
36973697/* *
3698- * Executes a pending forced OTA update using execOTA(JsonDocument&), matching
3699- * the HW-Reg implementation exactly. onComplete handles the reboot on success.
3698+ * Executes a pending OTA update. If _otaPendingDoc is empty the update was
3699+ * triggered from HA via MQTT (non-forced); otherwise it is a forced update
3700+ * with a specific document from the HTTP API.
37003701*/
37013702void otaFirmware_checkPending (){
37023703
@@ -3705,6 +3706,14 @@ void otaFirmware_checkPending(){
37053706 }
37063707
37073708 _otaUpdateInProcess = true ;
3709+ _otaCurrentPartition[0 ] = ' \0 ' ;
3710+
3711+ if (_otaPendingDoc.size () == 0 ){
3712+ _otaPendingRequest = false ;
3713+ otaFirmware.execOTA ();
3714+ _otaUpdateInProcess = false ;
3715+ return ;
3716+ }
37083717
37093718 otaFirmware.setApplicationName (_otaPendingDoc[" application_name" ]);
37103719
@@ -3720,8 +3729,6 @@ void otaFirmware_checkPending(){
37203729 }
37213730 }
37223731
3723- _otaCurrentPartition[0 ] = ' \0 ' ;
3724-
37253732 otaFirmware.onProgress ([](const char * partition, size_t written, size_t total){
37263733 _otaUpdateInProcess = true ;
37273734 if (strcmp (partition, _otaCurrentPartition) != 0 ){
@@ -4375,7 +4382,7 @@ void eventHandler_mqttMessageReceived(char* topic, byte* pl, unsigned int length
43754382 mqttClient.publish (topic, buffer);
43764383
43774384 if (!_otaManifestUrl.isEmpty ()){
4378- otaFirmware. execOTA () ;
4385+ _otaPendingRequest = true ;
43794386 }
43804387 return ;
43814388 }
0 commit comments