diff --git a/lib/extension/otaUpdate.ts b/lib/extension/otaUpdate.ts index 7a8846819..65bce1c9b 100644 --- a/lib/extension/otaUpdate.ts +++ b/lib/extension/otaUpdate.ts @@ -70,19 +70,20 @@ export default class OTAUpdate extends Extension { } @bind private async onZigbeeEvent(data: eventdata.DeviceMessage): Promise { - if (settings.get().ota.disable_automatic_update_check) return; - if (data.type !== 'commandQueryNextImageRequest' || !data.device.definition) return; + if (data.type !== 'commandQueryNextImageRequest' || !data.device.definition || + this.inProgress.has(data.device.ieeeAddr)) return; logger.debug(`Device '${data.device.name}' requested OTA`); + const automaticOTACheckDisabled = settings.get().ota.disable_automatic_update_check; let supportsOTA = data.device.definition.hasOwnProperty('ota'); - if (supportsOTA) { + if (supportsOTA && !automaticOTACheckDisabled) { // When a device does a next image request, it will usually do it a few times after each other // with only 10 - 60 seconds inbetween. It doesn't make sense to check for a new update // each time, so this interval can be set by the user. The default is 1,440 minutes (one day). const updateCheckInterval = settings.get().ota.update_check_interval * 1000 * 60; const check = this.lastChecked.hasOwnProperty(data.device.ieeeAddr) ? (Date.now() - this.lastChecked[data.device.ieeeAddr]) > updateCheckInterval : true; - if (!check || this.inProgress.has(data.device.ieeeAddr)) return; + if (!check) return; this.lastChecked[data.device.ieeeAddr] = Date.now(); let available = false;