diff --git a/utils/watch.js b/utils/watch.js index 14fd946..bf7a068 100644 --- a/utils/watch.js +++ b/utils/watch.js @@ -209,16 +209,23 @@ class Watch { initialAlertFunc = this.#watchObjects[watchUUID].initialAlertFunc; } - // Create timer to run initial alert rule + // Set alert state this.#watchObjects[watchUUID].alert = true; - this.#watchObjects[watchUUID].startAlertTimer = actions.ScriptExecution.createTimer('startAlert ' + watchUUID, - time.toZDT(this.#watchObjects[watchUUID].alertDelay), - () => { - console.log('Run initial alert function for watchObject ' + watchUUID); - initialAlertFunc(); - } - ); + // Execute initial alert function or create timer to run initial alert rule if required + if (this.#watchObjects[watchUUID].alertDelay == '') { + console.log('Run initial alert function for watchObject ' + watchUUID); + initialAlertFunc(); + } else { + console.log('Run initial alert function for watchObject ' + watchUUID + ' with delay setting ' + this.#watchObjects[watchUUID].alertDelay); + this.#watchObjects[watchUUID].startAlertTimer = actions.ScriptExecution.createTimer('startAlert ' + watchUUID, + time.toZDT(this.#watchObjects[watchUUID].alertDelay), + () => { + console.log('Run initial alert function for watchObject ' + watchUUID); + initialAlertFunc(); + } + ); + } // Create timer to run repeat alert rule if required if (this.#watchObjects[watchUUID].alertRepeat != '') {