From ede2a5afa5277f1394dc59cb79d6dfc3356a3848 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 17 Sep 2023 17:50:08 +0200 Subject: [PATCH] [rules] Rule Builder: Add fromOn & fromOff to Item trigger config (#297) Signed-off-by: Florian Hotze --- rules/trigger-builder.js | 18 ++++++++++++++++++ types/rules/trigger-builder.d.ts | 12 ++++++++++++ types/rules/trigger-builder.d.ts.map | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/rules/trigger-builder.js b/rules/trigger-builder.js index beffeb70b..cfc9775eb 100644 --- a/rules/trigger-builder.js +++ b/rules/trigger-builder.js @@ -312,6 +312,24 @@ class ItemTriggerConfig extends TriggerConf { return this.to('ON'); } + /** + * Item changed from OFF + * + * @returns {ItemTriggerConfig} + */ + fromOff () { + return this.from('OFF'); + } + + /** + * Item changed from ON + * + * @returns {ItemTriggerConfig} + */ + fromOn () { + return this.from('ON'); + } + /** * Item received command * diff --git a/types/rules/trigger-builder.d.ts b/types/rules/trigger-builder.d.ts index 61960bde8..2ebf13c95 100644 --- a/types/rules/trigger-builder.d.ts +++ b/types/rules/trigger-builder.d.ts @@ -87,6 +87,18 @@ export class ItemTriggerConfig extends TriggerConf { * @returns {ItemTriggerConfig} */ toOn(): ItemTriggerConfig; + /** + * Item changed from OFF + * + * @returns {ItemTriggerConfig} + */ + fromOff(): ItemTriggerConfig; + /** + * Item changed from ON + * + * @returns {ItemTriggerConfig} + */ + fromOn(): ItemTriggerConfig; /** * Item received command * diff --git a/types/rules/trigger-builder.d.ts.map b/types/rules/trigger-builder.d.ts.map index 719274dc2..c4b121613 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,kBAA2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AAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAoE;IACpE,eAAe;IACf,iBAA4G;CAE/G;AA2WD;;;;;;GAMG;AACH;IACE,gDAYC;IAVC,eAAe;IACf,kBAAyB;IACzB,eAAe;IACf,kBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAqF;IACrF,eAAe;IACf,iBAAwJ;IAG1J;;;;;OAKG;IACH,oBAHW,OAAO,GACL,qBAAqB,CAKjC;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;;;;;OAKG;IACH,cAHW,MAAM,GACJ,oBAAoB,CAIhC;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GACJ,oBAAoB,CAKhC;IAFC,kBAAgC;IAIlC,eAAe;IACf,kBAEC;CACF;AA4CD;;;;;;GAMG;AACH;IACE,gEAYC;IAVC,aAAyC;IAKzC,eAAe;IACf,kBAA2B;IA8G7B,eAAe;IACf,iBA6BC;IAzIC,oBAOW,iBAAiB,CAPX;IAGnB;;;;;OAKG;IACH,gBAFa,iBAAiB,CAK7B;IAFC,cAAqB;IAIvB;;;;OAIG;IACH,kBAFa,iBAAiB,CAQ7B;IAFC,gBAAuB;IAIzB;;;;OAIG;IACH,SAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,QAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,WAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,UAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,mBAFa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