From 6f35814b647dba1231d25f3245dad06f89f71a2e Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Aug 2023 23:01:49 +0200 Subject: [PATCH 01/10] [rules] Improve Rule Builder type defs Closes #217. Signed-off-by: Florian Hotze --- rules/condition-builder.js | 13 ++++--- rules/operation-builder.js | 29 +++++++++++---- rules/rule-builder.js | 9 ++++- rules/trigger-builder.js | 72 +++++++++++++++++++++++++------------- 4 files changed, 86 insertions(+), 37 deletions(-) diff --git a/rules/condition-builder.js b/rules/condition-builder.js index 767eb0c63..945a1a7df 100644 --- a/rules/condition-builder.js +++ b/rules/condition-builder.js @@ -14,6 +14,7 @@ class ConditionBuilder { this._fn = fn; } + /** @private */ _then (condition, fn) { this._builder.setCondition(condition); return new operations.OperationBuilder(this._builder, fn); @@ -22,7 +23,7 @@ class ConditionBuilder { /** * Move to the rule operations * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {operations.OperationBuilder} */ then (fn) { @@ -53,12 +54,13 @@ class ConditionBuilder { */ class ConditionConf { constructor (conditionBuilder) { + /** @private */ this.conditionBuilder = conditionBuilder; } /** * - * @param {*} function an optional function + * @param {*} fn an optional function * @returns ConditionBuilder */ then (fn) { @@ -81,6 +83,7 @@ class FunctionConditionConf extends ConditionConf { */ constructor (fn, conditionBuilder) { super(conditionBuilder); + /** @private */ this.fn = fn; } @@ -92,8 +95,7 @@ class FunctionConditionConf extends ConditionConf { * @returns {boolean} true only if the operations should be run */ check (...args) { - const answer = this.fn(args); - return answer; + return this.fn(args); } } @@ -107,11 +109,12 @@ class FunctionConditionConf extends ConditionConf { class ItemStateConditionConf extends ConditionConf { constructor (itemName, conditionBuilder) { super(conditionBuilder); + /** @private */ this.item_name = itemName; } /** - * Checks if item state is equal to vlaue + * Checks if item state is equal to value * @param {*} value * @returns {this} */ diff --git a/rules/operation-builder.js b/rules/operation-builder.js index d4d013628..c63a8f955 100644 --- a/rules/operation-builder.js +++ b/rules/operation-builder.js @@ -18,12 +18,14 @@ class OperationBuilder { this._fn = fn; } + /** @private */ _finishErr () { if (this._fn) { throw new Error('rule already completed'); } } + /** @private */ _then (operation, group, name, description, tags, id) { this._builder.name = name; this._builder.description = description; @@ -64,9 +66,9 @@ class OperationBuilder { * @param {string} command the command to send * @returns {SendCommandOrUpdateOperation} the operation */ - send (c) { + send (command) { this._finishErr(); - return new SendCommandOrUpdateOperation(this, c); + return new SendCommandOrUpdateOperation(this, command); } /** @@ -75,13 +77,13 @@ class OperationBuilder { * @param {string} update the update to send * @returns {SendCommandOrUpdateOperation} the operation */ - postUpdate (c) { + postUpdate (update) { this._finishErr(); - return new SendCommandOrUpdateOperation(this, c, false); + return new SendCommandOrUpdateOperation(this, update, false); } /** - * Specifies the a command 'ON' should be sent as a result of this rule firing. + * Specifies the command 'ON' should be sent as a result of this rule firing. * * @returns {SendCommandOrUpdateOperation} the operation */ @@ -91,7 +93,7 @@ class OperationBuilder { } /** - * Specifies the a command 'OFF' should be sent as a result of this rule firing. + * Specifies the command 'OFF' should be sent as a result of this rule firing. * * @returns {SendCommandOrUpdateOperation} the operation */ @@ -307,6 +309,7 @@ class CopyStateOperation extends OperationConfig { class SendCommandOrUpdateOperation extends OperationConfig { constructor (operationBuilder, dataOrSupplier, isCommand = true, optionalDesc) { super(operationBuilder); + /** @private */ this.isCommand = isCommand; if (typeof dataOrSupplier === 'function') { this.dataFn = dataOrSupplier; @@ -349,6 +352,7 @@ class SendCommandOrUpdateOperation extends OperationConfig { return this; } + /** @private */ _run (args) { for (const toItemName of this.toItemNames) { const item = items.getItem(toItemName); @@ -363,10 +367,12 @@ class SendCommandOrUpdateOperation extends OperationConfig { this.next && this.next.execute(args); } + /** @private */ _complete () { return (typeof this.toItemNames) !== 'undefined'; } + /** @private */ describe (compact) { if (compact) { return this.dataDesc + (this.isCommand ? '⌘' : '↻') + this.toItemNames + (this.next ? this.next.describe() : ''); @@ -386,6 +392,7 @@ class SendCommandOrUpdateOperation extends OperationConfig { class ToggleOperation extends OperationConfig { constructor (operationBuilder) { super(operationBuilder); + /** @private */ this.next = null; /** @type {function} */ this.toItem = function (itemName) { @@ -397,8 +404,11 @@ class ToggleOperation extends OperationConfig { this.next = next; return this; }; + /** @private */ this._run = () => this.doToggle() && (this.next && this.next.execute()); + /** @private */ this._complete = () => true; + /** @private */ this.describe = () => `toggle ${this.itemName}` + (this.next ? ` and ${this.next.describe()}` : ''); } @@ -426,13 +436,18 @@ class TimingItemStateOperation extends OperationConfig { throw Error('Must specify item state value to wait for!'); } + /** @private */ this.item_changed_trigger_config = itemChangedTriggerConfig; + /** @private */ this.duration_ms = (typeof duration === 'number' ? duration : parseDuration.parse(duration)); + /** @private */ this._complete = itemChangedTriggerConfig._complete; + /** @private */ this.describe = () => itemChangedTriggerConfig.describe() + ' for ' + duration; } + /** @private */ _toOHTriggers () { // each time we're triggered, set a callback. // If the item changes to something else, cancel the callback. @@ -447,6 +462,7 @@ class TimingItemStateOperation extends OperationConfig { } } + /** @private */ _executeHook (next) { if (items.get(this.item_changed_trigger_config.item_name).toString() === this.item_changed_trigger_config.to_value) { this._startWait(next); @@ -455,6 +471,7 @@ class TimingItemStateOperation extends OperationConfig { } } + /** @private */ _startWait (next) { this.current_wait = setTimeout(next, this.duration_ms); } diff --git a/rules/rule-builder.js b/rules/rule-builder.js index affc80624..c88e48056 100644 --- a/rules/rule-builder.js +++ b/rules/rule-builder.js @@ -11,6 +11,7 @@ class RuleBuilder { constructor (toggleable) { /** @private */ this._triggerConfs = []; + /** @private */ this.toggleable = toggleable || false; } @@ -23,6 +24,7 @@ class RuleBuilder { return new triggers.TriggerBuilder(this); } + /** @private */ addTrigger (triggerConf) { if (!triggerConf._complete()) { throw Error('Trigger is not complete!'); @@ -31,15 +33,18 @@ class RuleBuilder { return this; } + /** @private */ setCondition (condition) { if (typeof condition === 'function') { condition = new conditions.FunctionConditionConf(condition); } + /** @private */ this.condition = condition; return this; } + /** @private */ setOperation (operation, optionalRuleGroup) { if (typeof operation === 'function') { const operationFunction = operation; @@ -55,7 +60,9 @@ class RuleBuilder { } } + /** @private */ this.operation = operation; + /** @private */ this.optionalRuleGroup = optionalRuleGroup; const generatedTriggers = this._triggerConfs.flatMap(x => x._toOHTriggers()); @@ -108,7 +115,7 @@ class RuleBuilder { module.exports = { RuleBuilder, /** - * Create a new {RuleBuilder} chain for easily creating rules. + * Create a new {@link RuleBuilder} chain for easily creating rules. * * @example Basic rule * rules.when().item("F1_Light").changed().then().send("changed").toItem("F2_Light").build("My Rule", "My First Rule"); diff --git a/rules/trigger-builder.js b/rules/trigger-builder.js index 8cc654ee5..3eae7affc 100644 --- a/rules/trigger-builder.js +++ b/rules/trigger-builder.js @@ -13,21 +13,25 @@ class TriggerBuilder { this._builder = builder; } + /** @private */ _setTrigger (trigger) { - this.currentTigger = trigger; - return this.currentTigger; + this.currentTrigger = trigger; + return this.currentTrigger; } + /** @private */ _or () { - this._builder.addTrigger(this.currentTigger); + this._builder.addTrigger(this.currentTrigger); return this; } + /** @private */ _then (fn) { this._or(); return new operations.OperationBuilder(this._builder, fn); } + /** @private */ _if (fn) { this._or(); return new conditions.ConditionBuilder(this._builder, fn); @@ -39,8 +43,8 @@ class TriggerBuilder { * @param {string} channelName the name of the channel * @returns {ChannelTriggerConfig} the trigger config */ - channel (s) { - return this._setTrigger(new ChannelTriggerConfig(s, this)); + channel (channelName) { + return this._setTrigger(new ChannelTriggerConfig(channelName, this)); } /** @@ -49,18 +53,18 @@ class TriggerBuilder { * @param {string} cronExpression the cron expression * @returns {CronTriggerConfig} the trigger config */ - cron (s) { - return this._setTrigger(new CronTriggerConfig(s, this)); + cron (cronExpression) { + return this._setTrigger(new CronTriggerConfig(cronExpression, this)); } /** - * Specifies an item as the source of changes to trigger a rule. + * Specifies an Item as the source of changes to trigger a rule. * - * @param {string} itemName the name of the item + * @param {string} itemName the name of the Item * @returns {ItemTriggerConfig} the trigger config */ - item (s) { - return this._setTrigger(new ItemTriggerConfig(s, false, this)); + item (itemName) { + return this._setTrigger(new ItemTriggerConfig(itemName, false, this)); } /** @@ -69,8 +73,8 @@ class TriggerBuilder { * @param {string} groupName the name of the group * @returns {ItemTriggerConfig} the trigger config */ - memberOf (s) { - return this._setTrigger(new ItemTriggerConfig(s, true, this)); + memberOf (groupName) { + return this._setTrigger(new ItemTriggerConfig(groupName, true, this)); } /** @@ -79,8 +83,8 @@ class TriggerBuilder { * @param {string} thingUID the UID of the Thing * @returns {ThingTriggerConfig} the trigger config */ - thing (s) { - return this._setTrigger(new ThingTriggerConfig(s, this)); + thing (thingUID) { + return this._setTrigger(new ThingTriggerConfig(thingUID, this)); } /** @@ -100,6 +104,7 @@ class TriggerBuilder { */ class TriggerConf { constructor (triggerBuilder) { + /** @private */ this.triggerBuilder = triggerBuilder; } @@ -115,7 +120,7 @@ class TriggerConf { /** * Move to the rule operations * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {operations.OperationBuilder} */ then (fn) { @@ -125,7 +130,7 @@ class TriggerConf { /** * Move to the rule condition * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {conditions.ConditionBuilder} */ if (fn) { @@ -145,6 +150,7 @@ class ChannelTriggerConfig extends TriggerConf { this._toOHTriggers = () => [triggers.ChannelEventTrigger(this.channelName, this.eventName)]; } + /** @private */ describe (compact) { if (compact) { return this.channelName + (this.eventName ? `:${this.eventName}` : ''); @@ -174,6 +180,7 @@ class ChannelTriggerConfig extends TriggerConf { return this; } + /** @private */ _complete () { return typeof (this.eventName) !== 'undefined'; } @@ -189,15 +196,19 @@ class ChannelTriggerConfig extends TriggerConf { class CronTriggerConfig extends TriggerConf { constructor (timeStr, triggerBuilder) { super(triggerBuilder); + /** @private */ this.timeStr = timeStr; + /** @private */ this._complete = () => true; + /** @private */ this._toOHTriggers = () => [triggers.GenericCronTrigger(this.timeStr)]; + /** @private */ this.describe = (compact) => compact ? `cron_${this.timeStr}` : `matches cron "${this.timeStr}"`; } } /** - * item based trigger + * Item based trigger * * @memberof TriggerBuilder * @extends TriggerConf @@ -206,12 +217,14 @@ class CronTriggerConfig extends TriggerConf { class ItemTriggerConfig extends TriggerConf { constructor (itemOrName, isGroup, triggerBuilder) { super(triggerBuilder); - this.type = isGroup ? 'memberOf' : 'item'; + this.type = isGroup ? 'memberOf' : 'Item'; if (typeof itemOrName !== 'string') { itemOrName = itemOrName.name; } + /** @private */ this.item_name = itemOrName; + /** @private */ this.describe = () => `${this.type} ${this.item_name} changed`; this.of = this.to; // receivedCommand().of(..) } @@ -219,7 +232,7 @@ class ItemTriggerConfig extends TriggerConf { /** * Item to * - * @param {*} value this item should be triggered to + * @param {*} value this Item should be triggered to * @returns {ItemTriggerConfig} */ to (value) { @@ -241,7 +254,7 @@ class ItemTriggerConfig extends TriggerConf { } /** - * item changed to OFF + * Item changed to OFF * * @returns {ItemTriggerConfig} */ @@ -250,7 +263,7 @@ class ItemTriggerConfig extends TriggerConf { } /** - * item changed to ON + * Item changed to ON^ * * @returns {ItemTriggerConfig} */ @@ -259,7 +272,7 @@ class ItemTriggerConfig extends TriggerConf { } /** - * item recieved command + * Item received command * * @returns {ItemTriggerConfig} */ @@ -269,7 +282,7 @@ class ItemTriggerConfig extends TriggerConf { } /** - * item recieved update + * Item received update * * @returns {ItemTriggerConfig} */ @@ -279,7 +292,7 @@ class ItemTriggerConfig extends TriggerConf { } /** - * item changed state + * Item changed state * * @returns {ItemTriggerConfig} */ @@ -297,10 +310,12 @@ class ItemTriggerConfig extends TriggerConf { return new operations.TimingItemStateOperation(this, timespan); } + /** @private */ _complete () { return typeof (this.op_type) !== 'undefined'; } + /** @private */ describe (compact) { switch (this.op_type) { case 'changed': @@ -332,6 +347,7 @@ class ItemTriggerConfig extends TriggerConf { } } + /** @private */ _toOHTriggers () { if (this.type === 'memberOf') { switch (this.op_type) { @@ -358,6 +374,7 @@ class ItemTriggerConfig extends TriggerConf { } } + /** @private */ _executeHook () { const getReceivedCommand = (args) => args.receivedCommand; @@ -385,13 +402,16 @@ class ItemTriggerConfig extends TriggerConf { class ThingTriggerConfig extends TriggerConf { constructor (thingUID, triggerBuilder) { super(triggerBuilder); + /** @private */ this.thingUID = thingUID; } + /** @private */ _complete () { return typeof (this.op_type) !== 'undefined'; } + /** @private */ describe (compact) { switch (this.op_type) { case 'changed': @@ -456,6 +476,7 @@ class ThingTriggerConfig extends TriggerConf { return this; } + /** @private */ _toOHTriggers () { switch (this.op_type) { case 'changed': @@ -482,6 +503,7 @@ class SystemTriggerConfig extends TriggerConf { this.describe = (compact) => compact ? `system:${this.level}` : `system level "${this.level}"`; } + /** @private */ _complete () { return typeof (this.level) !== 'undefined'; } From e5f407b7ca0b95cd8308c3c04e874484a1539e4b Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Aug 2023 23:03:02 +0200 Subject: [PATCH 02/10] Regenerate type defs Signed-off-by: Florian Hotze --- types/rules/condition-builder.d.ts | 13 ++-- types/rules/condition-builder.d.ts.map | 2 +- types/rules/operation-builder.d.ts | 59 ++++++++++------ types/rules/operation-builder.d.ts.map | 2 +- types/rules/rule-builder.d.ts | 21 ++++-- types/rules/rule-builder.d.ts.map | 2 +- types/rules/trigger-builder.d.ts | 97 ++++++++++++++++---------- types/rules/trigger-builder.d.ts.map | 2 +- 8 files changed, 123 insertions(+), 75 deletions(-) diff --git a/types/rules/condition-builder.d.ts b/types/rules/condition-builder.d.ts index 107ed8119..b71388482 100644 --- a/types/rules/condition-builder.d.ts +++ b/types/rules/condition-builder.d.ts @@ -12,7 +12,8 @@ export class FunctionConditionConf { * @param {*} fn callback which determines whether the condition passes */ constructor(fn: any, conditionBuilder: any); - fn: any; + /** @private */ + private fn; /** * Checks whether the rule operations should be run * @@ -31,9 +32,10 @@ export class FunctionConditionConf { */ export class ItemStateConditionConf { constructor(itemName: any, conditionBuilder: any); - item_name: any; + /** @private */ + private item_name; /** - * Checks if item state is equal to vlaue + * Checks if item state is equal to value * @param {*} value * @returns {this} */ @@ -58,11 +60,12 @@ export class ConditionBuilder { private _builder; /** @private */ private _fn; - _then(condition: any, fn: any): operations.OperationBuilder; + /** @private */ + private _then; /** * Move to the rule operations * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {operations.OperationBuilder} */ then(fn: any): operations.OperationBuilder; diff --git a/types/rules/condition-builder.d.ts.map b/types/rules/condition-builder.d.ts.map index d11fac58b..2041edc57 100644 --- a/types/rules/condition-builder.d.ts.map +++ b/types/rules/condition-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"condition-builder.d.ts","sourceRoot":"","sources":["../../rules/condition-builder.js"],"names":[],"mappings":"AAoEA;;;;;;GAMG;AACH;IACE;;;;SAIK;IACL,4CAGC;IADC,QAAY;IAGd;;;;;;SAMK;IACL,cAGC;CACF;AAED;;;;;;GAMG;AACH;IACE,kDAGC;IADC,eAAyB;IAG3B;;;;SAIK;IACL,gBAFe,IAAI,CAKlB;IAFC,cAAqB;IAIvB;;;;SAIK;IACL,cAHiB,GAAG,KACL,IAAI,CAKlB;IAED,+BAMC;CACF;AAxID;;;;GAIG;AACH;IACE,mCAKC;IAJC,eAAe;IACf,iBAAuB;IACvB,eAAe;IACf,YAAa;IAGf,4DAGC;IAED;;;;;OAKG;IACH,eAFa,WAAW,gBAAgB,CASvC;IAED;;;;;;QAMI;IACJ,sBAHY,MAAM,GACJ,sBAAsB,CAKnC;IAFC,kCAA2D;CAG9D"} \ No newline at end of file +{"version":3,"file":"condition-builder.d.ts","sourceRoot":"","sources":["../../rules/condition-builder.js"],"names":[],"mappings":"AAsEA;;;;;;GAMG;AACH;IACE;;;;SAIK;IACL,4CAIC;IAFC,eAAe;IACf,WAAY;IAGd;;;;;;SAMK;IACL,cAEC;CACF;AAED;;;;;;GAMG;AACH;IACE,kDAIC;IAFC,eAAe;IACf,kBAAyB;IAG3B;;;;SAIK;IACL,gBAFe,IAAI,CAKlB;IAFC,cAAqB;IAIvB;;;;SAIK;IACL,cAHiB,GAAG,KACL,IAAI,CAKlB;IAED,+BAMC;CACF;AA3ID;;;;GAIG;AACH;IACE,mCAKC;IAJC,eAAe;IACf,iBAAuB;IACvB,eAAe;IACf,YAAa;IAGf,eAAe;IACf,cAGC;IAED;;;;;OAKG;IACH,eAFa,WAAW,gBAAgB,CASvC;IAED;;;;;;QAMI;IACJ,sBAHY,MAAM,GACJ,sBAAsB,CAKnC;IAFC,kCAA2D;CAG9D"} \ No newline at end of file diff --git a/types/rules/operation-builder.d.ts b/types/rules/operation-builder.d.ts index 7c4741fdd..8825c3b20 100644 --- a/types/rules/operation-builder.d.ts +++ b/types/rules/operation-builder.d.ts @@ -8,7 +8,8 @@ export type Item = import("../items/items").Item; */ export class SendCommandOrUpdateOperation extends OperationConfig { constructor(operationBuilder: any, dataOrSupplier: any, isCommand: boolean, optionalDesc: any); - isCommand: boolean; + /** @private */ + private isCommand; dataFn: any; dataDesc: any; /** @@ -33,9 +34,12 @@ export class SendCommandOrUpdateOperation extends OperationConfig { */ and(next: any): SendCommandOrUpdateOperation; next: any; - _run(args: any): void; - _complete(): boolean; - describe(compact: any): string; + /** @private */ + private _run; + /** @private */ + private _complete; + /** @private */ + private describe; } /** * Timing Item state @@ -46,13 +50,20 @@ export class SendCommandOrUpdateOperation extends OperationConfig { */ export class TimingItemStateOperation extends OperationConfig { constructor(operationBuilder: any, itemChangedTriggerConfig: any, duration: any); - item_changed_trigger_config: any; - duration_ms: any; - _complete: any; - describe: () => string; - _toOHTriggers(): any[]; - _executeHook(next: any): void; - _startWait(next: any): void; + /** @private */ + private item_changed_trigger_config; + /** @private */ + private duration_ms; + /** @private */ + private _complete; + /** @private */ + private describe; + /** @private */ + private _toOHTriggers; + /** @private */ + private _executeHook; + /** @private */ + private _startWait; current_wait: NodeJS.Timeout; _cancelWait(): void; } @@ -64,14 +75,18 @@ export class TimingItemStateOperation extends OperationConfig { * @hideconstructor */ export class ToggleOperation extends OperationConfig { - next: any; + /** @private */ + private next; /** @type {function} */ toItem: Function; /** @type {function} */ and: Function; - _run: () => any; - _complete: () => boolean; - describe: () => string; + /** @private */ + private _run; + /** @private */ + private _complete; + /** @private */ + private describe; /** * Toggle the state of an item * @@ -153,8 +168,10 @@ export class OperationBuilder { private _builder; /** @private */ private _fn; - _finishErr(): void; - _then(operation: any, group: any, name: any, description: any, tags: any, id: any): void; + /** @private */ + private _finishErr; + /** @private */ + private _then; /** * Build this rule * @@ -178,22 +195,22 @@ export class OperationBuilder { * @param {string} command the command to send * @returns {SendCommandOrUpdateOperation} the operation */ - send(c: any): SendCommandOrUpdateOperation; + send(command: string): SendCommandOrUpdateOperation; /** * Specifies that an update should be posted as a result of this rule firing. * * @param {string} update the update to send * @returns {SendCommandOrUpdateOperation} the operation */ - postUpdate(c: any): SendCommandOrUpdateOperation; + postUpdate(update: string): SendCommandOrUpdateOperation; /** - * Specifies the a command 'ON' should be sent as a result of this rule firing. + * Specifies the command 'ON' should be sent as a result of this rule firing. * * @returns {SendCommandOrUpdateOperation} the operation */ sendOn(): SendCommandOrUpdateOperation; /** - * Specifies the a command 'OFF' should be sent as a result of this rule firing. + * Specifies the command 'OFF' should be sent as a result of this rule firing. * * @returns {SendCommandOrUpdateOperation} the operation */ diff --git a/types/rules/operation-builder.d.ts.map b/types/rules/operation-builder.d.ts.map index d0dae6ba6..c80245879 100644 --- a/types/rules/operation-builder.d.ts.map +++ b/types/rules/operation-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"operation-builder.d.ts","sourceRoot":"","sources":["../../rules/operation-builder.js"],"names":[],"mappings":"mBAIc,OAAO,gBAAgB,EAAE,IAAI;AAuS3C;;;;;;GAMG;AACH;IACE,+FAUC;IARC,mBAA0B;IAExB,YAA4B;IAC5B,cAA6C;IAOjD;;;;;SAKK;IACL,sBAHa,IAAI,EAAE,GAAG,MAAM,EAAE,GACf,4BAA4B,CAK1C;IAFC,mBAA8E;IAIhF;;;;;SAKK;IACL,mBAHa,IAAI,GAAG,MAAM,GACX,4BAA4B,CAK1C;IAED;;;;SAIK;IACL,gBAFe,4BAA4B,CAK1C;IAFC,UAAgB;I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ED;;;;;;SAMK;IACL,UAFe,4BAA4B,CAK1C;IAED;;;;;;SAMK;IACL,UAFe,4BAA4B,CAK1C;IAED;;;;;SAKK;IACL,aAFe,kBAAkB,CAKhC;IAED;;;;;SAKK;IACL,oBAFe,kBAAkB,CAKhC;CACF;AAED;;;GAGG;AACH;IACE,mCAEC;IADC,sBAAwC;IAG1C;;;;;SAKK;IACL,eAHa,MAAM,GACJ,gBAAgB,CAK9B;IAFC,cAAkB;IAIpB;;;;;;;SAOK;IACL,aALa,MAAM,gBACN,MAAM,SACN,aAAa,OACb,MAAM,QAIlB;CACF"} \ No newline at end of file +{"version":3,"file":"operation-builder.d.ts","sourceRoot":"","sources":["../../rules/operation-builder.js"],"names":[],"mappings":"mBAIc,OAAO,gBAAgB,EAAE,IAAI;AAyS3C;;;;;;GAMG;AACH;IACE,+FAWC;IATC,eAAe;IACf,kBAA0B;IAExB,YAA4B;IAC5B,cAA6C;IAOjD;;;;;SAKK;IACL,sBAHa,IAAI,EAAE,GAAG,MAAM,EAAE,GACf,4BAA4B,CAK1C;IAFC,mBAA8E;IAIhF;;;;;SAKK;IACL,mBAHa,IAAI,GAAG,MAAM,GACX,4BAA4B,CAK1C;IAED;;;;SAIK;IACL,gBAFe,4BAA4B,CAK1C;IAFC,UAAgB;IAIlB,eAAe;IACf,aAYC;IAED,eAAe;IACf,kBAEC;IAED,eAAe;IACf,iBAMC;CACF;AA0CD;;;;;;GAMG;AACH;IACE,iFAeC;IATC,eAAe;IACf,oCAA2D;IAC3D,eAAe;IACf,oBAA4F;IAE5F,eAAe;IACf,kBAAmD;IACnD,eAAe;IACf,iBAA8E;IAGhF,eAAe;IACf,sBAYC;IAED,eAAe;IACf,qBAMC;IAED,eAAe;IACf,mBAEC;IADC,6BAAsD;IAGxD,oBAIC;CACF;AAnGD;;;;;;GAMG;AACH;IAGI,eAAe;IACf,aAAgB;IAChB,uBAAuB;IACvB,iBAGC;IACD,uBAAuB;IACvB,cAGC;IACD,eAAe;IACf,aAA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AHa,MAAM,GACJ,gBAAgB,CAK9B;IAFC,cAAkB;IAIpB;;;;;;;SAOK;IACL,aALa,MAAM,gBACN,MAAM,SACN,aAAa,OACb,MAAM,QAIlB;CACF"} \ No newline at end of file diff --git a/types/rules/rule-builder.d.ts b/types/rules/rule-builder.d.ts index 5137beff3..54771b2d1 100644 --- a/types/rules/rule-builder.d.ts +++ b/types/rules/rule-builder.d.ts @@ -6,19 +6,26 @@ export class RuleBuilder { constructor(toggleable: any); /** @private */ private _triggerConfs; - toggleable: any; + /** @private */ + private toggleable; /** * Specifies when the rule should occur. Will create a standard rule. * * @returns {triggers.TriggerBuilder} rule builder */ when(): triggers.TriggerBuilder; - addTrigger(triggerConf: any): RuleBuilder; - setCondition(condition: any): RuleBuilder; - condition: any; - setOperation(operation: any, optionalRuleGroup: any): HostRule; - operation: any; - optionalRuleGroup: any; + /** @private */ + private addTrigger; + /** @private */ + private setCondition; + /** @private */ + private condition; + /** @private */ + private setOperation; + /** @private */ + private operation; + /** @private */ + private optionalRuleGroup; describe(compact: any): string; } import triggers = require("./trigger-builder"); diff --git a/types/rules/rule-builder.d.ts.map b/types/rules/rule-builder.d.ts.map index d7346ea24..1a6e83f7c 100644 --- a/types/rules/rule-builder.d.ts.map +++ b/types/rules/rule-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"rule-builder.d.ts","sourceRoot":"","sources":["../../rules/rule-builder.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACE,6BAIC;IAHC,eAAe;IACf,sBAAuB;IACvB,gBAAqC;IAGvC;;;;SAIK;IACL,QAFe,SAAS,cAAc,CAIrC;IAED,0CAMC;IAED,0CAOC;IAFC,eAA0B;IAI5B,+DAsDC;IAvCC,eAA0B;IAC1B,uBAA0C;IAwC5C,+BAMC;CACF;;AAmBO,4EAAkD"} \ No newline at end of file +{"version":3,"file":"rule-builder.d.ts","sourceRoot":"","sources":["../../rules/rule-builder.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACE,6BAKC;IAJC,eAAe;IACf,sBAAuB;IACvB,eAAe;IACf,mBAAqC;IAGvC;;;;SAIK;IACL,QAFe,SAAS,cAAc,CAIrC;IAED,eAAe;IACf,mBAMC;IAED,eAAe;IACf,qBAQC;IAHC,eAAe;IACf,kBAA0B;IAI5B,eAAe;IACf,qBAwDC;IAzCC,eAAe;IACf,kBAA0B;IAC1B,eAAe;IACf,0BAA0C;IAwC5C,+BAMC;CACF;;AAmBO,4EAAkD"} \ No newline at end of file diff --git a/types/rules/trigger-builder.d.ts b/types/rules/trigger-builder.d.ts index 1de56ed38..89a51109c 100644 --- a/types/rules/trigger-builder.d.ts +++ b/types/rules/trigger-builder.d.ts @@ -7,10 +7,14 @@ */ export class CronTriggerConfig extends TriggerConf { constructor(timeStr: any, triggerBuilder: any); - timeStr: any; - _complete: () => boolean; - _toOHTriggers: () => HostTrigger[]; - describe: (compact: any) => string; + /** @private */ + private timeStr; + /** @private */ + private _complete; + /** @private */ + private _toOHTriggers; + /** @private */ + private describe; } /** * @memberof TriggerBuilder @@ -21,7 +25,8 @@ export class ChannelTriggerConfig extends TriggerConf { constructor(channelName: any, triggerBuilder: any); channelName: any; _toOHTriggers: () => HostTrigger[]; - describe(compact: any): string; + /** @private */ + private describe; /** * trigger a specific event name * @@ -37,10 +42,11 @@ export class ChannelTriggerConfig extends TriggerConf { */ triggered(eventName: string): ChannelTriggerConfig; eventName: string; - _complete(): boolean; + /** @private */ + private _complete; } /** - * item based trigger + * Item based trigger * * @memberof TriggerBuilder * @extends TriggerConf @@ -49,13 +55,15 @@ export class ChannelTriggerConfig extends TriggerConf { export class ItemTriggerConfig extends TriggerConf { constructor(itemOrName: any, isGroup: any, triggerBuilder: any); type: string; - item_name: any; - describe(compact: any): string; + /** @private */ + private item_name; + /** @private */ + private describe; of: (value: any) => ItemTriggerConfig; /** * Item to * - * @param {*} value this item should be triggered to + * @param {*} value this Item should be triggered to * @returns {ItemTriggerConfig} */ to(value: any): ItemTriggerConfig; @@ -68,32 +76,32 @@ export class ItemTriggerConfig extends TriggerConf { from(value: any): ItemTriggerConfig; from_value: any; /** - * item changed to OFF + * Item changed to OFF * * @returns {ItemTriggerConfig} */ toOff(): ItemTriggerConfig; /** - * item changed to ON + * Item changed to ON^ * * @returns {ItemTriggerConfig} */ toOn(): ItemTriggerConfig; /** - * item recieved command + * Item received command * * @returns {ItemTriggerConfig} */ receivedCommand(): ItemTriggerConfig; op_type: string; /** - * item recieved update + * Item received update * * @returns {ItemTriggerConfig} */ receivedUpdate(): ItemTriggerConfig; /** - * item changed state + * Item changed state * * @returns {ItemTriggerConfig} */ @@ -104,9 +112,12 @@ export class ItemTriggerConfig extends TriggerConf { * @returns {ItemTriggerConfig} */ for(timespan: any): ItemTriggerConfig; - _complete(): boolean; - _toOHTriggers(): HostTrigger[]; - _executeHook(): (next: any, args: any) => any; + /** @private */ + private _complete; + /** @private */ + private _toOHTriggers; + /** @private */ + private _executeHook; } /** * Thing based trigger @@ -117,9 +128,12 @@ export class ItemTriggerConfig extends TriggerConf { */ export class ThingTriggerConfig extends TriggerConf { constructor(thingUID: any, triggerBuilder: any); - thingUID: any; - _complete(): boolean; - describe(compact: any): string; + /** @private */ + private thingUID; + /** @private */ + private _complete; + /** @private */ + private describe; /** * thing changed * @@ -147,7 +161,8 @@ export class ThingTriggerConfig extends TriggerConf { */ to(value: any): ThingTriggerConfig; to_value: any; - _toOHTriggers(): HostTrigger[]; + /** @private */ + private _toOHTriggers; } /** * System based trigger @@ -159,7 +174,8 @@ export class ThingTriggerConfig extends TriggerConf { export class SystemTriggerConfig extends TriggerConf { _toOHTriggers: () => HostTrigger[]; describe: (compact: any) => string; - _complete(): boolean; + /** @private */ + private _complete; /** * System trigger * @@ -207,46 +223,50 @@ export class TriggerBuilder { constructor(builder: any); /** @private */ private _builder; - _setTrigger(trigger: any): any; - currentTigger: any; - _or(): TriggerBuilder; - _then(fn: any): operations.OperationBuilder; - _if(fn: any): conditions.ConditionBuilder; + /** @private */ + private _setTrigger; + currentTrigger: any; + /** @private */ + private _or; + /** @private */ + private _then; + /** @private */ + private _if; /** * Specifies a channel event as a source for the rule to fire. * * @param {string} channelName the name of the channel * @returns {ChannelTriggerConfig} the trigger config */ - channel(s: any): ChannelTriggerConfig; + channel(channelName: string): ChannelTriggerConfig; /** * Specifies a cron schedule for the rule to fire. * * @param {string} cronExpression the cron expression * @returns {CronTriggerConfig} the trigger config */ - cron(s: any): CronTriggerConfig; + cron(cronExpression: string): CronTriggerConfig; /** - * Specifies an item as the source of changes to trigger a rule. + * Specifies an Item as the source of changes to trigger a rule. * - * @param {string} itemName the name of the item + * @param {string} itemName the name of the Item * @returns {ItemTriggerConfig} the trigger config */ - item(s: any): ItemTriggerConfig; + item(itemName: string): ItemTriggerConfig; /** * Specifies a group member as the source of changes to trigger a rule. * * @param {string} groupName the name of the group * @returns {ItemTriggerConfig} the trigger config */ - memberOf(s: any): ItemTriggerConfig; + memberOf(groupName: string): ItemTriggerConfig; /** * Specifies a Thing status event as a source for the rule to fire. * * @param {string} thingUID the UID of the Thing * @returns {ThingTriggerConfig} the trigger config */ - thing(s: any): ThingTriggerConfig; + thing(thingUID: string): ThingTriggerConfig; /** * Specifies a system event as a source for the rule to fire. * @@ -261,7 +281,8 @@ export class TriggerBuilder { */ declare class TriggerConf { constructor(triggerBuilder: any); - triggerBuilder: any; + /** @private */ + private triggerBuilder; /** * Add an additional Trigger * @@ -271,14 +292,14 @@ declare class TriggerConf { /** * Move to the rule operations * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {operations.OperationBuilder} */ then(fn: any): operations.OperationBuilder; /** * Move to the rule condition * - * @param {*} function the optional function to execute + * @param {*} fn the optional function to execute * @returns {conditions.ConditionBuilder} */ if(fn: any): conditions.ConditionBuilder; diff --git a/types/rules/trigger-builder.d.ts.map b/types/rules/trigger-builder.d.ts.map index 06ee9ac18..3e639bf0e 100644 --- a/types/rules/trigger-builder.d.ts.map +++ b/types/rules/trigger-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AAqLA;;;;;;GAMG;AACH;IACE,+CAMC;IAJC,aAAsB;IACtB,yBAA2B;IAC3B,mCAAsE;IACtE,mCAAgG;CAEnG;AA7DD;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,+BAMC;IAED;;;;;SAKK;IACL,cAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAKlC;IAFC,kBAAgC;IAIlC,qBAEC;CACF;AAmBD;;;;;;GAMG;AACH;IACE,gEAUC;IARC,aAAyC;IAKzC,eAA2B;IA0F7B,+BA6BC;IArHC,oBAOa,iBAAiB,CAPb;IAGnB;;;;;SAKK;IACL,gBAFe,iBAAiB,CAK/B;IAFC,cAAqB;IAIvB;;;;SAIK;IACL,kBAFe,iBAAiB,CAQ/B;IAFC,gBAAuB;IAIzB;;;;SAIK;IACL,SAFe,iBAAiB,CAI/B;IAED;;;;SAIK;IACL,QAFe,iBAAiB,CAI/B;IAED;;;;SAIK;IACL,mBAFe,iBAAiB,CAK/B;IAFC,gBAAgC;IAIlC;;;;SAIK;IACL,kBAFe,iBAAiB,CAK/B;IAED;;;;SAIK;IACL,WAFe,iBAAiB,CAK/B;IAED;;;;SAIK;IACL,oBAFe,iBAAiB,CAI/B;IAED,qBAEC;IAiCD,+BAwBC;IAED,8CAcC;CACF;AAED;;;;;;GAMG;AACH;IACE,gDAGC;IADC,cAAwB;IAG1B,qBAEC;IAED,+BAmBC;IAED;;;;SAIK;IACL,WAFe,kBAAkB,CAKhC;IAFC,gBAAwB;IAI1B;;;;SAIK;IACL,WAFe,kBAAkB,CAKhC;IAED;;;;SAIK;IACL,kBAFe,kBAAkB,CAQhC;IAFC,gBAAuB;IAIzB;;;;SAIK;IACL,gBAFe,kBAAkB,CAKhC;IAFC,cAAqB;IAIvB,+BASC;CACF;AAED;;;;;;GAMG;AACH;IAGI,mCAAyE;IACzE,mCAA8F;IAGhG,qBAEC;IAED;;;;SAIK;IACL,eAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,qBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,yBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,qBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,mBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,wBAFe,mBAAmB,CAQjC;IAFC,WAAkB;CAGrB;AA7hBD;;;;GAIG;AACH;IACE,0BAGC;IAFC,eAAe;IACf,iBAAuB;IAGzB,+BAGC;IAFC,mBAA4B;IAI9B,sBAGC;IAED,4CAGC;IAED,0CAGC;IAED;;;;;SAKK;IACL,iBAFe,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,cAFe,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,cAFe,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,kBAFe,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,eAFe,kBAAkB,CAIhC;IAED;;;;;SAKK;IACL,UAFe,mBAAmB,CAIjC;CACF;AAED;;;GAGG;AACH;IACE,iCAEC;IADC,oBAAoC;IAGtC;;;;SAIK;IACL,MAFe,cAAc,CAI5B;IAED;;;;;SAKK;IACL,eAFe,WAAW,gBAAgB,CAIzC;IAED;;;;;SAKK;IACL,aAFe,WAAW,gBAAgB,CAIzC;CACF"} \ No newline at end of file +{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AA4LA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;I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;;;;SAIK;IACL,qBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,yBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,qBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,mBAFe,mBAAmB,CAIjC;IAED;;;;SAIK;IACL,wBAFe,mBAAmB,CAQjC;IAFC,WAAkB;CAGrB;AAnjBD;;;;GAIG;AACH;IACE,0BAGC;IAFC,eAAe;IACf,iBAAuB;IAGzB,eAAe;IACf,oBAGC;IAFC,oBAA6B;IAI/B,eAAe;IACf,YAGC;IAED,eAAe;IACf,cAGC;IAED,eAAe;IACf,YAGC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,eAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,oBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,gBAHa,MAAM,GACJ,kBAAkB,CAIhC;IAED;;;;;SAKK;IACL,UAFe,mBAAmB,CAIjC;CACF;AAED;;;GAGG;AACH;IACE,iCAGC;IAFC,eAAe;IACf,uBAAoC;IAGtC;;;;SAIK;IACL,MAFe,cAAc,CAI5B;IAED;;;;;SAKK;IACL,eAFe,WAAW,gBAAgB,CAIzC;IAED;;;;;SAKK;IACL,aAFe,WAAW,gBAAgB,CAIzC;CACF"} \ No newline at end of file From 391a4bef534e07b7bca7aba8925db683afdde10b Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Aug 2023 23:30:24 +0200 Subject: [PATCH 03/10] [triggers] Minor JSDoc improvements Signed-off-by: Florian Hotze --- triggers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triggers.js b/triggers.js index 8d35e65f7..b6447a2ad 100644 --- a/triggers.js +++ b/triggers.js @@ -244,7 +244,7 @@ const GenericCronTrigger = (expression, triggerName) => * TimeOfDayTrigger('19:00'); * * @memberof triggers - * @param {string} time the time expression defining the triggering schedule + * @param {string} time the time expression (in `HH:mm`) defining the triggering schedule * @param {string} [triggerName] the optional name of the trigger to create */ const TimeOfDayTrigger = (time, triggerName) => From e09dd4403406d24052d36a4197122e8e0f049e04 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Aug 2023 23:33:39 +0200 Subject: [PATCH 04/10] [rules] Add DateTime and TimeOfDay triggers to Rule Builder Closes #280. Signed-off-by: Florian Hotze --- rules/trigger-builder.js | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/rules/trigger-builder.js b/rules/trigger-builder.js index 3eae7affc..435968ff7 100644 --- a/rules/trigger-builder.js +++ b/rules/trigger-builder.js @@ -57,6 +57,16 @@ class TriggerBuilder { return this._setTrigger(new CronTriggerConfig(cronExpression, this)); } + /** + * Specifies a time schedule for the rule to fire. + * + * @param {string} time the time expression (in `HH:mm`) defining the triggering schedule + * @returns {TimeOfDayTriggerConfig} the trigger config + */ + timeOfDay (time) { + return this._setTrigger(new TimeOfDayTriggerConfig(time, this)); + } + /** * Specifies an Item as the source of changes to trigger a rule. * @@ -96,6 +106,16 @@ class TriggerBuilder { system () { return this._setTrigger(new SystemTriggerConfig(this)); } + + /** + * Specifies a DateTime Item whose (optional) date and time schedule the rule to fire. + * + * @param {string} itemName the name of the Item to monitor for change + * @returns {*} + */ + dateTime (itemName) { + return this._setTrigger(new DateTimeTriggerConfig(itemName, this)); + } } /** @@ -207,6 +227,27 @@ class CronTriggerConfig extends TriggerConf { } } +/** + * Time of day based trigger + * + * @memberof TriggerBuilder + * @extends TriggerConf + * @hideconstructor + */ +class TimeOfDayTriggerConfig extends TriggerConf { + constructor (timeStr, triggerBuilder) { + super(triggerBuilder); + /** @private */ + this.timeStr = timeStr; + /** @private */ + this._complete = () => true; + /** @private */ + this._toOHTriggers = () => [triggers.TimeOfDayTrigger(this.timeStr)]; + /** @private */ + this.describe = (compact) => compact ? `timeOfDay_${this.timeStr}` : `matches time of day "${this.timeStr}"`; + } +} + /** * Item based trigger * @@ -567,6 +608,33 @@ class SystemTriggerConfig extends TriggerConf { } } +class DateTimeTriggerConfig extends TriggerConf { + constructor (itemName, triggerBuilder) { + super(triggerBuilder); + /** @private */ + this._itemName = itemName; + /** @private */ + this._timeOnly = false; + /** @private */ + this._complete = () => true; + /** @private */ + this._toOHTriggers = () => [triggers.DateTimeTrigger(this._itemName, this._timeOnly)]; + /** @private */ + this.describe = (compact) => compact ? `dateTime_${this._itemName}` : `matches ${this._timeOnly ? 'time' : 'date and time'} of Item "${this._itemName}"`; + } + + /** + * Specifies whether only the time of the Item should be compared or the date and time. + * + * @param {boolean} [timeOnly=true] + * @returns {DateTimeTriggerConfig} + */ + timeOnly (timeOnly = true) { + this._timeOnly = timeOnly; + return this; + } +} + module.exports = { CronTriggerConfig, ChannelTriggerConfig, From 114db0a0b98a86ee5a42bc097a31ef28e2d53c30 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Aug 2023 23:33:48 +0200 Subject: [PATCH 05/10] Regenerate types Signed-off-by: Florian Hotze --- types/rules/trigger-builder.d.ts | 32 ++++++++++++++++++++++++++++ types/rules/trigger-builder.d.ts.map | 2 +- types/triggers.d.ts | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/types/rules/trigger-builder.d.ts b/types/rules/trigger-builder.d.ts index 89a51109c..7df4620ea 100644 --- a/types/rules/trigger-builder.d.ts +++ b/types/rules/trigger-builder.d.ts @@ -246,6 +246,13 @@ export class TriggerBuilder { * @returns {CronTriggerConfig} the trigger config */ cron(cronExpression: string): CronTriggerConfig; + /** + * Specifies a time schedule for the rule to fire. + * + * @param {string} time the time expression (in `HH:mm`) defining the triggering schedule + * @returns {TimeOfDayTriggerConfig} the trigger config + */ + timeOfDay(time: string): TimeOfDayTriggerConfig; /** * Specifies an Item as the source of changes to trigger a rule. * @@ -274,6 +281,13 @@ export class TriggerBuilder { * @returns {SystemTriggerConfig} the trigger config */ system(): SystemTriggerConfig; + /** + * Specifies a DateTime Item whose (optional) date and time schedule the rule to fire. + * + * @param {string} itemName the name of the Item to monitor for change + * @returns {*} + */ + dateTime(itemName: string): any; } /** * {RuleBuilder} RuleBuilder triggers @@ -304,6 +318,24 @@ declare class TriggerConf { */ if(fn: any): conditions.ConditionBuilder; } +/** + * Time of day based trigger + * + * @memberof TriggerBuilder + * @extends TriggerConf + * @hideconstructor + */ +declare class TimeOfDayTriggerConfig extends TriggerConf { + constructor(timeStr: any, triggerBuilder: any); + /** @private */ + private timeStr; + /** @private */ + private _complete; + /** @private */ + private _toOHTriggers; + /** @private */ + private describe; +} import operations = require("./operation-builder"); import conditions = require("./condition-builder"); export {}; diff --git a/types/rules/trigger-builder.d.ts.map b/types/rules/trigger-builder.d.ts.map index 3e639bf0e..bbd524ca2 100644 --- a/types/rules/trigger-builder.d.ts.map +++ b/types/rules/trigger-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AA4LA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;SAKK;IACL,cAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAKlC;IAFC,kBAAgC;IAIlC,eAAe;IACf,kBAEC;CACF;AAuBD;;;;;;GAMG;AACH;IACE,gEAYC;IAVC,aAAyC;IAKzC,eAAe;IACf,kBAA2B;IA4F7B,eAAe;IACf,iBA6BC;IAvHC,oBAOa,iBAAiB,CAPb;IAGnB;;;;;SAKK;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FC,oBAA6B;IAI/B,eAAe;IACf,YAGC;IAED,eAAe;IACf,cAGC;IAED,eAAe;IACf,YAGC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,eAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,oBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,gBAHa,MAAM,GACJ,kBAAkB,CAIhC;IAED;;;;;SAKK;IACL,UAFe,mBAAmB,CAIjC;CACF;AAED;;;GAGG;AACH;IACE,iCAGC;IAFC,eAAe;IACf,uBAAoC;IAGtC;;;;SAIK;IACL,MAFe,cAAc,CAI5B;IAED;;;;;SAKK;IACL,eAFe,WAAW,gBAAgB,CAIzC;IAED;;;;;SAKK;IACL,aAFe,WAAW,gBAAgB,CAIzC;CACF"} \ No newline at end of file +{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AAgNA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;SAKK;IACL,cAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAKlC;IAFC,kBAAgC;IAIlC,eAAe;IACf,kBAEC;CACF;AA4CD;;;;;;GAMG;AACH;IACE,gEAYC;IAVC,aAAyC;IAKzC,eAAe;IACf,kBAA2B;IA4F7B,eAAe;IACf,iBA6BC;IAvHC,oBAOa,iBAAiB,CAPb;IAGnB;;;;;SAKK;IACL,gBAF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B;IAI/B,eAAe;IACf,YAGC;IAED,eAAe;IACf,cAGC;IAED,eAAe;IACf,YAGC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,sBAAsB,CAIlC;IAED;;;;;SAKK;IACL,eAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,oBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,gBAHa,MAAM,GACJ,kBAAkB,CAIhC;IAED;;;;;SAKK;IACL,UAFe,mBAAmB,CAIjC;IAED;;;;;OAKG;IACH,mBAHW,MAAM,OAKhB;CACF;AAED;;;GAGG;AACH;IACE,iCAGC;IAFC,eAAe;IACf,uBAAoC;IAGtC;;;;SAIK;IACL,MAFe,cAAc,CAI5B;IAED;;;;;SAKK;IACL,eAFe,WAAW,gBAAgB,CAIzC;IAED;;;;;SAKK;IACL,aAFe,WAAW,gBAAgB,CAIzC;CACF;AAuED;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAoE;IACpE,eAAe;IACf,iBAA4G;CAE/G"} \ No newline at end of file diff --git a/types/triggers.d.ts b/types/triggers.d.ts index 9272e2bc6..0f4a1c478 100644 --- a/types/triggers.d.ts +++ b/types/triggers.d.ts @@ -148,7 +148,7 @@ export function GenericCronTrigger(expression: string, triggerName?: string): Ho * TimeOfDayTrigger('19:00'); * * @memberof triggers - * @param {string} time the time expression defining the triggering schedule + * @param {string} time the time expression (in `HH:mm`) defining the triggering schedule * @param {string} [triggerName] the optional name of the trigger to create */ export function TimeOfDayTrigger(time: string, triggerName?: string): HostTrigger; From d4624f7102bb7ee967e373c0cc6bb41ce29ecd97 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 13 Aug 2023 14:44:43 +0200 Subject: [PATCH 06/10] [triggers] Add debug logging Signed-off-by: Florian Hotze --- triggers.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/triggers.js b/triggers.js index b6447a2ad..60d378ee2 100644 --- a/triggers.js +++ b/triggers.js @@ -8,6 +8,8 @@ */ const utils = require('./utils'); +const log = require('./log')('triggers'); + /** * @type {Item} * @private @@ -31,6 +33,8 @@ function _createTrigger (typeString, name, config) { name = utils.randomUUID().toString(); } + log.debug('Creating {} trigger as {} with config: {}', typeString, name, JSON.stringify(config || {})); + return ModuleBuilder.createTrigger() .withId(name) .withTypeUID(typeString) From a66410acc491afd58f24cc7f79b7e32bd51f0864 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 13 Aug 2023 15:02:55 +0200 Subject: [PATCH 07/10] [rules] Fix wrong, add missing and reformat JSDoc for trigger builder Signed-off-by: Florian Hotze --- rules/trigger-builder.js | 264 ++++++++++++++++++++------------------- 1 file changed, 136 insertions(+), 128 deletions(-) diff --git a/rules/trigger-builder.js b/rules/trigger-builder.js index 435968ff7..beffeb70b 100644 --- a/rules/trigger-builder.js +++ b/rules/trigger-builder.js @@ -38,21 +38,21 @@ class TriggerBuilder { } /** - * Specifies a channel event as a source for the rule to fire. - * - * @param {string} channelName the name of the channel - * @returns {ChannelTriggerConfig} the trigger config - */ + * Specifies a channel event as a source for the rule to fire. + * + * @param {string} channelName the name of the channel + * @returns {ChannelTriggerConfig} the trigger config + */ channel (channelName) { return this._setTrigger(new ChannelTriggerConfig(channelName, this)); } /** - * Specifies a cron schedule for the rule to fire. - * - * @param {string} cronExpression the cron expression - * @returns {CronTriggerConfig} the trigger config - */ + * Specifies a cron schedule for the rule to fire. + * + * @param {string} cronExpression the cron expression + * @returns {CronTriggerConfig} the trigger config + */ cron (cronExpression) { return this._setTrigger(new CronTriggerConfig(cronExpression, this)); } @@ -68,41 +68,41 @@ class TriggerBuilder { } /** - * Specifies an Item as the source of changes to trigger a rule. - * - * @param {string} itemName the name of the Item - * @returns {ItemTriggerConfig} the trigger config - */ + * Specifies an Item as the source of changes to trigger a rule. + * + * @param {string} itemName the name of the Item + * @returns {ItemTriggerConfig} the trigger config + */ item (itemName) { return this._setTrigger(new ItemTriggerConfig(itemName, false, this)); } /** - * Specifies a group member as the source of changes to trigger a rule. - * - * @param {string} groupName the name of the group - * @returns {ItemTriggerConfig} the trigger config - */ + * Specifies a group member as the source of changes to trigger a rule. + * + * @param {string} groupName the name of the group + * @returns {ItemTriggerConfig} the trigger config + */ memberOf (groupName) { return this._setTrigger(new ItemTriggerConfig(groupName, true, this)); } /** - * Specifies a Thing status event as a source for the rule to fire. - * - * @param {string} thingUID the UID of the Thing - * @returns {ThingTriggerConfig} the trigger config - */ + * Specifies a Thing status event as a source for the rule to fire. + * + * @param {string} thingUID the UID of the Thing + * @returns {ThingTriggerConfig} the trigger config + */ thing (thingUID) { return this._setTrigger(new ThingTriggerConfig(thingUID, this)); } /** - * Specifies a system event as a source for the rule to fire. - * - * @memberof TriggerBuilder - * @returns {SystemTriggerConfig} the trigger config - */ + * Specifies a system event as a source for the rule to fire. + * + * @memberof TriggerBuilder + * @returns {SystemTriggerConfig} the trigger config + */ system () { return this._setTrigger(new SystemTriggerConfig(this)); } @@ -111,7 +111,7 @@ class TriggerBuilder { * Specifies a DateTime Item whose (optional) date and time schedule the rule to fire. * * @param {string} itemName the name of the Item to monitor for change - * @returns {*} + * @returns {DateTimeTriggerConfig} the trigger config */ dateTime (itemName) { return this._setTrigger(new DateTimeTriggerConfig(itemName, this)); @@ -129,30 +129,30 @@ class TriggerConf { } /** - * Add an additional Trigger - * - * @returns {TriggerBuilder} - */ + * Add an additional Trigger + * + * @returns {TriggerBuilder} + */ or () { return this.triggerBuilder._or(); } /** - * Move to the rule operations - * - * @param {*} fn the optional function to execute - * @returns {operations.OperationBuilder} - */ + * Move to the rule operations + * + * @param {*} fn the optional function to execute + * @returns {operations.OperationBuilder} + */ then (fn) { return this.triggerBuilder._then(fn); } /** - * Move to the rule condition - * - * @param {*} fn the optional function to execute - * @returns {conditions.ConditionBuilder} - */ + * Move to the rule condition + * + * @param {*} fn the optional function to execute + * @returns {conditions.ConditionBuilder} + */ if (fn) { return this.triggerBuilder._if(fn); } @@ -180,21 +180,21 @@ class ChannelTriggerConfig extends TriggerConf { } /** - * trigger a specific event name - * - * @param {string} eventName - * @returns {ChannelTriggerConfig} - */ + * trigger a specific event name + * + * @param {string} eventName + * @returns {ChannelTriggerConfig} + */ to (eventName) { return this.triggered(eventName); } /** - * trigger a specific event name - * - * @param {string} eventName - * @returns {ChannelTriggerConfig} - */ + * trigger a specific event name + * + * @param {string} eventName + * @returns {ChannelTriggerConfig} + */ triggered (eventName) { this.eventName = eventName || ''; return this; @@ -271,21 +271,21 @@ class ItemTriggerConfig extends TriggerConf { } /** - * Item to - * - * @param {*} value this Item should be triggered to - * @returns {ItemTriggerConfig} - */ + * Item to + * + * @param {*} value this Item should be triggered to + * @returns {ItemTriggerConfig} + */ to (value) { this.to_value = value; return this; } /** - * Item from - * @param {*} value this items should be triggered from - * @returns {ItemTriggerConfig} - */ + * Item from + * @param {*} value this items should be triggered from + * @returns {ItemTriggerConfig} + */ from (value) { if (this.op_type !== 'changed') { throw Error('.from(..) only available for .changed()'); @@ -295,58 +295,58 @@ class ItemTriggerConfig extends TriggerConf { } /** - * Item changed to OFF - * - * @returns {ItemTriggerConfig} - */ + * Item changed to OFF + * + * @returns {ItemTriggerConfig} + */ toOff () { return this.to('OFF'); } /** - * Item changed to ON^ - * - * @returns {ItemTriggerConfig} - */ + * Item changed to ON + * + * @returns {ItemTriggerConfig} + */ toOn () { return this.to('ON'); } /** - * Item received command - * - * @returns {ItemTriggerConfig} - */ + * Item received command + * + * @returns {ItemTriggerConfig} + */ receivedCommand () { this.op_type = 'receivedCommand'; return this; } /** - * Item received update - * - * @returns {ItemTriggerConfig} - */ + * Item received update + * + * @returns {ItemTriggerConfig} + */ receivedUpdate () { this.op_type = 'receivedUpdate'; return this; } /** - * Item changed state - * - * @returns {ItemTriggerConfig} - */ + * Item changed state + * + * @returns {ItemTriggerConfig} + */ changed () { this.op_type = 'changed'; return this; } /** - * For timespan - * @param {*} timespan - * @returns {ItemTriggerConfig} - */ + * For timespan + * @param {*} timespan + * @returns {ItemTriggerConfig} + */ for (timespan) { return new operations.TimingItemStateOperation(this, timespan); } @@ -475,30 +475,30 @@ class ThingTriggerConfig extends TriggerConf { } /** - * thing changed - * - * @returns {ThingTriggerConfig} - */ + * thing changed + * + * @returns {ThingTriggerConfig} + */ changed () { this.op_type = 'changed'; return this; } /** - * thing updates - * - * @returns {ThingTriggerConfig} - */ + * thing updates + * + * @returns {ThingTriggerConfig} + */ updated () { this.op_type = 'updated'; return this; } /** - * thing status changed from - * - * @returns {ThingTriggerConfig} - */ + * thing status changed from + * + * @returns {ThingTriggerConfig} + */ from (value) { if (this.op_type !== 'changed') { throw Error('.from(..) only available for .changed()'); @@ -508,10 +508,10 @@ class ThingTriggerConfig extends TriggerConf { } /** - * thing status changed to - * - * @returns {ThingTriggerConfig} - */ + * thing status changed to + * + * @returns {ThingTriggerConfig} + */ to (value) { this.to_value = value; return this; @@ -550,55 +550,56 @@ class SystemTriggerConfig extends TriggerConf { } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ rulesLoaded () { return this.startLevel(40); } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ ruleEngineStarted () { return this.startLevel(50); } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ userInterfacesStarted () { return this.startLevel(70); } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ thingsInitialized () { return this.startLevel(80); } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ startupComplete () { return this.startLevel(100); } /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @param {number} level + * @returns {SystemTriggerConfig} + */ startLevel (level) { if (typeof (this.level) !== 'undefined') { throw Error('Level already set'); @@ -608,6 +609,13 @@ class SystemTriggerConfig extends TriggerConf { } } +/** + * DateTime Item based trigger + * + * @memberof TriggerBuilder + * @extends TriggerConf + * @hideconstructor + */ class DateTimeTriggerConfig extends TriggerConf { constructor (itemName, triggerBuilder) { super(triggerBuilder); From c35f260e42e78bb70e9fb2286c6e97a0bc132cfe Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 13 Aug 2023 15:04:16 +0200 Subject: [PATCH 08/10] Regenerate type defs Signed-off-by: Florian Hotze --- types/rules/trigger-builder.d.ts | 290 +++++++++++++++------------ types/rules/trigger-builder.d.ts.map | 2 +- types/triggers.d.ts.map | 2 +- 3 files changed, 161 insertions(+), 133 deletions(-) diff --git a/types/rules/trigger-builder.d.ts b/types/rules/trigger-builder.d.ts index 7df4620ea..61960bde8 100644 --- a/types/rules/trigger-builder.d.ts +++ b/types/rules/trigger-builder.d.ts @@ -28,18 +28,18 @@ export class ChannelTriggerConfig extends TriggerConf { /** @private */ private describe; /** - * trigger a specific event name - * - * @param {string} eventName - * @returns {ChannelTriggerConfig} - */ + * trigger a specific event name + * + * @param {string} eventName + * @returns {ChannelTriggerConfig} + */ to(eventName: string): ChannelTriggerConfig; /** - * trigger a specific event name - * - * @param {string} eventName - * @returns {ChannelTriggerConfig} - */ + * trigger a specific event name + * + * @param {string} eventName + * @returns {ChannelTriggerConfig} + */ triggered(eventName: string): ChannelTriggerConfig; eventName: string; /** @private */ @@ -61,56 +61,56 @@ export class ItemTriggerConfig extends TriggerConf { private describe; of: (value: any) => ItemTriggerConfig; /** - * Item to - * - * @param {*} value this Item should be triggered to - * @returns {ItemTriggerConfig} - */ + * Item to + * + * @param {*} value this Item should be triggered to + * @returns {ItemTriggerConfig} + */ to(value: any): ItemTriggerConfig; to_value: any; /** - * Item from - * @param {*} value this items should be triggered from - * @returns {ItemTriggerConfig} - */ + * Item from + * @param {*} value this items should be triggered from + * @returns {ItemTriggerConfig} + */ from(value: any): ItemTriggerConfig; from_value: any; /** - * Item changed to OFF - * - * @returns {ItemTriggerConfig} - */ + * Item changed to OFF + * + * @returns {ItemTriggerConfig} + */ toOff(): ItemTriggerConfig; /** - * Item changed to ON^ - * - * @returns {ItemTriggerConfig} - */ + * Item changed to ON + * + * @returns {ItemTriggerConfig} + */ toOn(): ItemTriggerConfig; /** - * Item received command - * - * @returns {ItemTriggerConfig} - */ + * Item received command + * + * @returns {ItemTriggerConfig} + */ receivedCommand(): ItemTriggerConfig; op_type: string; /** - * Item received update - * - * @returns {ItemTriggerConfig} - */ + * Item received update + * + * @returns {ItemTriggerConfig} + */ receivedUpdate(): ItemTriggerConfig; /** - * Item changed state - * - * @returns {ItemTriggerConfig} - */ + * Item changed state + * + * @returns {ItemTriggerConfig} + */ changed(): ItemTriggerConfig; /** - * For timespan - * @param {*} timespan - * @returns {ItemTriggerConfig} - */ + * For timespan + * @param {*} timespan + * @returns {ItemTriggerConfig} + */ for(timespan: any): ItemTriggerConfig; /** @private */ private _complete; @@ -135,30 +135,30 @@ export class ThingTriggerConfig extends TriggerConf { /** @private */ private describe; /** - * thing changed - * - * @returns {ThingTriggerConfig} - */ + * thing changed + * + * @returns {ThingTriggerConfig} + */ changed(): ThingTriggerConfig; op_type: string; /** - * thing updates - * - * @returns {ThingTriggerConfig} - */ + * thing updates + * + * @returns {ThingTriggerConfig} + */ updated(): ThingTriggerConfig; /** - * thing status changed from - * - * @returns {ThingTriggerConfig} - */ + * thing status changed from + * + * @returns {ThingTriggerConfig} + */ from(value: any): ThingTriggerConfig; from_value: any; /** - * thing status changed to - * - * @returns {ThingTriggerConfig} - */ + * thing status changed to + * + * @returns {ThingTriggerConfig} + */ to(value: any): ThingTriggerConfig; to_value: any; /** @private */ @@ -177,42 +177,43 @@ export class SystemTriggerConfig extends TriggerConf { /** @private */ private _complete; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ rulesLoaded(): SystemTriggerConfig; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ ruleEngineStarted(): SystemTriggerConfig; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ userInterfacesStarted(): SystemTriggerConfig; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ thingsInitialized(): SystemTriggerConfig; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ + * System trigger + * + * @returns {SystemTriggerConfig} + */ startupComplete(): SystemTriggerConfig; /** - * System trigger - * - * @returns {SystemTriggerConfig} - */ - startLevel(level: any): SystemTriggerConfig; - level: any; + * System trigger + * + * @param {number} level + * @returns {SystemTriggerConfig} + */ + startLevel(level: number): SystemTriggerConfig; + level: number; } /** * Builder for rule Triggers @@ -233,18 +234,18 @@ export class TriggerBuilder { /** @private */ private _if; /** - * Specifies a channel event as a source for the rule to fire. - * - * @param {string} channelName the name of the channel - * @returns {ChannelTriggerConfig} the trigger config - */ + * Specifies a channel event as a source for the rule to fire. + * + * @param {string} channelName the name of the channel + * @returns {ChannelTriggerConfig} the trigger config + */ channel(channelName: string): ChannelTriggerConfig; /** - * Specifies a cron schedule for the rule to fire. - * - * @param {string} cronExpression the cron expression - * @returns {CronTriggerConfig} the trigger config - */ + * Specifies a cron schedule for the rule to fire. + * + * @param {string} cronExpression the cron expression + * @returns {CronTriggerConfig} the trigger config + */ cron(cronExpression: string): CronTriggerConfig; /** * Specifies a time schedule for the rule to fire. @@ -254,40 +255,40 @@ export class TriggerBuilder { */ timeOfDay(time: string): TimeOfDayTriggerConfig; /** - * Specifies an Item as the source of changes to trigger a rule. - * - * @param {string} itemName the name of the Item - * @returns {ItemTriggerConfig} the trigger config - */ + * Specifies an Item as the source of changes to trigger a rule. + * + * @param {string} itemName the name of the Item + * @returns {ItemTriggerConfig} the trigger config + */ item(itemName: string): ItemTriggerConfig; /** - * Specifies a group member as the source of changes to trigger a rule. - * - * @param {string} groupName the name of the group - * @returns {ItemTriggerConfig} the trigger config - */ + * Specifies a group member as the source of changes to trigger a rule. + * + * @param {string} groupName the name of the group + * @returns {ItemTriggerConfig} the trigger config + */ memberOf(groupName: string): ItemTriggerConfig; /** - * Specifies a Thing status event as a source for the rule to fire. - * - * @param {string} thingUID the UID of the Thing - * @returns {ThingTriggerConfig} the trigger config - */ + * Specifies a Thing status event as a source for the rule to fire. + * + * @param {string} thingUID the UID of the Thing + * @returns {ThingTriggerConfig} the trigger config + */ thing(thingUID: string): ThingTriggerConfig; /** - * Specifies a system event as a source for the rule to fire. - * - * @memberof TriggerBuilder - * @returns {SystemTriggerConfig} the trigger config - */ + * Specifies a system event as a source for the rule to fire. + * + * @memberof TriggerBuilder + * @returns {SystemTriggerConfig} the trigger config + */ system(): SystemTriggerConfig; /** * Specifies a DateTime Item whose (optional) date and time schedule the rule to fire. * * @param {string} itemName the name of the Item to monitor for change - * @returns {*} + * @returns {DateTimeTriggerConfig} the trigger config */ - dateTime(itemName: string): any; + dateTime(itemName: string): DateTimeTriggerConfig; } /** * {RuleBuilder} RuleBuilder triggers @@ -298,24 +299,24 @@ declare class TriggerConf { /** @private */ private triggerBuilder; /** - * Add an additional Trigger - * - * @returns {TriggerBuilder} - */ + * Add an additional Trigger + * + * @returns {TriggerBuilder} + */ or(): TriggerBuilder; /** - * Move to the rule operations - * - * @param {*} fn the optional function to execute - * @returns {operations.OperationBuilder} - */ + * Move to the rule operations + * + * @param {*} fn the optional function to execute + * @returns {operations.OperationBuilder} + */ then(fn: any): operations.OperationBuilder; /** - * Move to the rule condition - * - * @param {*} fn the optional function to execute - * @returns {conditions.ConditionBuilder} - */ + * Move to the rule condition + * + * @param {*} fn the optional function to execute + * @returns {conditions.ConditionBuilder} + */ if(fn: any): conditions.ConditionBuilder; } /** @@ -336,6 +337,33 @@ declare class TimeOfDayTriggerConfig extends TriggerConf { /** @private */ private describe; } +/** + * DateTime Item based trigger + * + * @memberof TriggerBuilder + * @extends TriggerConf + * @hideconstructor + */ +declare class DateTimeTriggerConfig extends TriggerConf { + constructor(itemName: any, triggerBuilder: any); + /** @private */ + private _itemName; + /** @private */ + private _timeOnly; + /** @private */ + private _complete; + /** @private */ + private _toOHTriggers; + /** @private */ + private describe; + /** + * Specifies whether only the time of the Item should be compared or the date and time. + * + * @param {boolean} [timeOnly=true] + * @returns {DateTimeTriggerConfig} + */ + timeOnly(timeOnly?: boolean): DateTimeTriggerConfig; +} import operations = require("./operation-builder"); import conditions = require("./condition-builder"); export {}; diff --git a/types/rules/trigger-builder.d.ts.map b/types/rules/trigger-builder.d.ts.map index bbd524ca2..719274dc2 100644 --- a/types/rules/trigger-builder.d.ts.map +++ b/types/rules/trigger-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AAgNA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;SAKK;IACL,cAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAKlC;IAFC,kBAAgC;IAIlC,eAAe;IACf,kBAEC;CACF;AA4CD;;;;;;GAMG;AACH;IACE,gEAYC;IAVC,aAAyC;IAKzC,eAAe;IACf,kBAA2B;IA4F7B,eAAe;IACf,iBA6BC;IAvHC,oBAOa,iBAAiB,CAPb;IAGnB;;;;;SAKK;IACL,gBAFe,iBAAiB,CAK/B;I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,YAGC;IAED,eAAe;IACf,cAGC;IAED,eAAe;IACf,YAGC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,oBAAoB,CAIlC;IAED;;;;;SAKK;IACL,qBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,sBAAsB,CAIlC;IAED;;;;;SAKK;IACL,eAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,oBAHa,MAAM,GACJ,iBAAiB,CAI/B;IAED;;;;;SAKK;IACL,gBAHa,MAAM,GACJ,kBAAkB,CAIhC;IAED;;;;;SAKK;IACL,UAFe,mBAAmB,CAIjC;IAED;;;;;OAKG;IACH,mBAHW,MAAM,OAKhB;CACF;AAED;;;GAGG;AACH;IACE,iCAGC;IAFC,eAAe;IACf,uBAAoC;IAGtC;;;;SAIK;IACL,MAFe,cAAc,CAI5B;IAED;;;;;SAKK;IACL,eAFe,WAAW,gBAAgB,CAIzC;IAED;;;;;SAKK;IACL,aAFe,WAAW,gBAAgB,CAIzC;CACF;AAuED;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAoE;IACpE,eAAe;IACf,iBAA4G;CAE/G"} \ No newline at end of file +{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../rules/trigger-builder.js"],"names":[],"mappings":"AAgNA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,oBAAoB,CAIhC;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GACJ,oBAAoB,C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;IAG1J;;;;;OAKG;IACH,oBAHW,OAAO,GACL,qBAAqB,CAKjC;CACF"} \ No newline at end of file diff --git a/types/triggers.d.ts.map b/types/triggers.d.ts.map index 513de70e2..14bc13fd4 100644 --- a/types/triggers.d.ts.map +++ b/types/triggers.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../triggers.js"],"names":[],"mappings":"AAwCA;;;;;;;;;;;GAWG;AACH,6CALW,MAAM,SACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;;;;GAcG;AACH,mDALW,MAAK,MAAM,aACX,MAAM,aACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;GAWG;AACH,mDAJW,MAAK,MAAM,UACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,+CAJW,MAAK,MAAM,YACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,qDALW,MAAK,MAAM,aACX,MAAM,aACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;GAUG;AACH,qDAJW,MAAK,MAAM,UACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;GAUG;AACH,iDAJW,MAAK,MAAM,YACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;GAUG;AACH,mDAJW,MAAM,WACN,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,mDALW,MAAM,WACN,MAAM,mBACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;;;GAaG;AACH,oDAHW,MAAM,GAAC,MAAM,gBACb,MAAM,eAKb;AAEJ;;;;;;;;;GASG;AACH,+CAHW,MAAM,gBACN,MAAM,eAKb;AAEJ;;;;;;;;;GASG;AACH,uCAHW,MAAM,gBACN,MAAM,eAKb;AAEJ;;;;;;;;;;GAUG;AACH,4CAJW,MAAK,MAAM,aACX,OAAO,gBACP,MAAM,eAMb;AAEJ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,0CAPW,MAAM,YACN,MAAM,iBACN,MAAM,iBACN,MAAM,kBACN,MAAM,gBACN,MAAM,eASb;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,sCAhBW,MAAM,gBACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,mBACN,MAAM,aACN,MAAM,gBACN,MAAM,qBACN,MAAM,qBACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,uBACN,MAAM,gBACN,MAAM,eAkBb"} \ No newline at end of file +{"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../triggers.js"],"names":[],"mappings":"AA4CA;;;;;;;;;;;GAWG;AACH,6CALW,MAAM,SACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;;;;GAcG;AACH,mDALW,MAAK,MAAM,aACX,MAAM,aACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;GAWG;AACH,mDAJW,MAAK,MAAM,UACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,+CAJW,MAAK,MAAM,YACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,qDALW,MAAK,MAAM,aACX,MAAM,aACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;GAUG;AACH,qDAJW,MAAK,MAAM,UACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;GAUG;AACH,iDAJW,MAAK,MAAM,YACX,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;GAUG;AACH,mDAJW,MAAM,WACN,MAAM,gBACN,MAAM,eAMb;AAEJ;;;;;;;;;;;GAWG;AACH,mDALW,MAAM,WACN,MAAM,mBACN,MAAM,gBACN,MAAM,eAOb;AAEJ;;;;;;;;;;;;;GAaG;AACH,oDAHW,MAAM,GAAC,MAAM,gBACb,MAAM,eAKb;AAEJ;;;;;;;;;GASG;AACH,+CAHW,MAAM,gBACN,MAAM,eAKb;AAEJ;;;;;;;;;GASG;AACH,uCAHW,MAAM,gBACN,MAAM,eAKb;AAEJ;;;;;;;;;;GAUG;AACH,4CAJW,MAAK,MAAM,aACX,OAAO,gBACP,MAAM,eAMb;AAEJ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,0CAPW,MAAM,YACN,MAAM,iBACN,MAAM,iBACN,MAAM,kBACN,MAAM,gBACN,MAAM,eASb;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,sCAhBW,MAAM,gBACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,mBACN,MAAM,aACN,MAAM,gBACN,MAAM,qBACN,MAAM,qBACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,uBACN,MAAM,gBACN,MAAM,eAkBb"} \ No newline at end of file From 0ead76ed3a73b19014f9441e4e47533c1ea6dc87 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 13 Aug 2023 15:20:51 +0200 Subject: [PATCH 09/10] Update README Signed-off-by: Florian Hotze --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 651a24517..fe5e78c9c 100644 --- a/README.md +++ b/README.md @@ -1168,7 +1168,8 @@ See [Examples](#rule-builder-examples) for further patterns. - `.channel(channelName)` Specifies a channel event as a source for the rule to fire. - `.triggered(event)` Trigger on a specific event name - `.cron(cronExpression)` Specifies a cron schedule for the rule to fire. - - `.item(itemName)` Specifies an item as the source of changes to trigger a rule. + - `.timeOfDay(time)` Specifies a time of day in `HH:mm` for the rule to fire. + - `.item(itemName)` Specifies an Item as the source of changes to trigger a rule. - `.for(duration)` - `.from(state)` - `.to(state)` @@ -1176,7 +1177,7 @@ See [Examples](#rule-builder-examples) for further patterns. - `.toOn()` - `.receivedCommand()` - `.receivedUpdate()` - - `.memberOf(groupName)` + - `.memberOf(groupName)` Specifies a group Item as the source of changes to trigger the rule. - `.for(duration)` - `.from(state)` - `.to(state)` @@ -1184,18 +1185,20 @@ See [Examples](#rule-builder-examples) for further patterns. - `.toOn()` - `.receivedCommand()` - `.receivedUpdate()` - - `.system()` + - `.system()` Specifies a system event as a source for the rule to fire. - `.ruleEngineStarted()` - `.rulesLoaded()` - `.startupComplete()` - `.thingsInitialized()` - `.userInterfacesStarted()` - `.startLevel(level)` - - `.thing(thingName)` + - `.thing(thingName)` Specifies a Thing event as a source for the rule to fire. - `changed()` - `updated()` - `from(state)` - `to(state)` + - `.dateTime(itemName)` Specifies a DateTime Item whose (optional) date and time schedule the rule to fire. + - `.timeOnly()` Only the time of the Item should be compared, the date should be ignored. Additionally, all the above triggers have the following functions: @@ -1230,31 +1233,31 @@ Additionally, all the above triggers have the following functions: ```javascript // Basic rule, when the BedroomLight1 is changed, run a custom function rules.when().item('BedroomLight1').changed().then(e => { - console.log("BedroomLight1 state", e.newState) + console.log("BedroomLight1 state", e.newState) }).build(); -// Turn on the kitchen light at SUNSET -rules.when().timeOfDay("SUNSET").then().sendOn().toItem("KitchenLight").build("Sunset Rule","turn on the kitchen light at SUNSET"); +// Turn on the kitchen light at SUNSET (using the Astro binding) +rules.when().channel('astro:sun:home:set#event').triggered('START').then().sendOn().toItem('KitchenLight').build('Sunset Rule', 'Turn on the kitchen light at SUNSET'); // Turn off the kitchen light at 9PM and tag rule -rules.when().cron("0 0 21 * * ?").then().sendOff().toItem("KitchenLight").build("9PM Rule", "turn off the kitchen light at 9PM", ["Tag1", "Tag2"]); +rules.when().cron('0 0 21 * * ?').then().sendOff().toItem('KitchenLight').build('9PM Rule', 'Turn off the kitchen light at 9PM', ['Tag1', 'Tag2']); // Set the colour of the hall light to pink at 9PM, tag rule and use a custom ID -rules.when().cron("0 0 21 * * ?").then().send("300,100,100").toItem("HallLight").build("Pink Rule", "set the colour of the hall light to pink at 9PM", ["Tag1", "Tag2"], "MyCustomID"); +rules.when().cron('0 0 21 * * ?').then().send('300,100,100').toItem('HallLight').build('Pink Rule', 'Set the colour of the hall light to pink at 9PM', ['Tag1', 'Tag2'], 'MyCustomID'); // When the switch S1 status changes to ON, then turn on the HallLight -rules.when().item('S1').changed().toOn().then(sendOn().toItem('HallLight')).build("S1 Rule"); +rules.when().item('S1').changed().toOn().then(sendOn().toItem('HallLight')).build('S1 Rule'); // When the HallLight colour changes pink, if the function fn returns true, then toggle the state of the OutsideLight -rules.when().item('HallLight').changed().to("300,100,100").if(fn).then().sendToggle().toItem('OutsideLight').build(); +rules.when().item('HallLight').changed().to('300,100,100').if(fn).then().sendToggle().toItem('OutsideLight').build(); // And some rules which can be toggled by the items created in the 'gRules' Group: // When the HallLight receives a command, send the same command to the KitchenLight -rules.when().item('HallLight').receivedCommand().then().sendIt().toItem('KitchenLight').build("Hall Light", ""); +rules.when(true).item('HallLight').receivedCommand().then().sendIt().toItem('KitchenLight').build('Hall Light to Kitchen Light'); // When the HallLight is updated to ON, make sure that BedroomLight1 is set to the same state as the BedroomLight2 -rules.when().item('HallLight').receivedUpdate().then().copyState().fromItem('BedroomLight1').toItem('BedroomLight2').build(); +rules.when(true).item('HallLight').receivedUpdate().then().copyState().fromItem('BedroomLight1').toItem('BedroomLight2').build(); ``` ### Event Object From 10fa2445927aaf27042f5f1324c7fd5e802bf02f Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 13 Aug 2023 15:44:18 +0200 Subject: [PATCH 10/10] README: Add dateTime and timeOfDay Rule Builder examples Signed-off-by: Florian Hotze --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe5e78c9c..57f4d4137 100644 --- a/README.md +++ b/README.md @@ -1240,17 +1240,20 @@ rules.when().item('BedroomLight1').changed().then(e => { rules.when().channel('astro:sun:home:set#event').triggered('START').then().sendOn().toItem('KitchenLight').build('Sunset Rule', 'Turn on the kitchen light at SUNSET'); // Turn off the kitchen light at 9PM and tag rule -rules.when().cron('0 0 21 * * ?').then().sendOff().toItem('KitchenLight').build('9PM Rule', 'Turn off the kitchen light at 9PM', ['Tag1', 'Tag2']); +rules.when().timeOfDay('21:00').then().sendOff().toItem('KitchenLight').build('9PM Rule', 'Turn off the kitchen light at 9PM', ['Tag1', 'Tag2']); // Set the colour of the hall light to pink at 9PM, tag rule and use a custom ID rules.when().cron('0 0 21 * * ?').then().send('300,100,100').toItem('HallLight').build('Pink Rule', 'Set the colour of the hall light to pink at 9PM', ['Tag1', 'Tag2'], 'MyCustomID'); // When the switch S1 status changes to ON, then turn on the HallLight -rules.when().item('S1').changed().toOn().then(sendOn().toItem('HallLight')).build('S1 Rule'); +rules.when().item('S1').changed().toOn().then().sendOn().toItem('HallLight').build('S1 Rule'); // When the HallLight colour changes pink, if the function fn returns true, then toggle the state of the OutsideLight rules.when().item('HallLight').changed().to('300,100,100').if(fn).then().sendToggle().toItem('OutsideLight').build(); +// Turn on the outdoor lights based on a DateTime Item's time portion +rules.when().dateTime('OutdoorLights_OffTime').timeOnly().then().sendOff().toItem('OutdoorLights').build('Outdoor Lights off'); + // And some rules which can be toggled by the items created in the 'gRules' Group: // When the HallLight receives a command, send the same command to the KitchenLight