Minor changes:; add isActive
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
const log = Java.type('org.slf4j.LoggerFactory').getLogger('js.watch');
|
const log = Java.type('org.slf4j.LoggerFactory').getLogger('js.utils.watch');
|
||||||
log.info('Load watch module');
|
log.info('Load watch module');
|
||||||
|
|
||||||
class Watch {
|
class Watch {
|
||||||
@@ -81,6 +81,13 @@ class Watch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isAlert(watchUUID) {
|
||||||
|
log.debug('Check if there is a running alert for watchObject ' + watchUUID);
|
||||||
|
if (watchUUID in this.#watchObjects) {
|
||||||
|
return this.#watchObjects[watchUUID].alert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
validateWatchConfig(params) {
|
validateWatchConfig(params) {
|
||||||
|
|
||||||
if (params['item'] === undefined) {
|
if (params['item'] === undefined) {
|
||||||
@@ -123,7 +130,7 @@ class Watch {
|
|||||||
|
|
||||||
// Do comparison
|
// Do comparison
|
||||||
if (lib.compare(currentState, this.#watchObjects[watchUUID].targetState, this.#watchObjects[watchUUID].operator)) { // Comparison successful
|
if (lib.compare(currentState, this.#watchObjects[watchUUID].targetState, this.#watchObjects[watchUUID].operator)) { // Comparison successful
|
||||||
log.info(`State ${currentState} is ${this.#watchObjects[watchUUID].operator} ${this.#watchObjects[watchUUID].targetState} triggered by ${watchUUID}`);
|
log.info(`State ${currentState} is ${this.#watchObjects[watchUUID].operator} ${this.#watchObjects[watchUUID].targetState} triggered by ${watchUUID} (${watchItemName})`);
|
||||||
if (this.#watchObjects[watchUUID].alert == true) { // Comparison successful and alert is already active
|
if (this.#watchObjects[watchUUID].alert == true) { // Comparison successful and alert is already active
|
||||||
this.#rescheduleAlert(watchUUID);
|
this.#rescheduleAlert(watchUUID);
|
||||||
} else { // Comparison successful and alert is not active
|
} else { // Comparison successful and alert is not active
|
||||||
|
|||||||
Reference in New Issue
Block a user