iobroker.smartcontrol 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -0
- package/README.md +41 -266
- package/admin/custom/assets/Components-CDPYnOs-.js +77 -0
- package/admin/custom/assets/Components-DpQjIfuo.js +1 -0
- package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__SmartcontrolSet__mf_owner__1-C9SdP7_s.js +1 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SmartcontrolSet__mf_owner__108197177487852__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-Ca-6Y14s.js +1525 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SmartcontrolSet__mf_owner__108197177487852__loadShare__shared-4MdeZwge.js +2 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SmartcontrolSet__mf_owner__108197177487852__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-QT6he7QZ.js +122 -0
- package/admin/custom/assets/_virtual_mf___mfe_internal__SmartcontrolSet__mf_owner__108197177487852__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__-BWTOCVCn.js +1 -0
- package/admin/custom/assets/dist-Cnxr-ruU.js +1 -0
- package/admin/custom/assets/helpers-CNHzo155.js +1 -0
- package/admin/custom/assets/hostInit-BVoHSU7s.js +1 -0
- package/admin/custom/assets/iconLibraryData-B5fiyl1C.js +1 -0
- package/admin/custom/assets/index-CwC_q7vn.js +1 -0
- package/admin/custom/assets/lib-CgOpGT17.js +3 -0
- package/admin/custom/assets/mf-entry-bootstrap-0-6167c687.js +54 -0
- package/admin/custom/assets/pendingShares-CEz9fejL.js +2 -0
- package/admin/custom/assets/prod-XWAlCKxB.js +492 -0
- package/admin/custom/assets/rolldown-runtime-9C0vUP4u.js +1 -0
- package/admin/custom/assets/utils-DmVoYT7i.js +4 -0
- package/admin/custom/assets/vite-preload-helper-nldAWQd6.js +1 -0
- package/admin/custom/customComponents.js +12 -0
- package/admin/custom/i18n/de.json +59 -0
- package/admin/custom/i18n/en.json +59 -0
- package/admin/custom/mf-manifest.json +1 -0
- package/admin/doc-md/readme.txt +2 -6
- package/admin/doc-md/start_de.md +34 -89
- package/admin/doc-md/start_en.md +33 -90
- package/admin/doc-md/table-conditions_de.md +7 -9
- package/admin/doc-md/table-conditions_en.md +7 -9
- package/admin/doc-md/table-execution_de.md +11 -10
- package/admin/doc-md/table-execution_en.md +12 -11
- package/admin/doc-md/table-options_de.md +58 -0
- package/admin/doc-md/table-options_en.md +58 -0
- package/admin/doc-md/table-target-devices_de.md +20 -16
- package/admin/doc-md/table-target-devices_en.md +18 -16
- package/admin/doc-md/table-target-enums_de.md +13 -13
- package/admin/doc-md/table-target-enums_en.md +12 -14
- package/admin/doc-md/table-target-url_de.md +14 -25
- package/admin/doc-md/table-target-url_en.md +14 -23
- package/admin/doc-md/table-trigger-devices_de.md +10 -11
- package/admin/doc-md/table-trigger-devices_en.md +10 -10
- package/admin/doc-md/table-trigger-motion_de.md +41 -24
- package/admin/doc-md/table-trigger-motion_en.md +35 -19
- package/admin/doc-md/table-trigger-times_de.md +11 -12
- package/admin/doc-md/table-trigger-times_en.md +11 -11
- package/admin/doc-md/table-zones_de.md +19 -14
- package/admin/doc-md/table-zones_en.md +19 -14
- package/admin/doc-md/table-zones_select-targets_de.md +7 -15
- package/admin/doc-md/table-zones_select-targets_en.md +7 -15
- package/admin/i18n/{de/translations.json → de.json} +2 -1
- package/admin/i18n/{en/translations.json → en.json} +3 -1
- package/admin/i18n/{es/translations.json → es.json} +2 -1
- package/admin/i18n/{fr/translations.json → fr.json} +2 -1
- package/admin/i18n/{it/translations.json → it.json} +2 -1
- package/admin/i18n/{nl/translations.json → nl.json} +2 -1
- package/admin/i18n/{pl/translations.json → pl.json} +2 -1
- package/admin/i18n/{pt/translations.json → pt.json} +2 -1
- package/admin/i18n/{ru/translations.json → ru.json} +2 -1
- package/admin/i18n/uk.json +110 -0
- package/admin/i18n/{zh-cn/translations.json → zh-cn.json} +2 -1
- package/admin/img/option-screenshots/tab-conditions.png +0 -0
- package/admin/img/option-screenshots/tab-further-options.png +0 -0
- package/admin/img/option-screenshots/tab-start.png +0 -0
- package/admin/img/option-screenshots/tab-target-devices.png +0 -0
- package/admin/img/option-screenshots/tab-triggers-motion.png +0 -0
- package/admin/img/option-screenshots/tab-triggers-other.png +0 -0
- package/admin/img/option-screenshots/tab-triggers-time.png +0 -0
- package/admin/img/option-screenshots/tab-zones-execution.png +0 -0
- package/admin/img/option-screenshots/tab-zones.png +0 -0
- package/admin/jsonConfig.json5 +524 -0
- package/io-package.json +46 -31
- package/lib/boolean-value.js +30 -0
- package/lib/constants.js +299 -65
- package/lib/cron-schedule.js +59 -0
- package/lib/helper.js +416 -375
- package/lib/midnight-reschedule.js +31 -0
- package/lib/motion-zone-timer.js +55 -0
- package/lib/num-comparator.js +70 -0
- package/lib/tools.js +12 -6
- package/lib/trigger-class.js +661 -311
- package/lib/trigger-match.js +76 -0
- package/main.js +1040 -652
- package/package.json +30 -38
- package/admin/admin.d.ts +0 -4
- package/admin/doc-md/img/start_dropdown-ani.gif +0 -0
- package/admin/doc-md/img/start_open-dialog.png +0 -0
- package/admin/doc-md/img/start_show-explanation.gif +0 -0
- package/admin/doc-md/img/table-zones_select-target-devices-overwrite.gif +0 -0
- package/admin/fancytree/skin-lion/icons-rtl.gif +0 -0
- package/admin/fancytree/skin-lion/icons.gif +0 -0
- package/admin/fancytree/skin-lion/loading.gif +0 -0
- package/admin/fancytree/skin-lion/ui.fancytree.min.css +0 -6
- package/admin/fancytree/skin-lion/vline-rtl.gif +0 -0
- package/admin/fancytree/skin-lion/vline.gif +0 -0
- package/admin/img/info-big.png +0 -0
- package/admin/img/info-big.png_README.txt +0 -6
- package/admin/img/sc_always.png +0 -0
- package/admin/img/select-target-devices-overwrite.gif +0 -0
- package/admin/img/smartControl_options1.gif +0 -0
- package/admin/img/smartControl_options_dropdown.gif +0 -0
- package/admin/img/smartControl_options_dropdown_2.gif +0 -0
- package/admin/index_m.html +0 -812
- package/admin/index_m.js +0 -1455
- package/admin/style.css +0 -187
- package/admin/tsconfig.json +0 -49
- package/admin/words.js +0 -113
- package/admin/zero-md/readme.txt +0 -1
- package/admin/zero-md/webcomponents-loader.min.js +0 -9
- package/admin/zero-md/zero-md.min.js.js +0 -9
package/lib/trigger-class.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const { getOtherMotionTriggerNames, zoneMotionOffTimerAction } = require('./motion-zone-timer');
|
|
4
|
+
const { isTriggerStateMatching, isRecheckAfterDelayEnabled, shouldRecheckTriggerState } = require('./trigger-match');
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* @
|
|
6
|
-
* @desc For handling of triggers and their associated target devices.
|
|
7
|
+
* @description For handling of triggers and their associated target devices.
|
|
7
8
|
* Every instance of this class is a specific trigger (motion sensor/'other device'/time trigger)
|
|
8
9
|
* @author Mic-M <https://github.com/Mic-M/ioBroker.smartcontrol>
|
|
9
10
|
* @license MIT
|
|
10
|
-
*
|
|
11
|
+
*
|
|
11
12
|
* Initial Properties:
|
|
12
13
|
* ---Generic Properties---
|
|
13
14
|
* {string} triggerName Name of Trigger
|
|
@@ -22,7 +23,6 @@
|
|
|
22
23
|
* {number} motionDuration Duration (timer) in seconds for motion sensor
|
|
23
24
|
* {string} motionBriStatePath State Path of brightness state
|
|
24
25
|
* {number} motionBriThreshold Threshold of brightness
|
|
25
|
-
* {object} motionTimer Timer object for motion to switch targets off
|
|
26
26
|
* {boolean} mimicMotion For trigger devices linked/associated with a motion sensor (tableTriggerMotion -> motionLinkedTrigger)
|
|
27
27
|
* {string} mimicMotionTriggerName Trigger name of device linked to motion sensor
|
|
28
28
|
* {boolean} mimicMotionIgnoreMotionOn Ignore motion if motion sensor is set to true
|
|
@@ -31,18 +31,16 @@
|
|
|
31
31
|
* {string} triggerTime If time trigger: time like '42 * * * *' or 'sunset+30'
|
|
32
32
|
* {array} triggerTmAdditionCond Array of additional condition names for "Must be fulfilled"
|
|
33
33
|
* {boolean} triggerTmAddCondAll if true: all conditions must be met, if false: at least one condition must be met
|
|
34
|
-
* {string} triggerTmNever Array of additional condition names for "Never" which shall not be
|
|
34
|
+
* {string} triggerTmNever Array of additional condition names for "Never" which shall not be
|
|
35
35
|
* {boolean} triggerTmNeverAll if true: all conditions must be met, if false: at least one condition must be met
|
|
36
36
|
*
|
|
37
37
|
* Properties set by this._asyncUpdateCurrentActiveZones()
|
|
38
38
|
* {array} zoneNames All zone names that were triggered and meet all conditions
|
|
39
39
|
* {object} zoneTargetNames All target device names per zone, like {Hallway:['Hallway Light'], Bath:['Light', 'Radio Bath']}
|
|
40
|
-
* NOTE: Motion Trigger - If target was already turned on previously by a non-motion trigger:
|
|
40
|
+
* NOTE: Motion Trigger - If target was already turned on previously by a non-motion trigger:
|
|
41
41
|
* We will remove that device to not schedule timer, if motionNotIfManual
|
|
42
|
-
*
|
|
43
42
|
*/
|
|
44
43
|
class Trigger {
|
|
45
|
-
|
|
46
44
|
/**
|
|
47
45
|
* Constructor
|
|
48
46
|
*
|
|
@@ -60,16 +58,14 @@ class Trigger {
|
|
|
60
58
|
* Set properties (retrieving from adapter configuration)
|
|
61
59
|
*/
|
|
62
60
|
_init() {
|
|
63
|
-
|
|
64
61
|
try {
|
|
65
|
-
|
|
66
62
|
this.triggerStatePath = undefined; // set below accordingly if state
|
|
67
|
-
this.triggerStateVal = undefined;
|
|
68
|
-
this.triggerIsMotion = false;
|
|
69
|
-
this.triggerIsToggle = false;
|
|
70
|
-
this.targetOff = false;
|
|
71
|
-
this.mimicMotion = false;
|
|
72
|
-
this.mimicMotionTriggerName = undefined;
|
|
63
|
+
this.triggerStateVal = undefined; // set below accordingly if state
|
|
64
|
+
this.triggerIsMotion = false; // set to true below, if motion
|
|
65
|
+
this.triggerIsToggle = false; // set to true below, if tableTriggerDevices.isToggle=true
|
|
66
|
+
this.targetOff = false; // set to true below, if activated in other devices or time trigger table
|
|
67
|
+
this.mimicMotion = false; // set accordingly in main.js
|
|
68
|
+
this.mimicMotionTriggerName = undefined; // set accordingly in main.js
|
|
73
69
|
this.mimicMotionIgnoreMotionOn = false; // set to true below, if tableTriggerMotion.ignoreMotionOn is true
|
|
74
70
|
|
|
75
71
|
/**
|
|
@@ -84,11 +80,12 @@ class Trigger {
|
|
|
84
80
|
break;
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
|
-
if (result.index > -1)
|
|
83
|
+
if (result.index > -1) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
switch (result.tableId) {
|
|
91
|
-
|
|
92
89
|
case 'tableTriggerDevices':
|
|
93
90
|
this.triggerTableId = result.tableId;
|
|
94
91
|
this.triggerStatePath = result.row.stateId;
|
|
@@ -100,7 +97,6 @@ class Trigger {
|
|
|
100
97
|
case 'tableTriggerMotion':
|
|
101
98
|
this.triggerTableId = result.tableId;
|
|
102
99
|
this.triggerIsMotion = true;
|
|
103
|
-
this.motionTimer = null;
|
|
104
100
|
this.triggerStatePath = result.row.stateId;
|
|
105
101
|
this.triggerStateVal = true; // is always true for motion sensors to indicate if on
|
|
106
102
|
this.motionNotIfManual = result.row.notIfManual;
|
|
@@ -111,7 +107,12 @@ class Trigger {
|
|
|
111
107
|
} else {
|
|
112
108
|
this.motionDuration = 0;
|
|
113
109
|
}
|
|
114
|
-
if (
|
|
110
|
+
if (
|
|
111
|
+
result.row.briThreshold &&
|
|
112
|
+
parseInt(result.row.briThreshold) > 0 &&
|
|
113
|
+
result.row.briStateId &&
|
|
114
|
+
result.row.briStateId.length > 5
|
|
115
|
+
) {
|
|
115
116
|
this.motionBriStatePath = result.row.briStateId;
|
|
116
117
|
this.motionBriThreshold = parseInt(result.row.briThreshold);
|
|
117
118
|
} else {
|
|
@@ -132,110 +133,286 @@ class Trigger {
|
|
|
132
133
|
break;
|
|
133
134
|
|
|
134
135
|
default:
|
|
135
|
-
throw
|
|
136
|
+
throw `No active trigger '${this.triggerName}' found in any trigger table.`;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
138
|
} catch (error) {
|
|
139
139
|
this.adapter.x.helper.dumpError('_init()]', error);
|
|
140
140
|
}
|
|
141
|
-
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
/**
|
|
145
144
|
* Set all target devices for all zones
|
|
146
145
|
* Note: No need to remove duplicates, this is being taken care of by asyncVerifyConfig() function.
|
|
146
|
+
*
|
|
147
147
|
* @fires _asyncSetTargetDevices_processZone()
|
|
148
148
|
*/
|
|
149
149
|
async asyncSetTargetDevices() {
|
|
150
|
-
|
|
151
150
|
try {
|
|
152
|
-
|
|
153
151
|
await this._asyncUpdateCurrentActiveZones(); // update current active zone properties
|
|
154
|
-
if (!this.zoneNames || !this.zoneTargetNames)
|
|
152
|
+
if (!this.zoneNames || !this.zoneTargetNames) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
155
|
|
|
156
156
|
// Timer zoneOn (delay for switching zone on)
|
|
157
157
|
for (const lpZoneName of this.zoneNames) {
|
|
158
|
-
clearTimeout(this.adapter.x.timersZoneOn[lpZoneName]);
|
|
158
|
+
this.adapter.clearTimeout(this.adapter.x.timersZoneOn[lpZoneName]);
|
|
159
159
|
this.adapter.x.timersZoneOn[lpZoneName] = null;
|
|
160
|
-
const zoneOnSecs = parseInt(
|
|
160
|
+
const zoneOnSecs = parseInt(
|
|
161
|
+
this.adapter.getOptionTableValue('tableZones', 'name', lpZoneName, 'onAfter'),
|
|
162
|
+
);
|
|
161
163
|
if (!zoneOnSecs || zoneOnSecs < 1) {
|
|
162
|
-
this.adapter.log.debug(
|
|
164
|
+
this.adapter.log.debug(
|
|
165
|
+
`Trigger [${this.triggerName}] Zone '${lpZoneName}' No 'On after x sec' time is set, so we do not set such delay (timer).`,
|
|
166
|
+
);
|
|
163
167
|
this._asyncSetTargetDevices_processZone(lpZoneName);
|
|
164
168
|
} else {
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
// Nach der Wartezeit: nur prüfen, wenn die Zone das opt-in gesetzt hat.
|
|
170
|
+
this.adapter.x.timersZoneOn[lpZoneName] = this.adapter.setTimeout(() => {
|
|
171
|
+
this._asyncActivateZoneAfterOnDelay(lpZoneName);
|
|
167
172
|
}, zoneOnSecs * 1000);
|
|
168
173
|
}
|
|
169
174
|
}
|
|
170
|
-
|
|
171
175
|
} catch (error) {
|
|
172
176
|
this.adapter.x.helper.dumpError('[asyncSetTargetDevices]', error);
|
|
173
177
|
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Zone-Einschaltverzögerung ist abgelaufen.
|
|
182
|
+
*
|
|
183
|
+
* Warum (#4 / Review #370): Standard wie früher immer schalten. Nur wenn
|
|
184
|
+
* die Zone „Recheck after delay“ an hat, nochmal Auslöser/Bedingungen prüfen.
|
|
185
|
+
*
|
|
186
|
+
* @param {string} zoneName
|
|
187
|
+
*/
|
|
188
|
+
async _asyncActivateZoneAfterOnDelay(zoneName) {
|
|
189
|
+
try {
|
|
190
|
+
this.adapter.x.timersZoneOn[zoneName] = null;
|
|
191
|
+
const recheckOn = isRecheckAfterDelayEnabled(
|
|
192
|
+
this.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'recheckAfterDelay'),
|
|
193
|
+
);
|
|
194
|
+
if (recheckOn) {
|
|
195
|
+
const stillOk = await this._asyncRecheckAfterOnDelay(zoneName);
|
|
196
|
+
if (!stillOk) {
|
|
197
|
+
this.adapter.log.debug(
|
|
198
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': delay elapsed, but trigger or conditions no longer match – skip switching on.`,
|
|
199
|
+
);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
await this._asyncSetTargetDevices_processZone(zoneName);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
this.adapter.x.helper.dumpError('[_asyncActivateZoneAfterOnDelay]', error);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Nochmal: Auslöser-Datenpunkt + Zonen-Ausführung (und bei Zeit: Zusatzbedingungen).
|
|
211
|
+
*
|
|
212
|
+
* @param {string} zoneName
|
|
213
|
+
* @returns {Promise<boolean>}
|
|
214
|
+
*/
|
|
215
|
+
async _asyncRecheckAfterOnDelay(zoneName) {
|
|
216
|
+
try {
|
|
217
|
+
if (this.triggerIsTime) {
|
|
218
|
+
let doContinue = await this.asyncAreScheduleConditionsMet(
|
|
219
|
+
'Trigger: Additional Conditions (recheck after delay)',
|
|
220
|
+
this.triggerTmAdditionCond,
|
|
221
|
+
this.triggerTmAddCondAll,
|
|
222
|
+
);
|
|
223
|
+
if (doContinue) {
|
|
224
|
+
doContinue = await this.asyncAreScheduleConditionsMet(
|
|
225
|
+
'Trigger: "Never if" Conditions (recheck after delay)',
|
|
226
|
+
this.triggerTmNever,
|
|
227
|
+
this.triggerTmNeverAll,
|
|
228
|
+
true,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (!doContinue) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
} else if (shouldRecheckTriggerState(this) && this.triggerStatePath) {
|
|
235
|
+
const stateObject = await this.adapter.x.helper.asyncGetForeignState(this.triggerStatePath);
|
|
236
|
+
if (!stateObject) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
if (!isTriggerStateMatching(stateObject.val, this.triggerStateVal, this.triggerTableId)) {
|
|
240
|
+
this.adapter.log.debug(
|
|
241
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': current value '${stateObject.val}' no longer matches '${this.triggerStateVal}'.`,
|
|
242
|
+
);
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
174
246
|
|
|
247
|
+
const zoneRow = (this.adapter.config.tableZones || []).find(
|
|
248
|
+
lpRow => lpRow.active && lpRow.name === zoneName,
|
|
249
|
+
);
|
|
250
|
+
if (!zoneRow || !Array.isArray(zoneRow.triggers) || !zoneRow.triggers.includes(this.triggerName)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return await this._asyncIsZoneExecutionCurrentlyMet(zoneRow);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
this.adapter.x.helper.dumpError('[_asyncRecheckAfterOnDelay]', error);
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
175
258
|
}
|
|
176
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Gilt die Ausführungs-Tabelle der Zone jetzt noch? (Uhrzeit, Wochentag, Bedingungen)
|
|
262
|
+
*
|
|
263
|
+
* @param {object} lpRowZones eine Zeile aus tableZones
|
|
264
|
+
* @returns {Promise<boolean>}
|
|
265
|
+
*/
|
|
266
|
+
async _asyncIsZoneExecutionCurrentlyMet(lpRowZones) {
|
|
267
|
+
const executeAlways = lpRowZones.executeAlways ? true : false;
|
|
268
|
+
let tablesZoneExecution = [];
|
|
269
|
+
if (executeAlways) {
|
|
270
|
+
tablesZoneExecution = [{ active: true, executeAlways: true }];
|
|
271
|
+
} else {
|
|
272
|
+
tablesZoneExecution = lpRowZones.executionJson ? JSON.parse(lpRowZones.executionJson) : [];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
for (const lpRow of tablesZoneExecution) {
|
|
276
|
+
if (lpRow.active && (await this._asyncDoesExecutionRowMatch(lpRowZones, lpRow))) {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Eine Zeile der Zonen-Ausführung (Zeitfenster, Tage, Bedingungen).
|
|
285
|
+
*
|
|
286
|
+
* @param {object} lpRowZones
|
|
287
|
+
* @param {object} lpRow
|
|
288
|
+
* @returns {Promise<boolean>}
|
|
289
|
+
*/
|
|
290
|
+
async _asyncDoesExecutionRowMatch(lpRowZones, lpRow) {
|
|
291
|
+
this.adapter.log.debug(`Trigger [${this.triggerName}] === check schedule conditions ===`);
|
|
292
|
+
|
|
293
|
+
if (lpRow.executeAlways) {
|
|
294
|
+
this.adapter.log.debug(
|
|
295
|
+
`Trigger [${this.triggerName}] Zone '${lpRowZones.name}' - 'Execute always is activated, so continue'`,
|
|
296
|
+
);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const tsCurrent = Date.now();
|
|
301
|
+
let doContinue = this.adapter.x.helper.scheduleIsTimeStampWithinPeriod(
|
|
302
|
+
tsCurrent,
|
|
303
|
+
lpRow.start,
|
|
304
|
+
lpRow.end,
|
|
305
|
+
lpRowZones.name,
|
|
306
|
+
);
|
|
307
|
+
if (doContinue) {
|
|
308
|
+
doContinue = this.adapter.x.helper.scheduleIsWeekdayMatching(lpRow, tsCurrent, lpRowZones.name);
|
|
309
|
+
}
|
|
310
|
+
if (doContinue) {
|
|
311
|
+
doContinue = await this.asyncAreScheduleConditionsMet(
|
|
312
|
+
'Zone Execution: Additional Conditions',
|
|
313
|
+
lpRow.additionalConditions,
|
|
314
|
+
lpRow.additionalConditionsAll,
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
if (doContinue) {
|
|
318
|
+
doContinue = await this.asyncAreScheduleConditionsMet(
|
|
319
|
+
'Zone Execution: "never if" Conditions',
|
|
320
|
+
lpRow.never,
|
|
321
|
+
lpRow.neverAll,
|
|
322
|
+
true,
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return doContinue;
|
|
326
|
+
}
|
|
177
327
|
|
|
178
328
|
/**
|
|
179
329
|
* Set all target devices: Process zone - Start
|
|
330
|
+
*
|
|
180
331
|
* @param {string} zoneName - Name of zone
|
|
181
332
|
*/
|
|
182
333
|
async _asyncSetTargetDevices_processZone(zoneName) {
|
|
183
|
-
|
|
184
334
|
try {
|
|
185
|
-
|
|
186
|
-
|
|
335
|
+
if (!this.zoneNames || !this.zoneTargetNames) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
187
338
|
|
|
188
339
|
/**
|
|
189
340
|
* Prepare: If Motion Sensor triggered - verify brightness if bri is set
|
|
190
341
|
*/
|
|
191
|
-
if (
|
|
192
|
-
|
|
342
|
+
if (
|
|
343
|
+
!this.mimicMotion &&
|
|
344
|
+
this.triggerIsMotion &&
|
|
345
|
+
!this.adapter.x.helper.isLikeEmpty(this.motionBriStatePath) &&
|
|
346
|
+
this.adapter.x.helper.isNumber(this.motionBriThreshold) &&
|
|
347
|
+
this.motionBriThreshold &&
|
|
348
|
+
this.motionBriThreshold > 0
|
|
349
|
+
) {
|
|
193
350
|
if (this.adapter.config.motionIgnoreBriIfZoneOn && this.adapter.x.zonesIsOn[zoneName]) {
|
|
194
351
|
// Disregard Brightness if zone is on (if this.adapter.config.motionIgnoreBriIfZoneOn == true)
|
|
195
|
-
this.adapter.log.debug(
|
|
352
|
+
this.adapter.log.debug(
|
|
353
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}' is on and new motion detected, therefore, we disregard any current brightness.`,
|
|
354
|
+
);
|
|
196
355
|
} else {
|
|
197
356
|
// Verify brightness
|
|
198
357
|
const briStateObjCurr = await this.adapter.x.helper.asyncGetForeignState(this.motionBriStatePath); // {val: false, ack: true, ts: 1591117034451, …}
|
|
199
358
|
const briStateValCurrent = briStateObjCurr.val;
|
|
200
|
-
if (
|
|
359
|
+
if (
|
|
360
|
+
this.adapter.x.helper.isLikeEmpty(briStateValCurrent) ||
|
|
361
|
+
!this.adapter.x.helper.isNumber(briStateValCurrent) ||
|
|
362
|
+
parseInt(briStateValCurrent) < 0
|
|
363
|
+
) {
|
|
201
364
|
// Bri not valid, so disregard bri and continue
|
|
202
|
-
this.adapter.log.debug(
|
|
365
|
+
this.adapter.log.debug(
|
|
366
|
+
`Trigger [${this.triggerName}] Brightness of ${briStateValCurrent} of ${this.motionBriStatePath} is not valid. State Value: [${briStateValCurrent}]. Therefore, bri will be disregarded and we continue.`,
|
|
367
|
+
);
|
|
203
368
|
} else if (parseInt(briStateValCurrent) < this.motionBriThreshold) {
|
|
204
369
|
// continue
|
|
205
|
-
this.adapter.log.debug(
|
|
370
|
+
this.adapter.log.debug(
|
|
371
|
+
`Trigger [${this.triggerName}] Brightness of ${briStateValCurrent} is < threshold of ${this.motionBriThreshold}, so we continue.`,
|
|
372
|
+
);
|
|
206
373
|
} else {
|
|
207
374
|
// Brightness condition is not met!
|
|
208
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
375
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
376
|
+
`Trigger [${this.triggerName}] activated but current brightness of ${briStateValCurrent} is >= threshold of ${this.motionBriThreshold} -> Motion disregarded.`,
|
|
377
|
+
);
|
|
209
378
|
return; // go out
|
|
210
379
|
}
|
|
211
380
|
}
|
|
212
381
|
} else if (!this.mimicMotion && this.triggerIsMotion) {
|
|
213
|
-
this.adapter.log.debug(
|
|
382
|
+
this.adapter.log.debug(
|
|
383
|
+
`Trigger [${this.triggerName}] - no brightness defined for this motion sensor, so continue and do not use bri as an additional criterion.`,
|
|
384
|
+
);
|
|
214
385
|
}
|
|
215
386
|
|
|
216
387
|
/**
|
|
217
388
|
* Ignore motion sensor triggered motion=true, if mimicMotionIgnoreMotionOn set to true
|
|
218
389
|
*/
|
|
219
|
-
const timeLeft = this.adapter.x.helper.getTimeoutTimeLeft(
|
|
390
|
+
const timeLeft = this.adapter.x.helper.getTimeoutTimeLeft(
|
|
391
|
+
this.adapter.x.timersMimicMotionTrigger[zoneName],
|
|
392
|
+
);
|
|
220
393
|
if (!this.mimicMotion && this.triggerStateVal && this.triggerIsMotion && this.mimicMotionIgnoreMotionOn) {
|
|
221
394
|
if (timeLeft > -1) {
|
|
222
|
-
this.adapter.log.debug(
|
|
395
|
+
this.adapter.log.debug(
|
|
396
|
+
`Trigger [${this.triggerName}] - Zone ${zoneName}: 'Mimic motion' is active, so we take over`,
|
|
397
|
+
);
|
|
223
398
|
// timer will be canceled below
|
|
224
399
|
} else {
|
|
225
|
-
this.adapter.log.info(
|
|
400
|
+
this.adapter.log.info(
|
|
401
|
+
`Trigger [${this.triggerName}] - Zone ${zoneName}: No execution due to activated zone option 'ignore motion on'.`,
|
|
402
|
+
);
|
|
226
403
|
return;
|
|
227
404
|
}
|
|
228
405
|
}
|
|
229
406
|
|
|
230
407
|
// Clear "linked devices" (mimic motion) timer for motion trigger
|
|
231
|
-
if (this.triggerIsMotion &&
|
|
232
|
-
clearTimeout(this.adapter.x.timersMimicMotionTrigger[zoneName]);
|
|
408
|
+
if (this.triggerIsMotion && timeLeft > -1) {
|
|
409
|
+
this.adapter.clearTimeout(this.adapter.x.timersMimicMotionTrigger[zoneName]);
|
|
233
410
|
this.adapter.x.timersMimicMotionTrigger[zoneName] = null;
|
|
234
|
-
this.adapter.log.debug(
|
|
411
|
+
this.adapter.log.debug(
|
|
412
|
+
`Clearing timer 'Linked device to motion', which was still running for ${(timeLeft / 1000).toFixed(0)} seconds.`,
|
|
413
|
+
);
|
|
235
414
|
}
|
|
236
415
|
|
|
237
|
-
|
|
238
|
-
|
|
239
416
|
/**
|
|
240
417
|
* -- Main --
|
|
241
418
|
* Loop thru the target device names and switch accordingly.
|
|
@@ -248,12 +425,21 @@ class Trigger {
|
|
|
248
425
|
let onOff = 'on'; // for toggle
|
|
249
426
|
|
|
250
427
|
// get delay ('onAfter')
|
|
251
|
-
const targetsOverwrite = this.adapter.getOptionTableValue(
|
|
428
|
+
const targetsOverwrite = this.adapter.getOptionTableValue(
|
|
429
|
+
'tableZones',
|
|
430
|
+
'name',
|
|
431
|
+
zoneName,
|
|
432
|
+
'targetsOverwrite',
|
|
433
|
+
); // like: {'Hallway.Light':{val:'new val', delay:10}, 'Hallway.Radio':{val:'Radio XYZ'}}
|
|
252
434
|
|
|
253
435
|
let counterDevicesProcessed = 0; // Once all processed, we will call a function
|
|
254
436
|
for (const lpTargetDeviceName of this.zoneTargetNames[zoneName]) {
|
|
255
|
-
|
|
256
|
-
|
|
437
|
+
let delay = this.adapter.getOptionTableValue(
|
|
438
|
+
'tableTargetDevices',
|
|
439
|
+
'name',
|
|
440
|
+
lpTargetDeviceName,
|
|
441
|
+
'onAfter',
|
|
442
|
+
);
|
|
257
443
|
if (delay !== undefined && this.adapter.x.helper.isNumber(delay) && parseInt(delay) > 0) {
|
|
258
444
|
delay = parseInt(delay);
|
|
259
445
|
} else {
|
|
@@ -261,31 +447,43 @@ class Trigger {
|
|
|
261
447
|
}
|
|
262
448
|
lDelaySecs.push(delay);
|
|
263
449
|
|
|
264
|
-
// Targets overwrite:
|
|
450
|
+
// Targets overwrite: alte UI speicherte oft nur den String ("95"),
|
|
451
|
+
// jsonConfig/verify { val, delay }. Beides muss zur Laufzeit greifen.
|
|
265
452
|
let overwriteValue = null;
|
|
266
453
|
if (targetsOverwrite && targetsOverwrite[lpTargetDeviceName]) {
|
|
267
|
-
|
|
268
|
-
|
|
454
|
+
const ow = this.adapter.x.helper.convertStrToJson(targetsOverwrite[lpTargetDeviceName], [
|
|
455
|
+
'val',
|
|
456
|
+
'delay',
|
|
457
|
+
]);
|
|
458
|
+
if (ow && !this.adapter.x.helper.isLikeEmpty(ow.val)) {
|
|
459
|
+
overwriteValue = ow.val;
|
|
269
460
|
}
|
|
270
|
-
if (
|
|
271
|
-
&&
|
|
272
|
-
|
|
273
|
-
|
|
461
|
+
if (
|
|
462
|
+
ow &&
|
|
463
|
+
ow.delay !== undefined &&
|
|
464
|
+
this.adapter.x.helper.isNumber(ow.delay) &&
|
|
465
|
+
parseInt(ow.delay) > -1
|
|
466
|
+
) {
|
|
467
|
+
delay = parseInt(ow.delay);
|
|
274
468
|
}
|
|
275
469
|
}
|
|
276
470
|
|
|
277
|
-
|
|
278
471
|
/**
|
|
279
472
|
* let's call function switchTargetDevice()
|
|
280
473
|
*/
|
|
281
474
|
// Timer (delay) to switch device on
|
|
282
|
-
if (delay > 0)
|
|
283
|
-
|
|
284
|
-
|
|
475
|
+
if (delay > 0) {
|
|
476
|
+
lDelayedDevices.push(lpTargetDeviceName);
|
|
477
|
+
}
|
|
478
|
+
this.adapter.clearTimeout(this.adapter.x.timersZoneDeviceOnDelay[`${zoneName}_${lpTargetDeviceName}`]);
|
|
479
|
+
this.adapter.x.timersZoneDeviceOnDelay[`${zoneName}_${lpTargetDeviceName}`] = null;
|
|
285
480
|
|
|
286
481
|
if (delay > 0) {
|
|
287
482
|
// set timeout
|
|
288
|
-
this.adapter.x.timersZoneDeviceOnDelay[zoneName
|
|
483
|
+
this.adapter.x.timersZoneDeviceOnDelay[`${zoneName}_${lpTargetDeviceName}`] =
|
|
484
|
+
this.adapter.setTimeout(() => {
|
|
485
|
+
switchTargetDeviceAsync(this);
|
|
486
|
+
}, delay * 1000);
|
|
289
487
|
} else {
|
|
290
488
|
// call right away
|
|
291
489
|
await switchTargetDeviceAsync(this);
|
|
@@ -293,63 +491,92 @@ class Trigger {
|
|
|
293
491
|
|
|
294
492
|
/**
|
|
295
493
|
* Function switchTargetDevice
|
|
494
|
+
*
|
|
296
495
|
* @param {object} that - this
|
|
297
496
|
*/
|
|
298
497
|
async function switchTargetDeviceAsync(that) {
|
|
299
|
-
|
|
300
498
|
try {
|
|
301
|
-
|
|
302
|
-
|
|
499
|
+
if (!that.zoneTargetNames) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
303
502
|
|
|
304
503
|
counterDevicesProcessed++; // +1
|
|
305
504
|
|
|
306
505
|
// If target device should be switched off, and not on, per config in trigger table
|
|
307
506
|
// Will be overwritten later if toggle is activated
|
|
308
|
-
if (that.targetOff)
|
|
309
|
-
|
|
507
|
+
if (that.targetOff) {
|
|
508
|
+
onOff = 'off';
|
|
509
|
+
}
|
|
510
|
+
|
|
310
511
|
// Toggle
|
|
311
512
|
if (that.triggerIsToggle) {
|
|
312
513
|
// If we have Toggle, we are using the ON state/value to check.
|
|
313
|
-
const onState = that.adapter.getOptionTableValue(
|
|
314
|
-
|
|
514
|
+
const onState = that.adapter.getOptionTableValue(
|
|
515
|
+
'tableTargetDevices',
|
|
516
|
+
'name',
|
|
517
|
+
lpTargetDeviceName,
|
|
518
|
+
'onState',
|
|
519
|
+
);
|
|
520
|
+
const onVal = that.adapter.getOptionTableValue(
|
|
521
|
+
'tableTargetDevices',
|
|
522
|
+
'name',
|
|
523
|
+
lpTargetDeviceName,
|
|
524
|
+
'onValue',
|
|
525
|
+
);
|
|
315
526
|
const currentStateVal = await that.adapter.x.helper.asyncGetForeignStateValue(onState);
|
|
316
|
-
if (currentStateVal == null)
|
|
527
|
+
if (currentStateVal == null) {
|
|
528
|
+
throw `Could not get current state value for '${onState}' of device '${lpTargetDeviceName}'`;
|
|
529
|
+
}
|
|
317
530
|
if (onVal == currentStateVal) {
|
|
318
531
|
onOff = 'off';
|
|
319
532
|
} else {
|
|
320
533
|
onOff = 'on';
|
|
321
534
|
}
|
|
322
535
|
}
|
|
323
|
-
|
|
536
|
+
|
|
324
537
|
// Get option values.
|
|
325
|
-
const lpTargetState = that.adapter.getOptionTableValue(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
538
|
+
const lpTargetState = that.adapter.getOptionTableValue(
|
|
539
|
+
'tableTargetDevices',
|
|
540
|
+
'name',
|
|
541
|
+
lpTargetDeviceName,
|
|
542
|
+
`${onOff}State`,
|
|
543
|
+
);
|
|
544
|
+
let lpTargetVal = that.adapter.getOptionTableValue(
|
|
545
|
+
'tableTargetDevices',
|
|
546
|
+
'name',
|
|
547
|
+
lpTargetDeviceName,
|
|
548
|
+
`${onOff}Value`,
|
|
549
|
+
);
|
|
550
|
+
const noTargetCheckStr = onOff == 'on' ? 'noTargetOnCheck' : 'noTargetOffCheck';
|
|
551
|
+
const doNotCheckTarget = that.adapter.getOptionTableValue(
|
|
552
|
+
'tableTargetDevices',
|
|
553
|
+
'name',
|
|
554
|
+
lpTargetDeviceName,
|
|
555
|
+
noTargetCheckStr,
|
|
556
|
+
);
|
|
557
|
+
|
|
330
558
|
if (lpTargetState == undefined || lpTargetVal == undefined) {
|
|
331
|
-
throw
|
|
559
|
+
throw `Unable to retrieve target '${onOff}' state/value for target device '${lpTargetDeviceName}'`;
|
|
332
560
|
}
|
|
333
|
-
|
|
561
|
+
|
|
334
562
|
// Overwrite target values if according value is set in Zones table
|
|
335
563
|
if (onOff == 'on' && overwriteValue !== null) {
|
|
336
564
|
lpTargetVal = overwriteValue;
|
|
337
565
|
}
|
|
338
|
-
|
|
566
|
+
|
|
339
567
|
// Let's get current state value
|
|
340
568
|
let currentStateVal;
|
|
341
569
|
if (!doNotCheckTarget) {
|
|
342
570
|
currentStateVal = await that.adapter.x.helper.asyncGetForeignStateValue(lpTargetState);
|
|
343
571
|
if (currentStateVal == null) {
|
|
344
|
-
throw
|
|
572
|
+
throw `Could not get current state value for '${lpTargetState}' of device '${lpTargetDeviceName}'`;
|
|
345
573
|
}
|
|
346
574
|
}
|
|
347
|
-
|
|
575
|
+
|
|
348
576
|
// Set target state.
|
|
349
577
|
// Note: Verification of the state value and conversion as needed was performed already by asyncVerifyConfig()
|
|
350
578
|
// Check if device is already on.
|
|
351
|
-
if (doNotCheckTarget || (!doNotCheckTarget &&
|
|
352
|
-
|
|
579
|
+
if (doNotCheckTarget || (!doNotCheckTarget && currentStateVal != lpTargetVal)) {
|
|
353
580
|
// Set state
|
|
354
581
|
await that.adapter.setForeignStateAsync(lpTargetState, { val: lpTargetVal, ack: false });
|
|
355
582
|
//if (delay == 0) lSwitchedDevices.push(lpTargetDeviceName);
|
|
@@ -362,7 +589,11 @@ class Trigger {
|
|
|
362
589
|
}
|
|
363
590
|
} else {
|
|
364
591
|
//Triggered by NON-motion, so remove from that.adapter.x.motionTriggeredDevices
|
|
365
|
-
that.adapter.x.motionTriggeredDevices =
|
|
592
|
+
that.adapter.x.motionTriggeredDevices =
|
|
593
|
+
that.adapter.x.helper.arrayRemoveElementByValue(
|
|
594
|
+
that.adapter.x.motionTriggeredDevices,
|
|
595
|
+
lpTargetDeviceName,
|
|
596
|
+
);
|
|
366
597
|
}
|
|
367
598
|
}
|
|
368
599
|
// set json log to smartcontrol.x.info.log.switchedTargetDevices.json
|
|
@@ -374,26 +605,31 @@ class Trigger {
|
|
|
374
605
|
triggerName: that.triggerName,
|
|
375
606
|
ts: Date.now(),
|
|
376
607
|
});
|
|
377
|
-
|
|
378
608
|
} else {
|
|
379
609
|
// do not set target state
|
|
380
610
|
// if (delay == 0) lAlreadyOnDevices.push(lpTargetDeviceName);
|
|
381
611
|
lAlreadyOnDevices.push(lpTargetDeviceName);
|
|
382
612
|
}
|
|
383
613
|
|
|
384
|
-
if (counterDevicesProcessed == that.zoneTargetNames[zoneName].length) {
|
|
385
|
-
|
|
614
|
+
if (counterDevicesProcessed == that.zoneTargetNames[zoneName].length) {
|
|
386
615
|
/**
|
|
387
616
|
* All devices processed, so we continue here
|
|
388
617
|
*/
|
|
389
|
-
if (!that.zoneTargetNames || !that.zoneNames)
|
|
618
|
+
if (!that.zoneTargetNames || !that.zoneNames) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
390
621
|
|
|
391
622
|
/**
|
|
392
623
|
* Motion Trigger: If target was already turned on previously by a non-motion trigger: do not schedule timer.
|
|
393
624
|
* Also, provide some log info in logMotion
|
|
394
625
|
*/
|
|
395
626
|
let logMotion = '';
|
|
396
|
-
if (
|
|
627
|
+
if (
|
|
628
|
+
!that.mimicMotion &&
|
|
629
|
+
that.triggerIsMotion &&
|
|
630
|
+
that.motionDuration &&
|
|
631
|
+
that.motionDuration > 0
|
|
632
|
+
) {
|
|
397
633
|
const lRemovedDevices = [];
|
|
398
634
|
if (that.motionNotIfManual) {
|
|
399
635
|
for (const lpTargetDevice of lAlreadyOnDevices) {
|
|
@@ -402,7 +638,11 @@ class Trigger {
|
|
|
402
638
|
} else {
|
|
403
639
|
// Device was already on, but NO motion triggered before.
|
|
404
640
|
// Therefore, we will exclude device from the timer
|
|
405
|
-
that.zoneTargetNames[zoneName] =
|
|
641
|
+
that.zoneTargetNames[zoneName] =
|
|
642
|
+
that.adapter.x.helper.arrayRemoveElementByValue(
|
|
643
|
+
that.zoneTargetNames[zoneName],
|
|
644
|
+
lpTargetDevice,
|
|
645
|
+
);
|
|
406
646
|
lRemovedDevices.push(lpTargetDevice);
|
|
407
647
|
}
|
|
408
648
|
}
|
|
@@ -418,24 +658,30 @@ class Trigger {
|
|
|
418
658
|
}
|
|
419
659
|
}
|
|
420
660
|
|
|
421
|
-
|
|
422
661
|
/**
|
|
423
662
|
* Set "always off after" timer if set in Table Zones.
|
|
424
663
|
*/
|
|
425
664
|
if (that.triggerIsToggle && onOff == 'off') {
|
|
426
665
|
// Toggle is activated and zone is turned off, so kill/delete the timer.
|
|
427
|
-
const zoneOffTimeLeft = that.adapter.x.helper.getTimeoutTimeLeft(
|
|
666
|
+
const zoneOffTimeLeft = that.adapter.x.helper.getTimeoutTimeLeft(
|
|
667
|
+
that.adapter.x.timersZoneOff[zoneName],
|
|
668
|
+
);
|
|
428
669
|
if (zoneOffTimeLeft > -1) {
|
|
429
|
-
that.adapter.log.debug(
|
|
430
|
-
|
|
670
|
+
that.adapter.log.debug(
|
|
671
|
+
`Trigger [${that.triggerName}] Zone '${zoneName}': Turn off 'always off' timer, since still running ${(zoneOffTimeLeft / 1000).toFixed(0)} seconds and toggle trigger triggered to turn off.`,
|
|
672
|
+
);
|
|
673
|
+
that.adapter.clearTimeout(that.adapter.x.timersZoneOff[zoneName]);
|
|
431
674
|
that.adapter.x.timersZoneOff[zoneName] = null;
|
|
432
675
|
}
|
|
433
|
-
|
|
434
676
|
} else {
|
|
435
|
-
if (that.triggerIsMotion &&
|
|
436
|
-
that.adapter.x.helper.logExtendedInfo(
|
|
677
|
+
if (that.triggerIsMotion && that.zoneTargetNames[zoneName].length < 1) {
|
|
678
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
679
|
+
`Trigger [${that.triggerName}], Zone '${that.zoneNames.toString()}': no 'always off after' timer set since device(s) turned on manually before.`,
|
|
680
|
+
);
|
|
437
681
|
} else {
|
|
438
|
-
const zoneOffSecs = parseInt(
|
|
682
|
+
const zoneOffSecs = parseInt(
|
|
683
|
+
that.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'offAfter'),
|
|
684
|
+
);
|
|
439
685
|
that.asyncSetZoneTimer_zoneOff('timersZoneOff', zoneName, zoneOffSecs);
|
|
440
686
|
}
|
|
441
687
|
}
|
|
@@ -444,75 +690,93 @@ class Trigger {
|
|
|
444
690
|
* If "mimic motion": set off timer for zone
|
|
445
691
|
*/
|
|
446
692
|
if (that.mimicMotion) {
|
|
447
|
-
const zoneOffSecs = parseInt(
|
|
448
|
-
|
|
693
|
+
const zoneOffSecs = parseInt(
|
|
694
|
+
that.adapter.getOptionTableValue(
|
|
695
|
+
'tableTriggerMotion',
|
|
696
|
+
'name',
|
|
697
|
+
that.triggerName,
|
|
698
|
+
'motionLinkedDuration',
|
|
699
|
+
),
|
|
700
|
+
);
|
|
701
|
+
that.asyncSetZoneTimer_zoneOff('timersMimicMotionTrigger', zoneName, zoneOffSecs);
|
|
449
702
|
}
|
|
450
703
|
|
|
451
|
-
|
|
452
704
|
// Set "Zone is on" status
|
|
453
705
|
that.adapter.x.zonesIsOn[zoneName] = true;
|
|
454
706
|
|
|
455
707
|
/**
|
|
456
708
|
* JSON log for info.log.zoneActivations.json
|
|
457
709
|
*/
|
|
458
|
-
const alwaysOff = parseInt(
|
|
710
|
+
const alwaysOff = parseInt(
|
|
711
|
+
that.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'offAfter'),
|
|
712
|
+
);
|
|
459
713
|
that.adapter.x.helper.setJsonLog('zoneActivations', {
|
|
460
714
|
ts: Date.now(),
|
|
461
715
|
time: that.adapter.x.helper.dateToLocalIsoString(new Date()),
|
|
462
716
|
zone: zoneName,
|
|
463
|
-
trigger:
|
|
717
|
+
trigger: !that.mimicMotion ? that.triggerName : that.mimicMotionTriggerName,
|
|
464
718
|
targetsAll: that.zoneTargetNames[zoneName].toString(),
|
|
465
719
|
targetsAllDelays: JSON.stringify(lDelaySecs),
|
|
466
720
|
targetsSet: lSwitchedDevices.toString(),
|
|
467
721
|
targetsSkipped: lAlreadyOnDevices.toString(),
|
|
468
|
-
motionTimer:
|
|
469
|
-
alwaysOffTimer:
|
|
722
|
+
motionTimer: that.motionDuration ? that.motionDuration : 0,
|
|
723
|
+
alwaysOffTimer: isNaN(alwaysOff) ? 0 : alwaysOff,
|
|
470
724
|
});
|
|
471
725
|
|
|
472
726
|
// Finalize
|
|
473
727
|
if (lSwitchedDevices.length > 0) {
|
|
474
728
|
if (lAlreadyOnDevices.length < 1) {
|
|
475
|
-
that.adapter.x.helper.logExtendedInfo(
|
|
729
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
730
|
+
`Trigger [${that.triggerName}] activated Zone '${zoneName}'. Turned ${onOff}: ${lSwitchedDevices.toString()}.`,
|
|
731
|
+
);
|
|
476
732
|
} else {
|
|
477
|
-
that.adapter.x.helper.logExtendedInfo(
|
|
733
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
734
|
+
`Trigger [${that.triggerName}] activated Zone '${zoneName}'. Turned ${onOff}: ${lSwitchedDevices.toString()}. Not turned ${onOff} (as already ${onOff}): '${lAlreadyOnDevices.toString()}'`,
|
|
735
|
+
);
|
|
478
736
|
}
|
|
479
737
|
} else {
|
|
480
|
-
if (lAlreadyOnDevices.length > 0)
|
|
738
|
+
if (lAlreadyOnDevices.length > 0) {
|
|
739
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
740
|
+
`Trigger [${that.triggerName}] activated Zone '${zoneName}'. However, device(s) '${lAlreadyOnDevices.toString()}' not turned ${onOff} as these are already ${onOff}.`,
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (lDelayedDevices.length > 0) {
|
|
745
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
746
|
+
`Trigger [${that.triggerName}] Following device(s) will be switched ${onOff} later, since a delay was set: ${lDelayedDevices.toString()}.`,
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
if (logMotion) {
|
|
750
|
+
that.adapter.x.helper.logExtendedInfo(
|
|
751
|
+
`Trigger [${that.triggerName}] Zone '${zoneName}': ${logMotion}`,
|
|
752
|
+
);
|
|
481
753
|
}
|
|
482
|
-
if (lDelayedDevices.length > 0) that.adapter.x.helper.logExtendedInfo(`Trigger [${that.triggerName}] Following device(s) will be switched ${onOff} later, since a delay was set: ${lDelayedDevices.toString()}.`);
|
|
483
|
-
if (logMotion) that.adapter.x.helper.logExtendedInfo(`Trigger [${that.triggerName}] Zone '${zoneName}': ${logMotion}`);
|
|
484
|
-
|
|
485
754
|
}
|
|
486
|
-
|
|
487
755
|
} catch (error) {
|
|
488
756
|
that.adapter.x.helper.dumpError(`[switchTargetDevice]`, error);
|
|
489
757
|
return;
|
|
490
758
|
}
|
|
491
|
-
|
|
492
759
|
}
|
|
493
|
-
|
|
494
760
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
761
|
} catch (error) {
|
|
498
762
|
this.adapter.x.helper.dumpError(`[_asyncSetTargetDevices_processZone]`, error);
|
|
499
763
|
return;
|
|
500
764
|
}
|
|
501
765
|
}
|
|
502
766
|
|
|
503
|
-
|
|
504
767
|
/**
|
|
505
768
|
* Set timeout to switch devices of a zone off for zoneOff timer
|
|
769
|
+
*
|
|
506
770
|
* @param {string} timerObjectKey - e.g. 'timersZoneOff' or 'timersMimicMotionTrigger'
|
|
507
771
|
* @param {string} zoneName - Zone Name
|
|
508
772
|
* @param {number} zoneOffAfter - Switch zone off after this number of seconds
|
|
509
773
|
*/
|
|
510
774
|
async asyncSetZoneTimer_zoneOff(timerObjectKey, zoneName, zoneOffAfter) {
|
|
511
|
-
|
|
512
775
|
try {
|
|
513
|
-
|
|
514
776
|
if (!zoneOffAfter || zoneOffAfter < 1) {
|
|
515
|
-
this.adapter.log.debug(
|
|
777
|
+
this.adapter.log.debug(
|
|
778
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}' No 'Always off after' time is set, so we do not set such timer.`,
|
|
779
|
+
);
|
|
516
780
|
return;
|
|
517
781
|
}
|
|
518
782
|
|
|
@@ -522,40 +786,53 @@ class Trigger {
|
|
|
522
786
|
// First: clear timers. Note: we use timeLeft since we need this anyways for log.
|
|
523
787
|
const timeLeft = this.adapter.x.helper.getTimeoutTimeLeft(this.adapter.x[timerObjectKey][zoneName]);
|
|
524
788
|
if (timeLeft > -1) {
|
|
525
|
-
clearTimeout(this.adapter.x[timerObjectKey][zoneName]);
|
|
789
|
+
this.adapter.clearTimeout(this.adapter.x[timerObjectKey][zoneName]);
|
|
526
790
|
this.adapter.x[timerObjectKey][zoneName] = null;
|
|
527
791
|
}
|
|
528
792
|
|
|
529
793
|
// Set timer
|
|
530
|
-
this.adapter.x[timerObjectKey][zoneName] = setTimeout(() => {
|
|
794
|
+
this.adapter.x[timerObjectKey][zoneName] = this.adapter.setTimeout(() => {
|
|
531
795
|
this._asyncSetZoneTimer_doOnTimeout(zoneName, timerObjectKey, targets, zoneOffAfter);
|
|
532
796
|
}, zoneOffAfter * 1000);
|
|
533
797
|
|
|
534
798
|
// Some log
|
|
535
799
|
if (timeLeft > -1) {
|
|
536
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
800
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
801
|
+
`Trigger [${this.triggerName}] 'zoneOff' ${zoneOffAfter}s timer still running ${(timeLeft / 1000).toFixed(0)}s. We stop it and set new to ${zoneOffAfter}s.`,
|
|
802
|
+
);
|
|
537
803
|
} else {
|
|
538
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
804
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
805
|
+
`Trigger [${this.triggerName}] 'zoneOff' ${zoneOffAfter}s timer for zone '${zoneName}' initially started.`,
|
|
806
|
+
);
|
|
539
807
|
}
|
|
540
|
-
|
|
541
808
|
} catch (error) {
|
|
542
809
|
this.adapter.x.helper.dumpError(`[asyncSetZoneTimer_zoneOff]`, error);
|
|
543
810
|
return;
|
|
544
811
|
}
|
|
545
|
-
|
|
546
812
|
}
|
|
547
813
|
|
|
548
|
-
|
|
549
814
|
/**
|
|
550
815
|
* Set timeout to switch devices of a zone off, if a motion sensor was triggered and switch off time (duration) is provided.
|
|
816
|
+
* Ein Timer pro Zone (nicht pro Melder): sonst schaltet der zuerst abgelaufene BWM das Licht aus (#147).
|
|
817
|
+
*
|
|
551
818
|
* @param {string} zoneName - Zone Name
|
|
552
819
|
*/
|
|
553
820
|
async asyncSetZoneTimer_motion(zoneName) {
|
|
554
|
-
|
|
555
821
|
try {
|
|
556
|
-
|
|
557
822
|
// Go out if no duration is set
|
|
558
|
-
if (!this.motionDuration || this.motionDuration <= 0)
|
|
823
|
+
if (!this.motionDuration || this.motionDuration <= 0) {
|
|
824
|
+
throw `No motion duration set for ${this.triggerName}.`;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Anderer BWM der Zone noch true? Dann keinen Aus-Timer starten (und laufenden löschen).
|
|
828
|
+
const otherMotionTrueName = await this._asyncGetOtherMotionTrueName(zoneName);
|
|
829
|
+
if (zoneMotionOffTimerAction(!!otherMotionTrueName) === 'skip') {
|
|
830
|
+
this._clearZoneMotionOffTimer(zoneName);
|
|
831
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
832
|
+
`Trigger [${this.triggerName}] Motion sensor '${this.triggerName}', zone '${zoneName}': No more motion, but '${otherMotionTrueName}' still detects motion, so we do not set off timer.`,
|
|
833
|
+
);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
559
836
|
|
|
560
837
|
// Get current target devices info
|
|
561
838
|
const targets = await this._asyncGetTargetDevicesInfoOfZone(zoneName); // {statePaths:[Array of state paths], stateValues: [Array of state values], deviceNames: [Array of device names]}
|
|
@@ -565,70 +842,128 @@ class Trigger {
|
|
|
565
842
|
return; // We already logged in _asyncGetTargetDevicesInfoOfZone()
|
|
566
843
|
}
|
|
567
844
|
|
|
568
|
-
//
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
845
|
+
// Bestehenden Zonen-Timer ersetzen (nicht parallel zum Timer eines anderen Melders)
|
|
846
|
+
const timeLeft = this.adapter.x.helper.getTimeoutTimeLeft(this.adapter.x.timersMotionOff[zoneName]);
|
|
847
|
+
if (timeLeft > -1) {
|
|
848
|
+
this.adapter.log.debug(
|
|
849
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': Motion off-timer still running ${(timeLeft / 1000).toFixed(0)} seconds but another 'no motion' of this zone detected. Therefore, we stop timer and set new.`,
|
|
850
|
+
);
|
|
851
|
+
this._clearZoneMotionOffTimer(zoneName);
|
|
576
852
|
}
|
|
577
853
|
|
|
578
854
|
// Set timer
|
|
579
|
-
this.
|
|
580
|
-
if (!this.motionDuration)
|
|
855
|
+
this.adapter.x.timersMotionOff[zoneName] = this.adapter.setTimeout(() => {
|
|
856
|
+
if (!this.motionDuration) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
581
859
|
this._asyncSetZoneTimer_doOnTimeout(zoneName, 'Motion', targets, this.motionDuration);
|
|
582
860
|
}, this.motionDuration * 1000);
|
|
583
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
584
|
-
|
|
861
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
862
|
+
`Trigger [${this.triggerName}] Motion sensor '${this.triggerName}', zone '${zoneName}': No more motion, so we set ${this.motionDuration}s timer.`,
|
|
863
|
+
);
|
|
585
864
|
} catch (error) {
|
|
586
865
|
this.adapter.x.helper.dumpError(`[asyncSetZoneTimer_motion]`, error);
|
|
587
866
|
return;
|
|
588
867
|
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Laufenden Bewegungs-Aus-Timer dieser Zone löschen (ein Timer pro Zone).
|
|
872
|
+
*
|
|
873
|
+
* @param {string} zoneName
|
|
874
|
+
*/
|
|
875
|
+
_clearZoneMotionOffTimer(zoneName) {
|
|
876
|
+
if (this.adapter.x.timersMotionOff[zoneName]) {
|
|
877
|
+
this.adapter.clearTimeout(this.adapter.x.timersMotionOff[zoneName]);
|
|
878
|
+
this.adapter.x.timersMotionOff[zoneName] = null;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
589
881
|
|
|
882
|
+
/**
|
|
883
|
+
* Name eines anderen BWM derselben Zone, der noch Bewegung (true) meldet, sonst null.
|
|
884
|
+
*
|
|
885
|
+
* @param {string} zoneName
|
|
886
|
+
* @returns {Promise<string|null>}
|
|
887
|
+
*/
|
|
888
|
+
async _asyncGetOtherMotionTrueName(zoneName) {
|
|
889
|
+
const otherNames = getOtherMotionTriggerNames(
|
|
890
|
+
this.adapter.config.tableTriggerMotion,
|
|
891
|
+
this.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'triggers'),
|
|
892
|
+
this.triggerName,
|
|
893
|
+
);
|
|
894
|
+
for (const lpName of otherNames) {
|
|
895
|
+
const lpMotionObjId = this.adapter.getOptionTableValue('tableTriggerMotion', 'name', lpName, 'stateId');
|
|
896
|
+
const lpMotionObj = await this.adapter.x.helper.asyncGetForeignStateValue(lpMotionObjId);
|
|
897
|
+
if (lpMotionObj == true) {
|
|
898
|
+
return lpName;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return null;
|
|
590
902
|
}
|
|
591
903
|
|
|
592
904
|
/**
|
|
593
905
|
* Check if additional conditions are met (like Public Holiday, etc. -- as set in conditions table).
|
|
594
|
-
*
|
|
595
|
-
* @param {string} name - Any name, for logging only
|
|
596
|
-
* @param {
|
|
906
|
+
*
|
|
907
|
+
* @param {string} name - Any name, for logging only
|
|
908
|
+
* @param {Array} conditionNames - Array of condition names
|
|
597
909
|
* @param {boolean} allMustMeet - if true: all conditions must be met, if false: one condition is enough
|
|
598
910
|
* @param {boolean} [inverse] - if true: inverse results (true -> false, and vice versa)
|
|
599
|
-
* @
|
|
911
|
+
* @returns {Promise<boolean>} True if condition(s) met, false if not. Also return true, if empty conditionNames array
|
|
600
912
|
*/
|
|
601
913
|
async asyncAreScheduleConditionsMet(name, conditionNames, allMustMeet, inverse = false) {
|
|
602
|
-
|
|
603
914
|
try {
|
|
604
|
-
|
|
605
915
|
// If empty array, we return true, as we need to continue if no conditions are set in the options table.
|
|
606
916
|
if (this.adapter.x.helper.isLikeEmpty(conditionNames)) {
|
|
607
|
-
this.adapter.log.debug(
|
|
917
|
+
this.adapter.log.debug(
|
|
918
|
+
`Trigger [${this.triggerName}], ${name} - no conditions defined, so we return "true" to continue.`,
|
|
919
|
+
);
|
|
608
920
|
return true;
|
|
609
921
|
}
|
|
610
922
|
|
|
611
923
|
let hitCount = 0;
|
|
612
924
|
|
|
613
|
-
this.adapter.log.debug(
|
|
925
|
+
this.adapter.log.debug(
|
|
926
|
+
`Trigger [${this.triggerName}], ${name} - check if conditions met: '${JSON.stringify(conditionNames)}'`,
|
|
927
|
+
);
|
|
614
928
|
const notMetConditionNames = [];
|
|
615
929
|
for (const lpConditionName of conditionNames) {
|
|
930
|
+
if (hitCount > 0 && allMustMeet == false) {
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
616
933
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
934
|
+
const lpConditionStatePath = this.adapter.getOptionTableValue(
|
|
935
|
+
'tableConditions',
|
|
936
|
+
'name',
|
|
937
|
+
lpConditionName,
|
|
938
|
+
'conditionState',
|
|
939
|
+
);
|
|
940
|
+
const lpConditionStateValue = this.adapter.getOptionTableValue(
|
|
941
|
+
'tableConditions',
|
|
942
|
+
'name',
|
|
943
|
+
lpConditionName,
|
|
944
|
+
'conditionValue',
|
|
945
|
+
);
|
|
621
946
|
|
|
622
947
|
if (!lpConditionStatePath) {
|
|
623
|
-
this.adapter.log.error(
|
|
948
|
+
this.adapter.log.error(
|
|
949
|
+
`asyncAreScheduleConditionsMet(): condition details for '${lpConditionName}' could not be found.`,
|
|
950
|
+
);
|
|
624
951
|
notMetConditionNames.push(lpConditionName);
|
|
625
|
-
if (allMustMeet) {
|
|
952
|
+
if (allMustMeet) {
|
|
953
|
+
break;
|
|
954
|
+
} else {
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
626
957
|
}
|
|
627
958
|
|
|
628
959
|
const lpStateVal = await this.adapter.x.helper.asyncGetForeignStateValue(lpConditionStatePath);
|
|
629
960
|
if (lpStateVal == null) {
|
|
630
961
|
notMetConditionNames.push(lpConditionName);
|
|
631
|
-
if (allMustMeet) {
|
|
962
|
+
if (allMustMeet) {
|
|
963
|
+
break;
|
|
964
|
+
} else {
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
632
967
|
}
|
|
633
968
|
|
|
634
969
|
/**
|
|
@@ -637,146 +972,153 @@ class Trigger {
|
|
|
637
972
|
// First: do we have comparator
|
|
638
973
|
const res = this.adapter.x.helper.isNumComparatorMatching(lpStateVal, lpConditionStateValue);
|
|
639
974
|
if (res.isComparator && res.result) {
|
|
640
|
-
this.adapter.log.debug(
|
|
975
|
+
this.adapter.log.debug(
|
|
976
|
+
`Trigger [${this.triggerName}], ${name} - condition '${lpConditionName}' *met* (options val = '${lpConditionStateValue}', actual state val = '${lpStateVal}')`,
|
|
977
|
+
);
|
|
641
978
|
hitCount++;
|
|
642
|
-
if (allMustMeet) {
|
|
979
|
+
if (allMustMeet) {
|
|
980
|
+
continue;
|
|
981
|
+
} else {
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
643
984
|
|
|
644
985
|
// Next: no comparator, so compare directly with ==
|
|
645
986
|
} else if (lpConditionStateValue == lpStateVal) {
|
|
646
|
-
this.adapter.log.debug(
|
|
987
|
+
this.adapter.log.debug(
|
|
988
|
+
`Trigger [${this.triggerName}], ${name} - condition '${lpConditionName}' *met* (options val = '${lpConditionStateValue}', actual state val = '${lpStateVal}')`,
|
|
989
|
+
);
|
|
647
990
|
hitCount++;
|
|
648
|
-
if (allMustMeet) {
|
|
991
|
+
if (allMustMeet) {
|
|
992
|
+
continue;
|
|
993
|
+
} else {
|
|
994
|
+
break;
|
|
995
|
+
}
|
|
649
996
|
} else {
|
|
650
997
|
// No hit, so go out!
|
|
651
|
-
this.adapter.log.debug(
|
|
998
|
+
this.adapter.log.debug(
|
|
999
|
+
`Trigger [${this.triggerName}], ${name} - condition '${lpConditionName}' *not* met (options val = '${lpConditionStateValue}', actual state val = '${lpStateVal}')`,
|
|
1000
|
+
);
|
|
652
1001
|
notMetConditionNames.push(lpConditionName);
|
|
653
|
-
if (allMustMeet) {
|
|
1002
|
+
if (allMustMeet) {
|
|
1003
|
+
break;
|
|
1004
|
+
} else {
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
654
1007
|
}
|
|
655
|
-
|
|
656
1008
|
}
|
|
657
1009
|
|
|
658
1010
|
let result = false;
|
|
659
|
-
if ((allMustMeet &&
|
|
1011
|
+
if ((allMustMeet && hitCount == conditionNames.length) || (!allMustMeet && hitCount > 0)) {
|
|
660
1012
|
result = true;
|
|
1013
|
+
}
|
|
661
1014
|
|
|
662
|
-
if (inverse)
|
|
1015
|
+
if (inverse) {
|
|
1016
|
+
result = !result;
|
|
1017
|
+
}
|
|
663
1018
|
|
|
664
1019
|
if (result) {
|
|
665
1020
|
this.adapter.log.debug(`Trigger [${this.triggerName}], ${name} - final result: condition matching`);
|
|
666
1021
|
return true;
|
|
667
|
-
} else {
|
|
668
|
-
if (!inverse) this.adapter.log.debug(`Trigger [${this.triggerName}], ${name} - final result: *not* matching conditions: ${notMetConditionNames.toString()}`);
|
|
669
|
-
if (inverse) this.adapter.log.debug(`Trigger [${this.triggerName}], ${name} - final result: *not* matching conditions`); // to avoid empty 'notMetConditionNames'
|
|
670
|
-
return false;
|
|
671
1022
|
}
|
|
672
|
-
|
|
1023
|
+
if (!inverse) {
|
|
1024
|
+
this.adapter.log.debug(
|
|
1025
|
+
`Trigger [${this.triggerName}], ${name} - final result: *not* matching conditions: ${notMetConditionNames.toString()}`,
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
if (inverse) {
|
|
1029
|
+
this.adapter.log.debug(
|
|
1030
|
+
`Trigger [${this.triggerName}], ${name} - final result: *not* matching conditions`,
|
|
1031
|
+
);
|
|
1032
|
+
} // to avoid empty 'notMetConditionNames'
|
|
1033
|
+
return false;
|
|
673
1034
|
} catch (error) {
|
|
674
1035
|
this.adapter.x.helper.dumpError('[asyncAreScheduleConditionsMet()]', error);
|
|
675
1036
|
return false;
|
|
676
1037
|
}
|
|
677
|
-
|
|
678
1038
|
}
|
|
679
1039
|
|
|
680
1040
|
/**
|
|
681
1041
|
* Set/update zoneNames and zoneTargetNames.
|
|
682
1042
|
* Call once a trigger that was triggered
|
|
683
|
-
*
|
|
1043
|
+
*
|
|
1044
|
+
* @returns {Promise<boolean>} true if successful, false if errors
|
|
684
1045
|
*/
|
|
685
1046
|
async _asyncUpdateCurrentActiveZones() {
|
|
686
|
-
|
|
687
1047
|
try {
|
|
688
|
-
|
|
689
1048
|
/**
|
|
690
1049
|
* Get zone names, and zone-specific target names and execution
|
|
691
1050
|
* Loop next iteration, if not successful.
|
|
692
1051
|
*/
|
|
693
1052
|
|
|
694
|
-
this.zoneNames =
|
|
695
|
-
this.zoneTargetNames = {};
|
|
1053
|
+
this.zoneNames = []; // Zone names that were triggered and which match with a schedule row name
|
|
1054
|
+
this.zoneTargetNames = {}; // Target devices per zone, like {Hallway:['Hallway Light'], Bath:['Bath Light', 'Bath Radio']}
|
|
696
1055
|
|
|
697
1056
|
for (const lpRowZones of this.adapter.config.tableZones) {
|
|
698
|
-
|
|
699
1057
|
// Loop next if item in table "Zones" is not containing any trigger name in column triggers
|
|
700
|
-
if (!(
|
|
1058
|
+
if (!(
|
|
1059
|
+
lpRowZones.active &&
|
|
1060
|
+
lpRowZones.triggers &&
|
|
1061
|
+
Array.isArray(lpRowZones.triggers) &&
|
|
1062
|
+
lpRowZones.triggers.includes(this.triggerName)
|
|
1063
|
+
)) {
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
701
1066
|
|
|
702
1067
|
// Add target devices
|
|
703
1068
|
this.zoneTargetNames[lpRowZones.name] = lpRowZones.targets;
|
|
704
1069
|
|
|
705
1070
|
// Execution options
|
|
706
1071
|
//const executeAlways = this.adapter.config.execution[lpRowZones.name].executeAlways;
|
|
707
|
-
const executeAlways =
|
|
1072
|
+
const executeAlways = lpRowZones.executeAlways ? true : false;
|
|
708
1073
|
let tablesZoneExecution = [];
|
|
709
1074
|
if (executeAlways) {
|
|
710
1075
|
// we create a dummy to always execute
|
|
711
|
-
tablesZoneExecution = [
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
1076
|
+
tablesZoneExecution = [
|
|
1077
|
+
{
|
|
1078
|
+
active: true,
|
|
1079
|
+
executeAlways: true, // This is a "dummy" key, so that we know to always execute
|
|
1080
|
+
},
|
|
1081
|
+
];
|
|
715
1082
|
} else {
|
|
716
|
-
tablesZoneExecution =
|
|
1083
|
+
tablesZoneExecution = lpRowZones.executionJson ? JSON.parse(lpRowZones.executionJson) : [];
|
|
717
1084
|
}
|
|
718
1085
|
|
|
719
1086
|
for (const lpRow of tablesZoneExecution) {
|
|
720
|
-
|
|
721
1087
|
if (lpRow.active) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
1088
|
+
const doContinue = await this._asyncDoesExecutionRowMatch(lpRowZones, lpRow);
|
|
1089
|
+
if (doContinue) {
|
|
1090
|
+
this.adapter.log.debug(
|
|
1091
|
+
`Trigger [${this.triggerName}] Zone '${lpRowZones.name}' - execution table row *is* meeting conditions`,
|
|
1092
|
+
);
|
|
727
1093
|
this.zoneNames.push(lpRowZones.name);
|
|
728
1094
|
} else {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
let doContinue = true; // flag if we can continue.
|
|
733
|
-
|
|
734
|
-
// First – check if current time is within the schedule times
|
|
735
|
-
if (doContinue) doContinue = this.adapter.x.helper.scheduleIsTimeStampWithinPeriod(tsCurrent, lpRow.start, lpRow.end, lpRowZones.name);
|
|
736
|
-
|
|
737
|
-
// Next, check if current day is within the mon-sun options as set in schedules tables.
|
|
738
|
-
if (doContinue) doContinue = this.adapter.x.helper.scheduleIsWeekdayMatching(lpRow, tsCurrent, lpRowZones.name);
|
|
739
|
-
|
|
740
|
-
// Next, check additional conditions (like Public Holiday, etc. -- as set in conditions table)
|
|
741
|
-
if (doContinue) doContinue = await this.asyncAreScheduleConditionsMet('Zone Execution: Additional Conditions', lpRow.additionalConditions, lpRow.additionalConditionsAll);
|
|
742
|
-
|
|
743
|
-
// Next, check conditions "Never if"
|
|
744
|
-
if (doContinue) doContinue = await this.asyncAreScheduleConditionsMet('Zone Execution: "never if" Conditions', lpRow.never, lpRow.neverAll, true);
|
|
745
|
-
|
|
746
|
-
// All checks done.
|
|
747
|
-
if (doContinue) {
|
|
748
|
-
this.adapter.log.debug(`Trigger [${this.triggerName}] Zone '${lpRowZones.name}' - execution table row *is* meeting conditions`);
|
|
749
|
-
/* isHit == true; */
|
|
750
|
-
this.zoneNames.push(lpRowZones.name); // set matching zone name
|
|
751
|
-
} else {
|
|
752
|
-
this.adapter.log.debug(`Trigger [${this.triggerName}] Zone '${lpRowZones.name}' - execution table row is *not* meeting conditions`);
|
|
753
|
-
}
|
|
1095
|
+
this.adapter.log.debug(
|
|
1096
|
+
`Trigger [${this.triggerName}] Zone '${lpRowZones.name}' - execution table row is *not* meeting conditions`,
|
|
1097
|
+
);
|
|
754
1098
|
}
|
|
755
|
-
|
|
756
1099
|
}
|
|
757
|
-
|
|
758
1100
|
}
|
|
759
|
-
|
|
760
1101
|
}
|
|
761
1102
|
|
|
762
|
-
if (
|
|
763
|
-
this.adapter.
|
|
1103
|
+
if (
|
|
1104
|
+
this.adapter.x.helper.isLikeEmpty(this.zoneNames) ||
|
|
1105
|
+
this.adapter.x.helper.isLikeEmpty(this.zoneTargetNames)
|
|
1106
|
+
) {
|
|
1107
|
+
this.adapter.log.debug(
|
|
1108
|
+
`Trigger [${this.triggerName}] Zone(s) will not be activated since no zone found which meets all conditions.`,
|
|
1109
|
+
);
|
|
764
1110
|
return false;
|
|
765
|
-
} else {
|
|
766
|
-
this.adapter.log.debug(`Trigger [${this.triggerName}] - (${this.zoneNames.length}) rows in Zones table found and assigned execution table rows fetched successfully.`);
|
|
767
|
-
return true;
|
|
768
1111
|
}
|
|
769
|
-
|
|
770
|
-
|
|
1112
|
+
this.adapter.log.debug(
|
|
1113
|
+
`Trigger [${this.triggerName}] - (${this.zoneNames.length}) rows in Zones table found and assigned execution table rows fetched successfully.`,
|
|
1114
|
+
);
|
|
1115
|
+
return true;
|
|
771
1116
|
} catch (error) {
|
|
772
1117
|
this.adapter.x.helper.dumpError('[_asyncUpdateCurrentActiveZones]', error);
|
|
773
1118
|
return false;
|
|
774
1119
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
1120
|
}
|
|
778
1121
|
|
|
779
|
-
|
|
780
1122
|
/**
|
|
781
1123
|
* @param {string} zoneName - Name of zone
|
|
782
1124
|
* @param {string} timerTitle - For logging only.
|
|
@@ -784,15 +1126,20 @@ class Trigger {
|
|
|
784
1126
|
* @param {number} secTimer - Number of seconds of the timer, that was set and now expired. For logging only.
|
|
785
1127
|
*/
|
|
786
1128
|
async _asyncSetZoneTimer_doOnTimeout(zoneName, timerTitle, targets, secTimer) {
|
|
787
|
-
|
|
788
1129
|
try {
|
|
789
|
-
|
|
790
1130
|
// First check if tableZones 'Never switch off if...' is met
|
|
791
1131
|
const neverOffConditionNames = this.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'neverOff');
|
|
792
1132
|
const allMustMeet = this.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'neverOffAll');
|
|
793
|
-
const switchOff = await this.asyncAreScheduleConditionsMet(
|
|
1133
|
+
const switchOff = await this.asyncAreScheduleConditionsMet(
|
|
1134
|
+
'Zones table - "never switch off if" condition',
|
|
1135
|
+
neverOffConditionNames,
|
|
1136
|
+
allMustMeet,
|
|
1137
|
+
true,
|
|
1138
|
+
);
|
|
794
1139
|
if (!switchOff) {
|
|
795
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
1140
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
1141
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': Timer '${timerTitle}' ended, but 'Never switch off if...' condition(s) true --> Zone will not be switched off.`,
|
|
1142
|
+
);
|
|
796
1143
|
return; // go out
|
|
797
1144
|
}
|
|
798
1145
|
|
|
@@ -800,118 +1147,116 @@ class Trigger {
|
|
|
800
1147
|
const timerObjIds = ['timersZoneOff', 'timersMimicMotionTrigger'];
|
|
801
1148
|
for (const lpTimerObjId of timerObjIds) {
|
|
802
1149
|
const lpTimeLeft = this.adapter.x.helper.getTimeoutTimeLeft(this.adapter.x[lpTimerObjId][zoneName]);
|
|
803
|
-
if (this.triggerIsMotion &&
|
|
804
|
-
clearTimeout(this.adapter.x[lpTimerObjId][zoneName]);
|
|
1150
|
+
if (this.triggerIsMotion && lpTimeLeft > -1) {
|
|
1151
|
+
this.adapter.clearTimeout(this.adapter.x[lpTimerObjId][zoneName]);
|
|
805
1152
|
this.adapter.x[lpTimerObjId][zoneName] = null;
|
|
806
|
-
this.adapter.log.debug(
|
|
1153
|
+
this.adapter.log.debug(
|
|
1154
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': Clearing timer '${lpTimerObjId}', which was still running for ${(lpTimeLeft / 1000).toFixed(0)} seconds.`,
|
|
1155
|
+
);
|
|
807
1156
|
}
|
|
808
1157
|
}
|
|
809
|
-
|
|
810
1158
|
|
|
811
1159
|
/* ================== START -- RESOLVING ISSUE #45 (https://github.com/Mic-M/ioBroker.smartcontrol/issues/45) */
|
|
812
1160
|
|
|
813
1161
|
/**
|
|
814
|
-
* Verify if there are other motion sensors in the same zone.
|
|
1162
|
+
* Verify if there are other motion sensors in the same zone.
|
|
815
1163
|
* If yes and if a motion detection of one of these is still true: do not switch off zone.
|
|
816
1164
|
*/
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
// Get all other motion triggers assigned to zone
|
|
825
|
-
const confZoneOtherTriggersMotion = [];
|
|
826
|
-
const confZoneTriggersAll = this.adapter.getOptionTableValue('tableZones', 'name', zoneName, 'triggers');
|
|
827
|
-
for (const lpTriggerName of confZoneTriggersAll) {
|
|
828
|
-
if (allMotionNames.includes(lpTriggerName)) {
|
|
829
|
-
if (lpTriggerName !== this.triggerName) {
|
|
830
|
-
// we have an additional motion sensor trigger
|
|
831
|
-
confZoneOtherTriggersMotion.push(lpTriggerName);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// Now check if motion state of any other motion timer is still true
|
|
837
|
-
if (confZoneOtherTriggersMotion.length > 0) {
|
|
838
|
-
for (const lpName of confZoneOtherTriggersMotion) {
|
|
839
|
-
const lpMotionObjId = this.adapter.getOptionTableValue('tableTriggerMotion', 'name', lpName, 'stateId');
|
|
840
|
-
const lpMotionObj = await this.adapter.x.helper.asyncGetForeignStateValue(lpMotionObjId);
|
|
841
|
-
if (lpMotionObj == true) {
|
|
842
|
-
// We have another motion sensor in same zone with motion=true, so go out.
|
|
843
|
-
this.adapter.x.helper.logExtendedInfo(`Trigger [${this.triggerName}] Zone '${zoneName}': Timer '${timerTitle}' ended, but another motion sensor '${lpName}' state value assigned to this zone is still true, so we will not switch off zone.' `);
|
|
844
|
-
return; // go out
|
|
845
|
-
}
|
|
846
|
-
}
|
|
1165
|
+
const otherMotionTrueName = await this._asyncGetOtherMotionTrueName(zoneName);
|
|
1166
|
+
if (otherMotionTrueName) {
|
|
1167
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
1168
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': Timer '${timerTitle}' ended, but another motion sensor '${otherMotionTrueName}' state value assigned to this zone is still true, so we will not switch off zone.' `,
|
|
1169
|
+
);
|
|
1170
|
+
return; // go out
|
|
847
1171
|
}
|
|
848
1172
|
|
|
849
1173
|
/* ================== END -- RESOLVING ISSUE #45 (https://github.com/Mic-M/ioBroker.smartcontrol/issues/45) */
|
|
850
1174
|
|
|
851
|
-
|
|
852
1175
|
// Set "is Zone on" status to false
|
|
853
1176
|
this.adapter.x.zonesIsOn[zoneName] = false;
|
|
854
1177
|
|
|
855
1178
|
// Clear timer 'timersZoneOn'
|
|
856
|
-
clearTimeout(this.adapter.x.timersZoneOn[zoneName]);
|
|
1179
|
+
this.adapter.clearTimeout(this.adapter.x.timersZoneOn[zoneName]);
|
|
857
1180
|
this.adapter.x.timersZoneOn[zoneName] = null;
|
|
858
1181
|
|
|
859
1182
|
const lTargetDevicesSwitchedOff = []; // For Log
|
|
860
1183
|
const lManualOnDevices = []; // For log
|
|
861
1184
|
for (let i = 0; i < targets.statePaths.length; i++) {
|
|
862
|
-
|
|
863
1185
|
// All are having same length and association per each element
|
|
864
1186
|
const lpStatePath = targets.statePaths[i];
|
|
865
1187
|
const lpStateValToSet = targets.stateValues[i];
|
|
866
1188
|
const lpTargetName = targets.deviceNames[i];
|
|
867
1189
|
|
|
868
1190
|
// Remove from this.adapter.x.motionTriggeredDevices
|
|
869
|
-
if (this.motionNotIfManual)
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
this.adapter.log.error(`Timer '${timerTitle}', trigger '${this.triggerName}', target ${lpTargetName}: - Timeout of '${secTimer}' seconds reached, but could not get current state value of '${lpStatePath}', so unable to turn device off.`);
|
|
875
|
-
continue;
|
|
1191
|
+
if (this.motionNotIfManual) {
|
|
1192
|
+
this.adapter.x.motionTriggeredDevices = this.adapter.x.helper.arrayRemoveElementByValue(
|
|
1193
|
+
this.adapter.x.motionTriggeredDevices,
|
|
1194
|
+
lpTargetName,
|
|
1195
|
+
);
|
|
876
1196
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1197
|
+
|
|
1198
|
+
// „Prüfung deaktiv. (aus)“: bei Buttons immer schreiben, auch wenn der Wert schon passt (#7).
|
|
1199
|
+
// Beim Einschalten macht switchTargetDeviceAsync das schon; der Aus-Timer hat das bisher ignoriert.
|
|
1200
|
+
const doNotCheckTargetOff = this.adapter.getOptionTableValue(
|
|
1201
|
+
'tableTargetDevices',
|
|
1202
|
+
'name',
|
|
1203
|
+
lpTargetName,
|
|
1204
|
+
'noTargetOffCheck',
|
|
1205
|
+
);
|
|
1206
|
+
if (!doNotCheckTargetOff) {
|
|
1207
|
+
const targetOffStateValCurrent = await this.adapter.x.helper.asyncGetForeignStateValue(lpStatePath);
|
|
1208
|
+
if (targetOffStateValCurrent == null) {
|
|
1209
|
+
this.adapter.log.error(
|
|
1210
|
+
`Timer '${timerTitle}', trigger '${this.triggerName}', target ${lpTargetName}: - Timeout of '${secTimer}' seconds reached, but could not get current state value of '${lpStatePath}', so unable to turn device off.`,
|
|
1211
|
+
);
|
|
1212
|
+
continue;
|
|
1213
|
+
}
|
|
1214
|
+
if (lpStateValToSet == targetOffStateValCurrent) {
|
|
1215
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
1216
|
+
`Trigger [${this.triggerName}] Timer '${timerTitle}', target ${lpTargetName}: - Timeout of '${secTimer}' seconds reached, target is already turned off, so not turning off again.`,
|
|
1217
|
+
);
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
880
1220
|
}
|
|
881
1221
|
|
|
882
1222
|
// All passed.
|
|
883
1223
|
await this.adapter.setForeignStateAsync(lpStatePath, { val: lpStateValToSet, ack: false });
|
|
884
1224
|
lTargetDevicesSwitchedOff.push(lpTargetName);
|
|
885
|
-
|
|
886
1225
|
}
|
|
887
1226
|
|
|
888
1227
|
// Log
|
|
889
1228
|
if (lManualOnDevices.length > 0) {
|
|
890
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
1229
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
1230
|
+
`Trigger [${this.triggerName}] Timer '${timerTitle}', target(s) '${lManualOnDevices.toString()}': - Timeout of '${secTimer}' seconds reached, target(s) manually turned on while timer was running, so do not turn off.`,
|
|
1231
|
+
);
|
|
891
1232
|
}
|
|
892
1233
|
if (lTargetDevicesSwitchedOff.length > 0) {
|
|
893
|
-
this.adapter.x.helper.logExtendedInfo(
|
|
1234
|
+
this.adapter.x.helper.logExtendedInfo(
|
|
1235
|
+
`Trigger [${this.triggerName}] Timer '${timerTitle}', target(s) '${lTargetDevicesSwitchedOff.toString()}': - Turned off per ${secTimer}s timer.`,
|
|
1236
|
+
);
|
|
894
1237
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
1238
|
} catch (error) {
|
|
898
1239
|
this.adapter.x.helper.dumpError('[asyncSetZoneTimer_doOnTimeout]', error);
|
|
899
1240
|
return;
|
|
900
1241
|
}
|
|
901
|
-
|
|
902
1242
|
}
|
|
903
1243
|
|
|
904
1244
|
/**
|
|
905
|
-
* Get target device info for a given zone name.
|
|
1245
|
+
* Get target device info for a given zone name.
|
|
1246
|
+
*
|
|
906
1247
|
* @param {string} zoneName - Zone Name
|
|
907
|
-
* @
|
|
1248
|
+
* @returns {Promise<object|null>} - Object: {statePaths:[Array of state paths], stateValues: [Array of state values], deviceNames: [Array of device names]}. null if not found/errors.
|
|
908
1249
|
*/
|
|
909
1250
|
async _asyncGetTargetDevicesInfoOfZone(zoneName) {
|
|
910
|
-
|
|
911
1251
|
try {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
this.
|
|
1252
|
+
if (
|
|
1253
|
+
!this.zoneTargetNames ||
|
|
1254
|
+
!this.zoneTargetNames[zoneName] ||
|
|
1255
|
+
this.adapter.x.helper.isLikeEmpty(this.zoneTargetNames[zoneName])
|
|
1256
|
+
) {
|
|
1257
|
+
this.adapter.log.debug(
|
|
1258
|
+
`Trigger [${this.triggerName}] Zone '${zoneName}': No current target devices found for timer to switch devices off, likely because all were turned on manually before`,
|
|
1259
|
+
);
|
|
915
1260
|
return null;
|
|
916
1261
|
}
|
|
917
1262
|
const targetDevices = this.zoneTargetNames[zoneName];
|
|
@@ -919,18 +1264,28 @@ class Trigger {
|
|
|
919
1264
|
|
|
920
1265
|
// Get all target device state paths and values
|
|
921
1266
|
const targets = {
|
|
922
|
-
statePaths:
|
|
923
|
-
stateValues:
|
|
924
|
-
deviceNames:
|
|
1267
|
+
statePaths: [], // Would use [] instead of Array(), but see: https://stackoverflow.com/a/56394664
|
|
1268
|
+
stateValues: [],
|
|
1269
|
+
deviceNames: [],
|
|
925
1270
|
};
|
|
926
1271
|
|
|
927
1272
|
for (const lpTargetName of targetDevices) {
|
|
928
1273
|
// Get target device information
|
|
929
|
-
const targetOffState = this.adapter.getOptionTableValue(
|
|
930
|
-
|
|
1274
|
+
const targetOffState = this.adapter.getOptionTableValue(
|
|
1275
|
+
'tableTargetDevices',
|
|
1276
|
+
'name',
|
|
1277
|
+
lpTargetName,
|
|
1278
|
+
'offState',
|
|
1279
|
+
);
|
|
1280
|
+
const targetOffVal = this.adapter.getOptionTableValue(
|
|
1281
|
+
'tableTargetDevices',
|
|
1282
|
+
'name',
|
|
1283
|
+
lpTargetName,
|
|
1284
|
+
'offValue',
|
|
1285
|
+
);
|
|
931
1286
|
|
|
932
1287
|
if (targetOffState == undefined || targetOffVal == undefined) {
|
|
933
|
-
throw
|
|
1288
|
+
throw `Unable to retrieve target off state/value for target device '${lpTargetName}' from adapter config.`;
|
|
934
1289
|
}
|
|
935
1290
|
|
|
936
1291
|
// Target Off State
|
|
@@ -947,19 +1302,14 @@ class Trigger {
|
|
|
947
1302
|
|
|
948
1303
|
// Go out if we actually have no devices to turn off
|
|
949
1304
|
if (this.adapter.x.helper.isLikeEmpty(targets.statePaths)) {
|
|
950
|
-
throw
|
|
1305
|
+
throw `Zone '${zoneName}': --> No target states found in adapter settings, so no timer will be set to turn off.`;
|
|
951
1306
|
}
|
|
952
1307
|
|
|
953
1308
|
return targets;
|
|
954
|
-
|
|
955
1309
|
} catch (error) {
|
|
956
1310
|
this.adapter.x.helper.dumpError(`[asyncGetTargetDevicesInfoOfZone]`, error);
|
|
957
1311
|
return null;
|
|
958
1312
|
}
|
|
959
|
-
|
|
960
1313
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
1314
|
}
|
|
965
|
-
module.exports = Trigger;
|
|
1315
|
+
module.exports = Trigger;
|