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.
Files changed (110) hide show
  1. package/LICENSE +2 -0
  2. package/README.md +41 -266
  3. package/admin/custom/assets/Components-CDPYnOs-.js +77 -0
  4. package/admin/custom/assets/Components-DpQjIfuo.js +1 -0
  5. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__SmartcontrolSet__mf_owner__1-C9SdP7_s.js +1 -0
  6. 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
  7. package/admin/custom/assets/_virtual_mf___mfe_internal__SmartcontrolSet__mf_owner__108197177487852__loadShare__shared-4MdeZwge.js +2 -0
  8. 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
  9. 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
  10. package/admin/custom/assets/dist-Cnxr-ruU.js +1 -0
  11. package/admin/custom/assets/helpers-CNHzo155.js +1 -0
  12. package/admin/custom/assets/hostInit-BVoHSU7s.js +1 -0
  13. package/admin/custom/assets/iconLibraryData-B5fiyl1C.js +1 -0
  14. package/admin/custom/assets/index-CwC_q7vn.js +1 -0
  15. package/admin/custom/assets/lib-CgOpGT17.js +3 -0
  16. package/admin/custom/assets/mf-entry-bootstrap-0-6167c687.js +54 -0
  17. package/admin/custom/assets/pendingShares-CEz9fejL.js +2 -0
  18. package/admin/custom/assets/prod-XWAlCKxB.js +492 -0
  19. package/admin/custom/assets/rolldown-runtime-9C0vUP4u.js +1 -0
  20. package/admin/custom/assets/utils-DmVoYT7i.js +4 -0
  21. package/admin/custom/assets/vite-preload-helper-nldAWQd6.js +1 -0
  22. package/admin/custom/customComponents.js +12 -0
  23. package/admin/custom/i18n/de.json +59 -0
  24. package/admin/custom/i18n/en.json +59 -0
  25. package/admin/custom/mf-manifest.json +1 -0
  26. package/admin/doc-md/readme.txt +2 -6
  27. package/admin/doc-md/start_de.md +34 -89
  28. package/admin/doc-md/start_en.md +33 -90
  29. package/admin/doc-md/table-conditions_de.md +7 -9
  30. package/admin/doc-md/table-conditions_en.md +7 -9
  31. package/admin/doc-md/table-execution_de.md +11 -10
  32. package/admin/doc-md/table-execution_en.md +12 -11
  33. package/admin/doc-md/table-options_de.md +58 -0
  34. package/admin/doc-md/table-options_en.md +58 -0
  35. package/admin/doc-md/table-target-devices_de.md +20 -16
  36. package/admin/doc-md/table-target-devices_en.md +18 -16
  37. package/admin/doc-md/table-target-enums_de.md +13 -13
  38. package/admin/doc-md/table-target-enums_en.md +12 -14
  39. package/admin/doc-md/table-target-url_de.md +14 -25
  40. package/admin/doc-md/table-target-url_en.md +14 -23
  41. package/admin/doc-md/table-trigger-devices_de.md +10 -11
  42. package/admin/doc-md/table-trigger-devices_en.md +10 -10
  43. package/admin/doc-md/table-trigger-motion_de.md +41 -24
  44. package/admin/doc-md/table-trigger-motion_en.md +35 -19
  45. package/admin/doc-md/table-trigger-times_de.md +11 -12
  46. package/admin/doc-md/table-trigger-times_en.md +11 -11
  47. package/admin/doc-md/table-zones_de.md +19 -14
  48. package/admin/doc-md/table-zones_en.md +19 -14
  49. package/admin/doc-md/table-zones_select-targets_de.md +7 -15
  50. package/admin/doc-md/table-zones_select-targets_en.md +7 -15
  51. package/admin/i18n/{de/translations.json → de.json} +2 -1
  52. package/admin/i18n/{en/translations.json → en.json} +3 -1
  53. package/admin/i18n/{es/translations.json → es.json} +2 -1
  54. package/admin/i18n/{fr/translations.json → fr.json} +2 -1
  55. package/admin/i18n/{it/translations.json → it.json} +2 -1
  56. package/admin/i18n/{nl/translations.json → nl.json} +2 -1
  57. package/admin/i18n/{pl/translations.json → pl.json} +2 -1
  58. package/admin/i18n/{pt/translations.json → pt.json} +2 -1
  59. package/admin/i18n/{ru/translations.json → ru.json} +2 -1
  60. package/admin/i18n/uk.json +110 -0
  61. package/admin/i18n/{zh-cn/translations.json → zh-cn.json} +2 -1
  62. package/admin/img/option-screenshots/tab-conditions.png +0 -0
  63. package/admin/img/option-screenshots/tab-further-options.png +0 -0
  64. package/admin/img/option-screenshots/tab-start.png +0 -0
  65. package/admin/img/option-screenshots/tab-target-devices.png +0 -0
  66. package/admin/img/option-screenshots/tab-triggers-motion.png +0 -0
  67. package/admin/img/option-screenshots/tab-triggers-other.png +0 -0
  68. package/admin/img/option-screenshots/tab-triggers-time.png +0 -0
  69. package/admin/img/option-screenshots/tab-zones-execution.png +0 -0
  70. package/admin/img/option-screenshots/tab-zones.png +0 -0
  71. package/admin/jsonConfig.json5 +524 -0
  72. package/io-package.json +46 -31
  73. package/lib/boolean-value.js +30 -0
  74. package/lib/constants.js +299 -65
  75. package/lib/cron-schedule.js +59 -0
  76. package/lib/helper.js +416 -375
  77. package/lib/midnight-reschedule.js +31 -0
  78. package/lib/motion-zone-timer.js +55 -0
  79. package/lib/num-comparator.js +70 -0
  80. package/lib/tools.js +12 -6
  81. package/lib/trigger-class.js +661 -311
  82. package/lib/trigger-match.js +76 -0
  83. package/main.js +1040 -652
  84. package/package.json +30 -38
  85. package/admin/admin.d.ts +0 -4
  86. package/admin/doc-md/img/start_dropdown-ani.gif +0 -0
  87. package/admin/doc-md/img/start_open-dialog.png +0 -0
  88. package/admin/doc-md/img/start_show-explanation.gif +0 -0
  89. package/admin/doc-md/img/table-zones_select-target-devices-overwrite.gif +0 -0
  90. package/admin/fancytree/skin-lion/icons-rtl.gif +0 -0
  91. package/admin/fancytree/skin-lion/icons.gif +0 -0
  92. package/admin/fancytree/skin-lion/loading.gif +0 -0
  93. package/admin/fancytree/skin-lion/ui.fancytree.min.css +0 -6
  94. package/admin/fancytree/skin-lion/vline-rtl.gif +0 -0
  95. package/admin/fancytree/skin-lion/vline.gif +0 -0
  96. package/admin/img/info-big.png +0 -0
  97. package/admin/img/info-big.png_README.txt +0 -6
  98. package/admin/img/sc_always.png +0 -0
  99. package/admin/img/select-target-devices-overwrite.gif +0 -0
  100. package/admin/img/smartControl_options1.gif +0 -0
  101. package/admin/img/smartControl_options_dropdown.gif +0 -0
  102. package/admin/img/smartControl_options_dropdown_2.gif +0 -0
  103. package/admin/index_m.html +0 -812
  104. package/admin/index_m.js +0 -1455
  105. package/admin/style.css +0 -187
  106. package/admin/tsconfig.json +0 -49
  107. package/admin/words.js +0 -113
  108. package/admin/zero-md/readme.txt +0 -1
  109. package/admin/zero-md/webcomponents-loader.min.js +0 -9
  110. package/admin/zero-md/zero-md.min.js.js +0 -9
package/lib/helper.js CHANGED
@@ -1,47 +1,53 @@
1
- /* eslint-disable no-irregular-whitespace */
2
1
  'use strict';
3
2
 
3
+ const nodeTimers = require('node:timers');
4
+
4
5
  /**
5
- * @desc Generic Helper Functions
6
+ * @param adapter
7
+ * @description Generic Helper Functions
6
8
  * @author Mic-M <https://github.com/Mic-M/ioBroker.smartcontrol>
7
9
  * @license MIT
8
10
  */
9
11
  module.exports = function (adapter) {
10
-
11
12
  return {
12
-
13
-
14
13
  /**
15
14
  * Create States, either under adapter instance or anywhere.
16
15
  * TODO: Better error handling (callback: function (err, _obj) ) for set(Foreign)ObjectNotExistsAsync and set(Foreign)StateAsync
17
- *
18
- * @param {object|array} statesToCreate Object like {statePath:'0_userdata.0.motionHallway', commonObject:{name:'Motion', type:'boolean', read:true, write:true, role:'state', def:false }
16
+ *
17
+ * @param {object | Array} statesToCreate Object like {statePath:'0_userdata.0.motionHallway', commonObject:{name:'Motion', type:'boolean', read:true, write:true, role:'state', def:false }
19
18
  * You can pass multiple objects via array of these objects.
20
- * @param {boolean} [isForeign=false] False: creates states under adapter instance, if true: creates states anywhere.
19
+ * @param {boolean} [isForeign] False: creates states under adapter instance, if true: creates states anywhere.
21
20
  * WARN: use the "true" flag carefully!
22
- * @return {Promise<boolean>} false if errors caught, otherwise true.
21
+ * @returns {Promise<boolean>} false if errors caught, otherwise true.
23
22
  */
24
- async asyncCreateStates(statesToCreate, isForeign=false) {
25
-
23
+ async asyncCreateStates(statesToCreate, isForeign = false) {
26
24
  try {
27
-
28
25
  // Convert to array if it is an object, since we allow both
29
- if(!Array.isArray(statesToCreate)) statesToCreate = [statesToCreate];
26
+ if (!Array.isArray(statesToCreate)) {
27
+ statesToCreate = [statesToCreate];
28
+ }
30
29
 
31
30
  for (const lpStateToCreate of statesToCreate) {
32
-
33
31
  // Check parameters
34
32
  if (!lpStateToCreate.statePath || !lpStateToCreate.commonObject) {
35
33
  adapter.log.error(`asyncCreateForeignStates(): invalid parameter provided to function`);
36
34
  return false;
37
35
  }
38
36
 
39
- // Create new state.
37
+ // Create new state.
40
38
  // While set(Foreign)ObjectNotExistsAsync takes care if state does not exist, we still check as we also set values afterwards.
41
- if (isForeign && ! await this.asyncObjectExists(lpStateToCreate.statePath, true)) {
42
- await adapter.setForeignObjectNotExistsAsync(lpStateToCreate.statePath, {type:'state', common:lpStateToCreate.commonObject, native: {}});
43
- } else if(!isForeign && ! await this.asyncObjectExists(lpStateToCreate.statePath, false)) {
44
- await adapter.setObjectNotExistsAsync(lpStateToCreate.statePath, {type:'state', common:lpStateToCreate.commonObject, native: {}});
39
+ if (isForeign && !(await this.asyncObjectExists(lpStateToCreate.statePath, true))) {
40
+ await adapter.setForeignObjectNotExistsAsync(lpStateToCreate.statePath, {
41
+ type: 'state',
42
+ common: lpStateToCreate.commonObject,
43
+ native: {},
44
+ });
45
+ } else if (!isForeign && !(await this.asyncObjectExists(lpStateToCreate.statePath, false))) {
46
+ await adapter.setObjectNotExistsAsync(lpStateToCreate.statePath, {
47
+ type: 'state',
48
+ common: lpStateToCreate.commonObject,
49
+ native: {},
50
+ });
45
51
  } else {
46
52
  // State already exists.
47
53
  continue;
@@ -54,39 +60,47 @@ module.exports = function (adapter) {
54
60
  if (def !== undefined) {
55
61
  initialDefault = def;
56
62
  } else {
57
- if(type === 'number') initialDefault = 0;
58
- if(type === 'boolean') initialDefault = false;
59
- if(type === 'string') initialDefault = '';
60
- if(type === 'array') initialDefault = [];
61
- if(type === 'object') initialDefault = {};
62
- }
63
+ if (type === 'number') {
64
+ initialDefault = 0;
65
+ }
66
+ if (type === 'boolean') {
67
+ initialDefault = false;
68
+ }
69
+ if (type === 'string') {
70
+ initialDefault = '';
71
+ }
72
+ if (type === 'array') {
73
+ initialDefault = [];
74
+ }
75
+ if (type === 'object') {
76
+ initialDefault = {};
77
+ }
78
+ }
79
+ // Default nach create ist Adapter-Wert, nicht Nutzer-Befehl.
80
+ // write:false (z. B. options.*.name) + ack:false -> js-controller-Warnung.
63
81
  if (isForeign) {
64
- await adapter.setForeignStateAsync(lpStateToCreate.statePath, initialDefault, false);
82
+ await adapter.setForeignStateAsync(lpStateToCreate.statePath, initialDefault, true);
65
83
  } else {
66
- await adapter.setStateAsync(lpStateToCreate.statePath, initialDefault, false);
67
- }
84
+ await adapter.setStateAsync(lpStateToCreate.statePath, initialDefault, true);
85
+ }
68
86
  adapter.log.debug(`State '${lpStateToCreate.statePath}' created.`);
69
-
70
87
  }
71
88
 
72
89
  return true;
73
-
74
-
75
90
  } catch (error) {
76
91
  this.dumpError('[asyncCreateForeignStates()]', error);
77
92
  return false;
78
93
  }
79
-
80
94
  },
81
95
 
82
- /**
96
+ /**
83
97
  * Check if an ioBroker object exists.
98
+ *
84
99
  * @param {string} str State path
85
- * @param {boolean} [isForeign=false] true if a foreign state, false if a state of this adapter
86
- * @return {Promise<boolean>}
100
+ * @param {boolean} [isForeign] true if a foreign state, false if a state of this adapter
101
+ * @returns {Promise<boolean>}
87
102
  */
88
- async asyncObjectExists (str, isForeign=false) {
89
-
103
+ async asyncObjectExists(str, isForeign = false) {
90
104
  try {
91
105
  let ret;
92
106
  if (isForeign) {
@@ -94,65 +108,61 @@ module.exports = function (adapter) {
94
108
  } else {
95
109
  ret = await adapter.getObjectAsync(str);
96
110
  }
97
-
111
+
98
112
  if (ret == undefined) {
99
113
  return false;
100
- } else {
101
- return true;
102
114
  }
115
+ return true;
103
116
  } catch (error) {
104
117
  this.dumpError('[asyncObjectExists()]', error);
105
118
  return false;
106
119
  }
107
-
108
120
  },
109
121
 
110
122
  /**
111
123
  * Get foreign state value
112
- *
124
+ *
113
125
  * @param {string} statePath - Full path to state, like 0_userdata.0.other.isSummer
114
- * @return {Promise<*>} - State value, or null if error
126
+ * @returns {Promise<*>} - State value, or null if error
115
127
  */
116
128
  async asyncGetForeignStateValue(statePath) {
117
129
  try {
118
130
  const stateObject = await this.asyncGetForeignState(statePath);
119
- if (stateObject == null) return null; // error thrown already in asyncGetForeignState()
120
- return stateObject.val;
131
+ if (stateObject == null) {
132
+ return null;
133
+ } // error thrown already in asyncGetForeignState()
134
+ return stateObject.val;
121
135
  } catch (error) {
122
136
  this.dumpError(`[asyncGetForeignStateValue]`, error);
123
137
  return null;
124
138
  }
125
-
126
- },
139
+ },
127
140
 
128
141
  /**
129
142
  * Get foreign state
130
- *
143
+ *
131
144
  * @param {string} statePath - Full path to state, like 0_userdata.0.other.isSummer
132
- * @return {Promise<object>} - State object: {val: false, ack: true, ts: 1591117034451, …}, or null if error
145
+ * @returns {Promise<object>} - State object: {val: false, ack: true, ts: 1591117034451, …}, or null if error
133
146
  */
134
147
  async asyncGetForeignState(statePath) {
135
-
136
148
  try {
137
149
  // Check state existence
138
150
  const stateObject = await adapter.getForeignObjectAsync(statePath);
139
151
 
140
152
  if (!stateObject) {
141
- throw(`State '${statePath}' does not exist.`);
153
+ throw `State '${statePath}' does not exist.`;
142
154
  } else {
143
155
  // Get state value, so like: {val: false, ack: true, ts: 1591117034451, …}
144
156
  const stateValueObject = await adapter.getForeignStateAsync(statePath);
145
- if (! this.isLikeEmpty(stateValueObject)) {
157
+ if (!this.isLikeEmpty(stateValueObject)) {
146
158
  return stateValueObject;
147
- } else {
148
- throw(`Unable to retrieve info from state '${statePath}'.`);
149
159
  }
160
+ throw `Unable to retrieve info from state '${statePath}'.`;
150
161
  }
151
162
  } catch (error) {
152
163
  this.dumpError(`[asyncGetForeignState]`, error);
153
164
  return null;
154
165
  }
155
-
156
166
  },
157
167
 
158
168
  /**
@@ -160,30 +170,28 @@ module.exports = function (adapter) {
160
170
  * This function is needed since toISOString() uses UTC +0 (Zulu) as time zone.
161
171
  * https://stackoverflow.com/questions/10830357/
162
172
  * Mic-M, 04/Apr/2020
173
+ *
163
174
  * @param {object} date Date object
164
- * @return {string} string like "2015-01-26T06:40:36.181", without trailing Z (which would represent Zulu time zone)
175
+ * @returns {string} string like "2015-01-26T06:40:36.181", without trailing Z (which would represent Zulu time zone)
165
176
  */
166
177
  dateToLocalIsoString(date) {
167
178
  const timezoneOffset = date.getTimezoneOffset() * 60000; //offset in milliseconds
168
- return (new Date(date.getTime() - timezoneOffset)).toISOString().slice(0, -1);
179
+ return new Date(date.getTime() - timezoneOffset).toISOString().slice(0, -1);
169
180
  },
170
181
 
171
-
172
-
173
-
174
182
  /**
175
183
  * For given object of enum objects, get the names and associated ids.
176
184
  * enumObj.common.name can be either string like 'Living room' or {en:'Living room', de:'Wohnzimmer', ...}
185
+ *
177
186
  * @param {object} enumObj - object of multiple enum objects, so return of getEnumAsync('rooms').result or getEnumAsync('functions').result
178
- * @param {boolean} [allLanguages=false] if true, it will return all languages (in case user changes ioBroker language after saving options), if false, just the current language
179
- * @return {object|null} resulting object like {'Bathroom': 'enum.rooms.bathroom', 'Bedroom': 'enum.rooms.bedroom'}, or null if nothing found
187
+ * @param {boolean} [allLanguages] if true, it will return all languages (in case user changes ioBroker language after saving options), if false, just the current language
188
+ * @returns {object|null} resulting object like {'Bathroom': 'enum.rooms.bathroom', 'Bedroom': 'enum.rooms.bedroom'}, or null if nothing found
180
189
  */
181
- enumsGetNamesAndIds(enumObj, allLanguages=false) {
182
-
190
+ enumsGetNamesAndIds(enumObj, allLanguages = false) {
183
191
  try {
184
-
185
192
  const result = {};
186
- for (const id in enumObj) { // id = like 'enum.rooms.bathroom'
193
+ for (const id in enumObj) {
194
+ // id = like 'enum.rooms.bathroom'
187
195
  const nameObj = enumObj[id].common.name; // either string like 'Living room' or {en:'Living room', de:'Wohnzimmer', ...}
188
196
  if (typeof nameObj === 'string') {
189
197
  result[nameObj] = id;
@@ -195,23 +203,21 @@ module.exports = function (adapter) {
195
203
  } else {
196
204
  result[nameObj[adapter.x.systemConfig.language]] = id;
197
205
  }
198
-
199
206
  } else {
200
- adapter.log.warn(`Getting enum room name for '${id}': type for name must be string or object, but is '${typeof nameObj}'.`);
207
+ adapter.log.warn(
208
+ `Getting enum room name for '${id}': type for name must be string or object, but is '${typeof nameObj}'.`,
209
+ );
201
210
  }
202
211
  }
203
212
 
204
213
  if (!this.isLikeEmpty(result)) {
205
214
  return result;
206
- } else {
207
- return null;
208
215
  }
209
-
216
+ return null;
210
217
  } catch (error) {
211
218
  this.dumpError('[enumsGetNamesAndIds]', error);
212
219
  return null;
213
220
  }
214
-
215
221
  },
216
222
 
217
223
  /**
@@ -240,33 +246,31 @@ module.exports = function (adapter) {
240
246
  },
241
247
  */
242
248
 
243
-
244
-
245
-
246
249
  /**
247
250
  * Verify acknowledge (ack) once a state was changed.
248
- *
251
+ *
249
252
  * In General: Any state changes of states will be ignored, if acknowledge (ack) = false.
250
253
  * The reason is that adapters confirm states by the acknowledge "ack" flag (setting to true).
251
254
  * Reference: https://forum.iobroker.net/post/448606
252
- *
255
+ *
253
256
  * Exception 1: States under javascript.x/0_userdata.0/alias.x: For states created by users, this behavior can be changed in the adapter options.
254
257
  * Exception 2: States under smartcontrol.x.: ack:false only.
255
- * Exception 3: States which are not under a "real" adapter namespace, so like "Messwerte.0". Reason: Several users have created
258
+ * Exception 3: States which are not under a "real" adapter namespace, so like "Messwerte.0". Reason: Several users have created
256
259
  * own states in the object main tree, like "Messwerte.0". https://forum.iobroker.net/post/461189
257
- *
260
+ *
258
261
  * @param {string} statePath - State Path
259
262
  * @param {ioBroker.State|null|undefined} stateObject - State object
260
- * @return {Promise<object>} {passing: false; msg:'some message'}
263
+ * @returns {Promise<object>} {passing: false; msg:'some message'}
261
264
  * if state change shall be ignored due to the ack (or error occurred), otherwise true.
262
- *
263
265
  */
264
266
  async isAckPassing(statePath, stateObject) {
265
-
266
267
  try {
267
-
268
- if (!stateObject || !statePath)
269
- return {passing:false, msg:`Unexpected error: isAckPassing() was no valid statePath or stateObject provided.`};
268
+ if (!stateObject || !statePath) {
269
+ return {
270
+ passing: false,
271
+ msg: `Unexpected error: isAckPassing() was no valid statePath or stateObject provided.`,
272
+ };
273
+ }
270
274
 
271
275
  const namespace = `${statePath.split('.')[0]}.${statePath.split('.')[1]}`; // like sonos.1
272
276
 
@@ -275,107 +279,116 @@ module.exports = function (adapter) {
275
279
  // if (statePath.startsWith(`${adapter.namespace}.`)) {
276
280
  if (statePath.match(/^smartcontrol.\d+./)) {
277
281
  if (stateObject.ack == false) {
278
- return {passing:true, msg:`Adapter Instance State (${adapter.namespace}) requires ack:false`};
279
- } else {
280
- return {passing:false, msg:`Adapter Instance State (${adapter.namespace}) requires ack:false`};
282
+ return {
283
+ passing: true,
284
+ msg: `Adapter Instance State (${adapter.namespace}) requires ack:false`,
285
+ };
281
286
  }
287
+ return { passing: false, msg: `Adapter Instance State (${adapter.namespace}) requires ack:false` };
282
288
  }
283
289
 
284
290
  // Handle User States
285
291
  let isUserState = false;
286
- if (statePath.startsWith('javascript.') || statePath.startsWith('0_userdata.0') || statePath.startsWith('alias.')) isUserState = true;
292
+ if (
293
+ statePath.startsWith('javascript.') ||
294
+ statePath.startsWith('0_userdata.0') ||
295
+ statePath.startsWith('alias.')
296
+ ) {
297
+ isUserState = true;
298
+ }
287
299
 
288
300
  if (!isUserState) {
289
301
  // Check if state is under a "real" adapter namespace.
290
302
  const isRealAdapter = await adapter.getForeignObjectAsync(`system.adapter.${namespace}`);
291
- if (!isRealAdapter) isUserState = true;
303
+ if (!isRealAdapter) {
304
+ isUserState = true;
305
+ }
292
306
  }
293
307
 
294
308
  if (isUserState) {
295
-
296
309
  if (!adapter.config.triggerStatesAck || adapter.config.triggerStatesAck == 'false') {
297
310
  if (stateObject.ack == false) {
298
- return {passing:true, msg:`User State (${statePath}) requires ack:false per adapter configuration`};
299
- } else {
300
- return {passing:false, msg:`User State (${statePath}) requires ack:false per adapter configuration`};
311
+ return {
312
+ passing: true,
313
+ msg: `User State (${statePath}) requires ack:false per adapter configuration`,
314
+ };
301
315
  }
302
-
316
+ return {
317
+ passing: false,
318
+ msg: `User State (${statePath}) requires ack:false per adapter configuration`,
319
+ };
303
320
  } else if (adapter.config.triggerStatesAck == 'true') {
304
321
  if (stateObject.ack == true) {
305
- return {passing:true, msg:`User State (${statePath}) requires ack:true per adapter configuration`};
306
- } else {
307
- return {passing:false, msg:`User State (${statePath}) requires ack:true per adapter configuration`};
322
+ return {
323
+ passing: true,
324
+ msg: `User State (${statePath}) requires ack:true per adapter configuration`,
325
+ };
308
326
  }
309
- } else {
310
- // any (ack: true or false)
311
- return {passing:true, msg:`User State (${statePath}) can be ack:true or ack:false per adapter configuration`};
312
- }
313
-
314
- } else {
315
- // For any other "real" adapter state changes, we require ack = true
316
- if (stateObject.ack == true) {
317
- return {passing:true, msg:`"Real" adapter state (${statePath}) requires ack:true`};
318
- } else {
319
- return {passing:false, msg:`"Real" adapter state (${statePath}) requires ack:true`};
327
+ return {
328
+ passing: false,
329
+ msg: `User State (${statePath}) requires ack:true per adapter configuration`,
330
+ };
320
331
  }
332
+ // any (ack: true or false)
333
+ return {
334
+ passing: true,
335
+ msg: `User State (${statePath}) can be ack:true or ack:false per adapter configuration`,
336
+ };
321
337
  }
322
-
338
+ // For any other "real" adapter state changes, we require ack = true
339
+ if (stateObject.ack == true) {
340
+ return { passing: true, msg: `"Real" adapter state (${statePath}) requires ack:true` };
341
+ }
342
+ return { passing: false, msg: `"Real" adapter state (${statePath}) requires ack:true` };
323
343
  } catch (error) {
324
344
  this.dumpError('[isAckPassing()]', error);
325
- return {passing:false, msg:`Unexpected error occurred in isAckPassing()`};
345
+ return { passing: false, msg: `Unexpected error occurred in isAckPassing()` };
326
346
  }
327
-
328
347
  },
329
348
 
330
-
331
349
  /**
332
350
  * Checks if a cron string like xxx is valid or not.
333
- * Source: "Test if schedule is valid" - https://github.com/node-schedule/node-schedule/issues/296#issuecomment-269971152
334
- * Read: https://stackoverflow.com/questions/35817080/node-requiring-module-inside-function
335
- *
351
+ *
336
352
  * @param {string} str String to check, so like '0 22 * * 1-5'
337
- * @return {boolean} true if we have a valid cron string, false if not.
353
+ * @returns {boolean} true if we have a valid cron string, false if not.
338
354
  */
339
355
  isCronScheduleValid(str) {
340
-
341
- // node-schedule uses cron-parser, so we can simply require it here without adding to package.json
342
- const cronParser = require('cron-parser');
343
- try {
344
- cronParser.parseExpression(str);
345
- } catch (error) {
346
- // handle the parse error
347
- return false;
348
- }
349
- // success
350
- return true;
351
-
356
+ // Ausgelagert: gleiche Prüfung beim Speichern und beim Planen der Timer.
357
+ return require('./cron-schedule').isCronScheduleValid(str);
352
358
  },
353
359
 
354
360
  /**
355
361
  * Get the timestamp of an astro name.
356
- *
362
+ *
357
363
  * @param {string} astroName Name of sunlight time, like "sunrise", "nauticalDusk", etc.
358
- * @param {number} [offsetMinutes=0] Offset in minutes
359
- * @return {number} Timestamp of the astro name
364
+ * @param {number} [offsetMinutes] Offset in minutes
365
+ * @returns {number} Timestamp of the astro name
360
366
  */
361
- getAstroNameTs(astroName, offsetMinutes=0) {
362
-
367
+ getAstroNameTs(astroName, offsetMinutes = 0) {
363
368
  try {
364
- let ts = adapter.x.mSuncalc.getTimes(new Date(), adapter.x.systemConfig.latitude, adapter.x.systemConfig.longitude)[astroName];
369
+ let ts = adapter.x.mSuncalc.getTimes(
370
+ new Date(),
371
+ adapter.x.systemConfig.latitude,
372
+ adapter.x.systemConfig.longitude,
373
+ )[astroName];
365
374
  if (!ts || ts.getTime().toString() === 'NaN') {
366
375
  // Fix night / nightEnd per adapter options.
367
- // In northern areas is no night/nightEnd provided in the Summer.
376
+ // In northern areas is no night/nightEnd provided in the Summer.
368
377
  // So we use 0:00 for night and 2:00 for night end as fallback.
369
- if (adapter.config.fixNightNightEnd && ['night', 'nightEnd'].includes(astroName) ) {
370
- const currDate = new Date();
371
- const midnightTs = currDate.setHours(24,0,0,0); // is the future midnight of today, not the one that was at 0:00 today
378
+ if (adapter.config.fixNightNightEnd && ['night', 'nightEnd'].includes(astroName)) {
379
+ const currDate = new Date();
380
+ const midnightTs = currDate.setHours(24, 0, 0, 0); // is the future midnight of today, not the one that was at 0:00 today
372
381
  switch (astroName) {
373
382
  case 'night':
374
- adapter.log.debug(`[getAstroNameTs] No time found for [${astroName}], so we set 00:00 as fallback per adapter config.`);
383
+ adapter.log.debug(
384
+ `[getAstroNameTs] No time found for [${astroName}], so we set 00:00 as fallback per adapter config.`,
385
+ );
375
386
  return midnightTs; // midnight - 00:00
376
- case 'nightEnd':
377
- adapter.log.debug(`[getAstroNameTs] No time found for [${astroName}], so we set 02:00 as fallback per adapter config.`);
378
- return midnightTs + (1000*3600*2); // 02:00
387
+ case 'nightEnd':
388
+ adapter.log.debug(
389
+ `[getAstroNameTs] No time found for [${astroName}], so we set 02:00 as fallback per adapter config.`,
390
+ );
391
+ return midnightTs + 1000 * 3600 * 2; // 02:00
379
392
  }
380
393
  } else {
381
394
  adapter.log.warn(`[getAstroNameTs] No time found for [${astroName}].`);
@@ -384,31 +397,28 @@ module.exports = function (adapter) {
384
397
  }
385
398
 
386
399
  ts = this.roundTimeStampToNearestMinute(ts);
387
- ts = ts + (offsetMinutes * 60 * 1000);
400
+ ts = ts + offsetMinutes * 60 * 1000;
388
401
  return ts;
389
402
  } catch (error) {
390
403
  this.dumpError('[getAstroNameTs()]', error);
391
404
  return 0;
392
405
  }
393
-
394
406
  },
395
407
 
396
-
397
408
  /**
398
409
  * Get the time stamp of a time string, like '23:30', 'goldenHourEnd', or 'goldenHourEnd+30'
399
410
  * Supports times like 'h:ss'/'hh:ss', and also astro names.
400
411
  * Astro names can also have an additional offset in minutes, so like "sunriseEnd-40" or "sunriseEnd+120".
401
- *
412
+ *
402
413
  * @param {string} input the input string
403
- * @param {boolean} [getFullResult=false] if false: returns true if a valid time provided, and false if not.
414
+ * @param {boolean} [getFullResult] if false: returns true if a valid time provided, and false if not.
404
415
  * if true: Empty object if nothing found, or object with details.
405
- * @return {boolean|object} Return value
416
+ * @returns {boolean|object} Return value
406
417
  */
407
- getTimeInfoFromAstroString(input, getFullResult=false) {
408
-
418
+ getTimeInfoFromAstroString(input, getFullResult = false) {
409
419
  const currentDateTime = new Date(); // Date object of current date/time
410
420
 
411
- input = input.replace(/\s/g,''); // remove all white spaces
421
+ input = input.replace(/\s/g, ''); // remove all white spaces
412
422
 
413
423
  const returnObject = {
414
424
  full: input,
@@ -421,20 +431,23 @@ module.exports = function (adapter) {
421
431
  };
422
432
 
423
433
  const matchTime = input.match(/^(\d{1,2})(:)(\d{2})$/);
424
- const matchAstroName = input.match(/^(sunriseEnd|sunrise|goldenHourEnd|solarNoon|goldenHour|sunsetStart|sunset|dusk|nauticalDusk|nightEnd|nadir|night|nauticalDawn|dawn)$/g);
425
- const matchAstroWithOffset = input.match(/^(sunriseEnd|sunrise|goldenHourEnd|solarNoon|goldenHour|sunsetStart|sunset|dusk|nauticalDusk|nightEnd|nadir|night|nauticalDawn|dawn)(-|\+)(\d{1,3})$/);
434
+ const matchAstroName = input.match(
435
+ /^(sunriseEnd|sunrise|goldenHourEnd|solarNoon|goldenHour|sunsetStart|sunset|dusk|nauticalDusk|nightEnd|nadir|night|nauticalDawn|dawn)$/g,
436
+ );
437
+ const matchAstroWithOffset = input.match(
438
+ /^(sunriseEnd|sunrise|goldenHourEnd|solarNoon|goldenHour|sunsetStart|sunset|dusk|nauticalDusk|nightEnd|nadir|night|nauticalDawn|dawn)(-|\+)(\d{1,3})$/,
439
+ );
426
440
 
427
441
  if (matchTime != null) {
428
442
  // No Astro.
429
443
  // Time like "19:35" found. Convert to timestamp by using current date
430
-
444
+
431
445
  const hour = parseInt(matchTime[1]);
432
446
  const min = parseInt(matchTime[3]);
433
447
 
434
- if ( (input != '24:00') && (hour < 0 || hour > 23 || min < 0 || min > 60 ) ) {
448
+ if (input != '24:00' && (hour < 0 || hour > 23 || min < 0 || min > 60)) {
435
449
  returnObject.full = '';
436
450
  } else {
437
-
438
451
  returnObject.timestamp = new Date(
439
452
  currentDateTime.getFullYear(),
440
453
  currentDateTime.getMonth(),
@@ -442,7 +455,6 @@ module.exports = function (adapter) {
442
455
  hour, // hours
443
456
  min, // minutes
444
457
  ).getTime();
445
-
446
458
  }
447
459
  } else {
448
460
  if (matchAstroName != null) {
@@ -456,10 +468,13 @@ module.exports = function (adapter) {
456
468
  returnObject.astroHasOffset = true;
457
469
  returnObject.astroName = matchAstroWithOffset[1];
458
470
  returnObject.astroOffsetMinutes = parseInt(matchAstroWithOffset[3]);
459
- if(matchAstroWithOffset[2] == '-') {
460
- returnObject.astroOffsetMinutes = returnObject.astroOffsetMinutes * (-1);
471
+ if (matchAstroWithOffset[2] == '-') {
472
+ returnObject.astroOffsetMinutes = returnObject.astroOffsetMinutes * -1;
461
473
  }
462
- returnObject.timestamp = this.getAstroNameTs(returnObject.astroName, returnObject.astroOffsetMinutes);
474
+ returnObject.timestamp = this.getAstroNameTs(
475
+ returnObject.astroName,
476
+ returnObject.astroOffsetMinutes,
477
+ );
463
478
  } else {
464
479
  // Nothing found
465
480
  returnObject.full = '';
@@ -471,110 +486,109 @@ module.exports = function (adapter) {
471
486
 
472
487
  // handle '24:00'. We add a full day.
473
488
  if (input == '24:00') {
474
- returnObject.timestamp = returnObject.timestamp + +1000*60*60*24;
489
+ returnObject.timestamp = returnObject.timestamp + +1000 * 60 * 60 * 24;
475
490
  returnObject.hoursMins = '24:00';
476
491
  }
477
492
 
478
-
479
493
  if (!getFullResult) {
480
494
  if (!returnObject.full) {
481
495
  return false;
482
- } else {
483
- return true;
484
496
  }
485
- } else {
486
- return returnObject;
497
+ return true;
487
498
  }
488
-
499
+ return returnObject;
489
500
  },
490
501
 
491
502
  /**
492
503
  * Converts a given timestamp into European time. E.g. '9:03pm and 45 seconds' -> '21:03:45'
504
+ *
493
505
  * @param {object} ts Timestamp
494
- * @param {boolean} [noSeconds=false] if true, seconds will not be added. Result is '21:04' (rounded)
495
- * @return {string} Date in European date/time as String
506
+ * @param {boolean} [noSeconds] if true, seconds will not be added. Result is '21:04' (rounded)
507
+ * @returns {string} Date in European date/time as String
496
508
  */
497
- timestampToTimeString(ts, noSeconds=false) {
498
-
499
- if(noSeconds) ts = this.roundTimeStampToNearestMinute(ts);
500
- const inputDate = new Date(ts);
501
-
509
+ timestampToTimeString(ts, noSeconds = false) {
502
510
  if (noSeconds) {
503
- return this.zeroPad(inputDate.getHours(), 2) + ':' + this.zeroPad(inputDate.getMinutes(), 2);
504
- } else {
505
- return this.zeroPad(inputDate.getHours(), 2) + ':' + this.zeroPad(inputDate.getMinutes(), 2) + ':' + this.zeroPad(inputDate.getSeconds(), 2);
511
+ ts = this.roundTimeStampToNearestMinute(ts);
506
512
  }
513
+ const inputDate = new Date(ts);
507
514
 
515
+ if (noSeconds) {
516
+ return `${this.zeroPad(inputDate.getHours(), 2)}:${this.zeroPad(inputDate.getMinutes(), 2)}`;
517
+ }
518
+ return `${this.zeroPad(inputDate.getHours(), 2)}:${this.zeroPad(inputDate.getMinutes(), 2)}:${this.zeroPad(
519
+ inputDate.getSeconds(),
520
+ 2,
521
+ )}`;
508
522
  },
509
523
 
510
-
511
524
  /**
512
525
  * Checks if time of '08:30' is between '23:00' and '09:00'.
513
526
  * Source/inspired by: https://stackoverflow.com/a/24577309
514
- *
527
+ *
515
528
  * @param {string} start - start string, like: '23:00', '07:30', 9:15'
516
529
  * @param {string} end - end string, like: '08:15', '17:23'
517
530
  * @param {string} check - to check, like: '17:25', '9:30'
518
- * @return {boolean} true if in between, false if not
519
- *
531
+ * @returns {boolean} true if in between, false if not
520
532
  */
521
- isTimeBetween (start, end, check) {
522
-
523
-
524
- const timeIsBetween = function(start, end, check) {
525
- return (start.hour <= end.hour) ? check.isGreaterThan(start) && !check.isGreaterThan(end)
526
- : (check.isGreaterThan(start) && check.isGreaterThan(end)) || (!check.isGreaterThan(start) && !check.isGreaterThan(end));
533
+ isTimeBetween(start, end, check) {
534
+ const timeIsBetween = function (start, end, check) {
535
+ return start.hour <= end.hour
536
+ ? check.isGreaterThan(start) && !check.isGreaterThan(end)
537
+ : (check.isGreaterThan(start) && check.isGreaterThan(end)) ||
538
+ (!check.isGreaterThan(start) && !check.isGreaterThan(end));
527
539
  };
528
-
529
- function getTimeObj (timeString) {
540
+
541
+ function getTimeObj(timeString) {
530
542
  const t = timeString.split(':');
531
543
  const returnObject = {};
532
544
  returnObject.hour = parseInt(t[0]);
533
545
  returnObject.minutes = parseInt(t[1]);
534
- returnObject.isGreaterThan = function(other) {
535
- return (returnObject.hour > other.hour) || (returnObject.hour === other.hour) && (returnObject.minutes > other.minutes);
546
+ returnObject.isGreaterThan = function (other) {
547
+ return (
548
+ returnObject.hour > other.hour ||
549
+ (returnObject.hour === other.hour && returnObject.minutes > other.minutes)
550
+ );
536
551
  };
537
552
  return returnObject;
538
553
  }
539
-
554
+
540
555
  return timeIsBetween(getTimeObj(start), getTimeObj(end), getTimeObj(check));
541
-
542
556
  },
543
557
 
544
-
545
558
  /**
546
559
  * Gets the time left of 'const xxx = setTimeout()', where xxx is the timer id.
547
- *
560
+ *
548
561
  * @author Mic-M <https://github.com/Mic-M/>
549
562
  * @version 0.1 (30 June 2020)
550
- *
551
563
  * @param {object} timerId - The timer object 'xxx' when executing a 'const xxx = setTimeout()'
552
- * @return {number} The time remaining of the setTimeout() in milliseconds. Returns -1, if not or no longer running, never run, or object not even set.
564
+ * @returns {number} The time remaining of the setTimeout() in milliseconds. Returns -1, if not or no longer running, never run, or object not even set.
553
565
  * To convert ms to seconds, simply use: (timeLeft / 1000).toFixed(0) - where timeLeft is the return value of the function.
554
- *
555
566
  */
556
567
  getTimeoutTimeLeft(timerId) {
557
-
558
568
  try {
559
-
560
569
  // Return -1 if timer object is undefined/null or if timer is not running
561
- if (!timerId || timerId._destroyed) return -1;
570
+ if (!timerId || timerId._destroyed) {
571
+ return -1;
572
+ }
562
573
 
563
- const dummyTimer = setTimeout(() => {}, 0); // We need a dummy timer to get the current number of ms when the node.js session was started
564
- const currMsAfterNodeJsStart = dummyTimer['_idleStart']; // _idleStart is the number of milliseconds since the node.js session was started.
565
- clearTimeout(dummyTimer); // clear dummy timer, just in case.
574
+ // A native dummy timer only to read the current libuv time (_idleStart, ms since the node.js session was started).
575
+ // It is cleared at once, so it cannot outlive the adapter. adapter.setTimeout() is not used on purpose:
576
+ // this is also called in onUnload(), where adapter.setTimeout() returns undefined and logs a warning.
577
+ const dummyTimer = nodeTimers.setTimeout(() => {}, 0);
578
+ const currMsAfterNodeJsStart = dummyTimer['_idleStart'];
579
+ nodeTimers.clearTimeout(dummyTimer);
566
580
 
567
- const elapsed = currMsAfterNodeJsStart - timerId._idleStart; // for how many milliseconds is timer already running?
568
- let remaining = timerId._idleTimeout - elapsed; // remaining time in ms
569
- if (remaining < 0 ) remaining = -1; // Just in case, should be already caught by timerObject._destroyed
581
+ const elapsed = currMsAfterNodeJsStart - timerId._idleStart; // for how many milliseconds is timer already running?
582
+ let remaining = timerId._idleTimeout - elapsed; // remaining time in ms
583
+ if (remaining < 0) {
584
+ remaining = -1;
585
+ } // Just in case, should be already caught by timerObject._destroyed
570
586
 
571
587
  return remaining;
572
-
573
588
  } catch (error) {
574
589
  this.dumpError('[getTimeoutTimeLeft()]', error);
575
590
  return -1;
576
- }
577
-
591
+ }
578
592
  },
579
593
 
580
594
  /**
@@ -584,30 +598,36 @@ module.exports = function (adapter) {
584
598
  * @param {string} start Start time, like '18:30', or 'sunrise, or 'sunset+30'
585
599
  * @param {string} end End time
586
600
  * @param {string} ofWhat Typically zone name. For logging purposes only.
587
- * @return {boolean} true if within times, and false if not.
601
+ * @returns {boolean} true if within times, and false if not.
588
602
  */
589
603
  scheduleIsTimeStampWithinPeriod(tsGiven, start, end, ofWhat) {
590
-
591
604
  try {
592
-
593
605
  // First: convert potential Astro start time to "normal", so like 'sunset-30' to '18:30'
594
606
  const givenFinal = this.timestampToTimeString(tsGiven, true);
595
607
  const startFinal = this.getTimeInfoFromAstroString(start, true).hoursMins;
596
- const endFinal = this.getTimeInfoFromAstroString(end, true).hoursMins;
608
+ const endFinal = this.getTimeInfoFromAstroString(end, true).hoursMins;
597
609
 
598
- if (!givenFinal) throw(`givenFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`);
599
- if (!startFinal) throw(`startFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`);
600
- if (!endFinal) throw(`endFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`);
610
+ if (!givenFinal) {
611
+ throw `givenFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`;
612
+ }
613
+ if (!startFinal) {
614
+ throw `startFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`;
615
+ }
616
+ if (!endFinal) {
617
+ throw `endFinal is undefined. start: '${start}', end: '${end}', ofWhat: '${ofWhat}'`;
618
+ }
601
619
 
602
620
  // Next, check if given time is in between
603
621
  if (this.isTimeBetween(startFinal, endFinal, givenFinal)) {
604
- adapter.log.debug(`'${ofWhat}' - Current time '${givenFinal}' *is* within schedule times (start: '${startFinal}', end: '${endFinal}).`);
605
- return true;
606
- } else {
607
- adapter.log.debug(`'${ofWhat}' - Current time '${givenFinal}' is *not* within schedule times (start: '${startFinal}', end: '${endFinal}).`);
608
- return false;
622
+ adapter.log.debug(
623
+ `'${ofWhat}' - Current time '${givenFinal}' *is* within schedule times (start: '${startFinal}', end: '${endFinal}).`,
624
+ );
625
+ return true;
609
626
  }
610
-
627
+ adapter.log.debug(
628
+ `'${ofWhat}' - Current time '${givenFinal}' is *not* within schedule times (start: '${startFinal}', end: '${endFinal}).`,
629
+ );
630
+ return false;
611
631
  } catch (error) {
612
632
  this.dumpError('[scheduleIsTimeStampWithinPeriod]', error);
613
633
  return false;
@@ -616,24 +636,28 @@ module.exports = function (adapter) {
616
636
 
617
637
  /**
618
638
  * Check if current day is within the mon-sun options as set in Execution table.
619
- *
639
+ *
620
640
  * @param {object} row The "Execution" table row which was triggered.
621
641
  * @param {number} ts The timestamp to check.
622
642
  * @param {string} ofWhat Typically zone name. For logging purposes only.
623
- * @return {boolean} True if matching, false if not.
643
+ * @returns {boolean} True if matching, false if not.
624
644
  */
625
645
  scheduleIsWeekdayMatching(row, ts, ofWhat) {
626
646
  const days = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
627
647
  const lpWeekdayGiven = getWeekDayString(ts);
628
648
  for (const lpDay of days) {
629
649
  if (lpWeekdayGiven == null) {
630
- adapter.log.error(`[scheduleIsWeekdayMatching()] Unable to calculate day of week for given timestamp '${ts}'`);
650
+ adapter.log.error(
651
+ `[scheduleIsWeekdayMatching()] Unable to calculate day of week for given timestamp '${ts}'`,
652
+ );
631
653
  return false;
632
- } else if ( (row[lpDay] == true) && (lpDay == lpWeekdayGiven) ) {
633
- adapter.log.debug(`${ofWhat} - Current weekday '${lpWeekdayGiven}' *is* matching Execution table row.`);
654
+ } else if (row[lpDay] == true && lpDay == lpWeekdayGiven) {
655
+ adapter.log.debug(
656
+ `${ofWhat} - Current weekday '${lpWeekdayGiven}' *is* matching Execution table row.`,
657
+ );
634
658
  return true;
635
659
  }
636
- }
660
+ }
637
661
  // There was no hit, so we return false.
638
662
  adapter.log.debug(`${ofWhat} - Current weekday '${lpWeekdayGiven}' is *not* matching Execution table row.`);
639
663
  return false;
@@ -641,74 +665,84 @@ module.exports = function (adapter) {
641
665
  /**
642
666
  * get the week day of a string.
643
667
  * Source: https://stackoverflow.com/a/17964373
668
+ *
644
669
  * @param {*} date object or time stamp or string that is recognized by the Date.parse() method
645
- * @return {string|null} day of week as string, or null if not found.
670
+ * @returns {string|null} day of week as string, or null if not found.
646
671
  */
647
672
  function getWeekDayString(date) {
648
- const dayOfWeek = new Date(date).getDay();
673
+ const dayOfWeek = new Date(date).getDay();
649
674
  return isNaN(dayOfWeek) ? null : ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'][dayOfWeek];
650
675
  }
651
-
652
676
  },
653
677
 
654
678
  /**
655
679
  * JSON Log to smartcontrol.x.info.log.<id>.json
680
+ *
656
681
  * @param {string} id - e.g. 'zoneActivations' or 'switchedTargetDevices'
657
682
  * @param {object} jsonObj - object to add, e.g. {zone:'xyz', targetDevice:'xyz'}
658
- * @return {boolean} - false if errors caught, otherwise true.
683
+ * @returns {boolean} - false if errors caught, otherwise true.
659
684
  */
660
685
  async setJsonLog(id, jsonObj) {
661
-
662
686
  try {
663
-
664
687
  let maxJsonLength = 0;
665
- if (adapter.x.helper.isNumber(adapter.config.jsonMaxEntries)) {
688
+ if (adapter.x.helper.isNumber(adapter.config.jsonMaxEntries)) {
666
689
  maxJsonLength = parseInt(adapter.config.jsonMaxEntries);
667
690
  }
668
- if (maxJsonLength <= 0) return true;
669
-
670
- if(!this.isLikeEmpty(adapter.x.jsonLogs[id])) {
691
+ if (maxJsonLength <= 0) {
692
+ return true;
693
+ }
694
+
695
+ if (!this.isLikeEmpty(adapter.x.jsonLogs[id])) {
671
696
  adapter.x.jsonLogs[id] = adapter.x.jsonLogs[id].slice(0, maxJsonLength - 1); // just keep first x entries
672
- adapter.x.jsonLogs[id].unshift(jsonObj); // Add new entry as first element of array
697
+ adapter.x.jsonLogs[id].unshift(jsonObj); // Add new entry as first element of array
673
698
  } else {
674
699
  adapter.x.jsonLogs[id] = [jsonObj]; // add as array
675
700
  }
676
701
  adapter.setState(`info.log.${id}.json`, { val: JSON.stringify(adapter.x.jsonLogs[id]), ack: true });
677
702
  return true;
678
-
679
703
  } catch (error) {
680
704
  this.dumpError('[setJsonLog]', error);
681
705
  return false;
682
706
  }
683
-
684
707
  },
685
708
 
686
-
687
709
  /**
688
- * Checks if an ioBroker state id (path) string is valid.
710
+ * Checks if an ioBroker state id (path) string is valid.
689
711
  * NOTE: This does not verify if the state is existing. It does just some basic checks if the path looks good-
690
- *
712
+ *
691
713
  * @param {string} str String to validate
692
- * @return {boolean} true/false of validation result
714
+ * @returns {boolean} true/false of validation result
693
715
  */
694
716
  isStateIdValid(str) {
695
-
696
- if (!str || typeof str !== 'string') return false; // String?
697
- if(str.length < 5) return false; // If string length < 5 chars (minimum state length is 5, assuming this is a valid state: 'x.0.a'
698
- if (adapter.x.constants.forbiddenStatePaths.test(str)) return false; // If forbidden chars
699
- if (!/\.\d+\./.test(str)) return false; // If no instance number with a leading and trailing dot "."
700
- if (str.startsWith(' ') || str.endsWith(' ')) return false; // If spaces at beginning or end
701
- if (str.startsWith('.') || str.endsWith('.')) return false; // If dots at beginning or end
717
+ if (!str || typeof str !== 'string') {
718
+ return false;
719
+ } // String?
720
+ if (str.length < 5) {
721
+ return false;
722
+ } // If string length < 5 chars (minimum state length is 5, assuming this is a valid state: 'x.0.a'
723
+ if (adapter.x.constants.forbiddenStatePaths.test(str)) {
724
+ return false;
725
+ } // If forbidden chars
726
+ if (!/\.\d+\./.test(str)) {
727
+ return false;
728
+ } // If no instance number with a leading and trailing dot "."
729
+ if (str.startsWith(' ') || str.endsWith(' ')) {
730
+ return false;
731
+ } // If spaces at beginning or end
732
+ if (str.startsWith('.') || str.endsWith('.')) {
733
+ return false;
734
+ } // If dots at beginning or end
702
735
  return true; // All passed
703
736
  },
704
737
 
705
738
  /**
706
739
  * Logs information to ioBroker log.
707
740
  * If "extendedInfoLog" in adapter settings is disabled, log level is debug.
741
+ *
708
742
  * @param {string} msg The log message
709
743
  */
710
744
  logExtendedInfo(msg) {
711
- if(adapter.config.extendedInfoLog) {
745
+ if (adapter.config.extendedInfoLog) {
712
746
  adapter.log.info(msg);
713
747
  } else {
714
748
  adapter.log.debug(msg);
@@ -719,11 +753,11 @@ module.exports = function (adapter) {
719
753
  * Error Message to Log. Handles error object being provided.
720
754
  *
721
755
  * @param {string} msg - (intro) message of the error
722
- * @param {*} [error=undefined] - Optional: Error object or string
723
- * @param {boolean} [returnMsg=false] - Optional: If true, it will not log an error, but return the msg as string
724
- * @return {void|string}
756
+ * @param {*} [error] - Optional: Error object or string
757
+ * @param {boolean} [returnMsg] - Optional: If true, it will not log an error, but return the msg as string
758
+ * @returns {void|string}
725
759
  */
726
- dumpError(msg, error=undefined, returnMsg=false) {
760
+ dumpError(msg, error = undefined, returnMsg = false) {
727
761
  let finalMsg = 'undefined';
728
762
  if (!error) {
729
763
  finalMsg = msg;
@@ -740,15 +774,12 @@ module.exports = function (adapter) {
740
774
  finalMsg = `${msg} – ${error}`;
741
775
  } else {
742
776
  finalMsg = `[dumpError()] : wrong error argument: ${JSON.stringify(error)}`;
743
-
744
777
  }
745
778
  }
746
779
  if (returnMsg) {
747
780
  return finalMsg;
748
- } else {
749
- adapter.log.error(finalMsg);
750
781
  }
751
-
782
+ adapter.log.error(finalMsg);
752
783
  },
753
784
 
754
785
  /**
@@ -756,87 +787,81 @@ module.exports = function (adapter) {
756
787
  * Array, object, or string containing just white spaces or >'< or >"< or >[< or >]< is considered empty
757
788
  * 18-Jun-2020: added check for { and } to also catch empty objects.
758
789
  * 08-Sep-2019: added check for [ and ] to also catch arrays with empty strings.
790
+ *
759
791
  * @param {any} inputVar Input Array or String, Number, etc.
760
- * @return {boolean} True if it is undefined/null/empty, false if it contains value(s)
792
+ * @returns {boolean} True if it is undefined/null/empty, false if it contains value(s)
761
793
  */
762
794
  isLikeEmpty(inputVar) {
763
795
  if (typeof inputVar !== 'undefined' && inputVar !== null) {
764
796
  let strTemp = JSON.stringify(inputVar);
765
797
  strTemp = strTemp.replace(/\s+/g, ''); // remove all white spaces
766
- strTemp = strTemp.replace(/"+/g, ''); // remove all >"<
767
- strTemp = strTemp.replace(/'+/g, ''); // remove all >'<
768
- strTemp = strTemp.replace(/\[+/g, ''); // remove all >[<
769
- strTemp = strTemp.replace(/\]+/g, ''); // remove all >]<
770
- strTemp = strTemp.replace(/\{+/g, ''); // remove all >{<
771
- strTemp = strTemp.replace(/\}+/g, ''); // remove all >}<
798
+ strTemp = strTemp.replace(/"+/g, ''); // remove all >"<
799
+ strTemp = strTemp.replace(/'+/g, ''); // remove all >'<
800
+ strTemp = strTemp.replace(/\[+/g, ''); // remove all >[<
801
+ strTemp = strTemp.replace(/\]+/g, ''); // remove all >]<
802
+ strTemp = strTemp.replace(/\{+/g, ''); // remove all >{<
803
+ strTemp = strTemp.replace(/\}+/g, ''); // remove all >}<
772
804
  if (strTemp !== '') {
773
805
  return false;
774
- } else {
775
- return true;
776
806
  }
777
- } else {
778
807
  return true;
779
808
  }
809
+ return true;
780
810
  },
781
811
 
782
812
  /**
783
813
  * Checks whether variable is number
784
814
  * true: 5, '123'
785
815
  * false: '123abc', 'q345', null, undefined, false, ' '
816
+ *
786
817
  * @source https://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript
787
818
  * @param {any} n Input variable to check
788
- * @return {boolean} true if number, false if not.
819
+ * @returns {boolean} true if number, false if not.
789
820
  */
790
821
  isNumber(n) {
791
822
  return /^-?[\d.]+(?:e-?\d+)?$/.test(n);
792
823
  },
793
824
 
825
+ /**
826
+ * true/false aus dem Vergleichswert in der Config (#170).
827
+ *
828
+ * @param {any} val
829
+ * @returns {{ok: boolean, value?: boolean}}
830
+ */
831
+ parseBooleanStateVal(val) {
832
+ return require('./boolean-value').parseBooleanStateVal(val);
833
+ },
834
+
835
+ /**
836
+ * Parse a comparator string like '< -200' or '>26,5'.
837
+ *
838
+ * @param {string} compStr
839
+ * @returns {{isComparator: boolean, operand?: string, compNum?: number}}
840
+ */
841
+ parseNumComparator(compStr) {
842
+ return require('./num-comparator').parseNumComparator(compStr);
843
+ },
794
844
 
795
845
  /**
796
- * Check a given number against a comparator string, like '>30', '<= 25', etc.
846
+ * Check a given number against a comparator string, like '>30', '<= 25', '< -200'.
847
+ *
797
848
  * @param {any} numToCheck - number to check against comparator
798
849
  * @param {string} compStr - comparator, like '>30', '<= 25'
799
- * @return {object} - Object like {isComparator:true, result:true} - isComparator: if compStr was recognized as comparator, result: true if matching, false if not
850
+ * @returns {object} - Object like {isComparator:true, result:true}
800
851
  */
801
852
  isNumComparatorMatching(numToCheck, compStr) {
802
- // Check for >=, <=, >, <, != leading a number, so like '>= 3', '<7'
803
- if (typeof compStr == 'string' && (typeof numToCheck == 'string' || typeof numToCheck == 'number')) {
804
- const matchComparator =compStr.match(/^(>=|<=|>|<|!=|<>)\s?(\d{1,})$/);
805
- if (matchComparator != null) {
806
- // String like ">= 30" found.
807
- const operand = matchComparator[1];
808
- const compNum = parseFloat(matchComparator[2]);
809
- if (operand == '>=' && Number(numToCheck) >= compNum) {
810
- return {isComparator:true, result:true};
811
- } else if (operand == '<=' && Number(numToCheck) <= compNum) {
812
- return {isComparator:true, result:true};
813
- } else if (operand == '>' && Number(numToCheck) > compNum) {
814
- return {isComparator:true, result:true};
815
- } else if (operand == '<' && Number(numToCheck) < compNum) {
816
- return {isComparator:true, result:true};
817
- } else if ((operand == '!=' || operand == '<>' ) && Number(numToCheck) != compNum) {
818
- return {isComparator:true, result:true};
819
- } else {
820
- return {isComparator:true, result:false};
821
- }
822
- } else {
823
- return {isComparator:false, result:false};
824
- }
825
-
826
- } else {
827
- return {isComparator:false, result:false};
828
- }
853
+ return require('./num-comparator').isNumComparatorMatching(numToCheck, compStr);
829
854
  },
830
855
 
831
-
832
856
  /**
833
857
  * Remove certain (forbidden) chars from a string
858
+ *
834
859
  * @param {string} str - The input string
835
860
  * @param {RegExp} regex - Regex of chars to be removed, like /[\][*,;'"`<>\\?]/g
836
- * @param {boolean} [cleanSpaces=false] - Optional: trim and remove replace multiple spaces with single space
837
- * @return {array} Array with two elements: [0]: the resulting string, [1]: message if str was altered or empty string if no changes applied
861
+ * @param {boolean} [cleanSpaces] - Optional: trim and remove replace multiple spaces with single space
862
+ * @returns {Array} Array with two elements: [0]: the resulting string, [1]: message if str was altered or empty string if no changes applied
838
863
  */
839
- strCharsRemove(str, regex, cleanSpaces=false) {
864
+ strCharsRemove(str, regex, cleanSpaces = false) {
840
865
  let correctedMsg = '';
841
866
  let result = str;
842
867
  if (result.match(regex)) {
@@ -858,46 +883,44 @@ module.exports = function (adapter) {
858
883
  return [result, correctedMsg];
859
884
  },
860
885
 
861
-
862
-
863
886
  /**
864
887
  * Remove Duplicates from Array
888
+ *
865
889
  * @source https://stackoverflow.com/questions/23237704/nodejs-how-to-remove-duplicates-from-array
866
- * @param {array} inputArray Array to process
867
- * @return {array} Array without duplicates.
890
+ * @param {Array} inputArray Array to process
891
+ * @returns {Array} Array without duplicates.
868
892
  */
869
893
  uniqueArray(inputArray) {
870
- return inputArray.filter(function(elem, pos) {
894
+ return inputArray.filter(function (elem, pos) {
871
895
  return inputArray.indexOf(elem) == pos;
872
896
  });
873
897
  },
874
898
 
875
-
876
899
  /**
877
900
  * Check if an array contains duplicate values
878
901
  * https://stackoverflow.com/a/34192063
879
902
  *
880
903
  * @param {*} myArray - The given array
881
- * @return {boolean} - true if it is unique, false otherwise.
904
+ * @returns {boolean} - true if it is unique, false otherwise.
882
905
  */
883
906
  isArrayUnique(myArray) {
884
907
  return myArray.length === new Set(myArray).size;
885
908
  },
886
909
 
887
910
  /**
888
- * Removing Array element(s) by input value.
889
- * @param {array} arr the input array
911
+ * Removing Array element(s) by input value.
912
+ *
913
+ * @param {Array} arr the input array
890
914
  * @param {string} valRemove the value to be removed
891
- * @param {boolean} [exact=true] OPTIONAL: default is true. if true, it must fully match. if false, it matches also if valRemove is part of element string
892
- * @return {array} the array without the element(s)
915
+ * @param {boolean} [exact] OPTIONAL: default is true. if true, it must fully match. if false, it matches also if valRemove is part of element string
916
+ * @returns {Array} the array without the element(s)
893
917
  */
894
- arrayRemoveElementByValue(arr, valRemove, exact=true) {
895
-
918
+ arrayRemoveElementByValue(arr, valRemove, exact = true) {
896
919
  const arrGiven = [...arr]; // copy array
897
920
 
898
- for ( let i = 0; i < arrGiven.length; i++){
921
+ for (let i = 0; i < arrGiven.length; i++) {
899
922
  if (exact) {
900
- if ( arrGiven[i] === valRemove) {
923
+ if (arrGiven[i] === valRemove) {
901
924
  arrGiven.splice(i, 1);
902
925
  i--;
903
926
  }
@@ -914,32 +937,58 @@ module.exports = function (adapter) {
914
937
  /**
915
938
  * Remove duplicates from an array of objects by key
916
939
  * https://stackoverflow.com/a/58437069
917
- *
918
- * @param {array} givenArray
940
+ *
941
+ * @param {Array} givenArray
919
942
  * @param {string} key key which value must be unique.
920
- * @param {boolean} [all=false] if true: unique by all properties of the object, if false: unique by just the key value
943
+ * @param {boolean} [all] if true: unique by all properties of the object, if false: unique by just the key value
921
944
  */
922
- uniqueArrayObjectByKey(givenArray, key, all=false) {
923
-
945
+ uniqueArrayObjectByKey(givenArray, key, all = false) {
924
946
  if (all) {
925
- return givenArray.filter((v,i,a)=>a.findIndex(t=>(JSON.stringify(t) === JSON.stringify(v)))===i);
926
- } else {
927
- return givenArray.filter((v,i,a)=>a.findIndex(t=>(t[key] === v[key]))===i);
947
+ return givenArray.filter((v, i, a) => a.findIndex(t => JSON.stringify(t) === JSON.stringify(v)) === i);
928
948
  }
929
-
949
+ return givenArray.filter((v, i, a) => a.findIndex(t => t[key] === v[key]) === i);
930
950
  },
931
951
 
932
952
  /**
933
953
  * Converts string like 'val:'abc', delay:500' to a JSON object
934
954
  * If keys 'val' or 'delay' are not existing, return {val: query}
935
- * @param {string} query
936
- * @param {array} keys - array of strings like ['val', 'delay']
937
- * @param {boolean} [flat=false]
938
- * @return {object|null} JSON object, or null if query is empty or errors
955
+ *
956
+ * jsonConfig speichert denselben Override schon als Objekt { val, delay }.
957
+ * Die alte Admin-UI speicherte nur den String ("95"). Beides muss hier landen.
958
+ *
959
+ * @param {string|object} query
960
+ * @param {Array} keys - array of strings like ['val', 'delay']
961
+ * @param {boolean} [flat]
962
+ * @returns {object|null} JSON object, or null if query is empty or errors
939
963
  */
940
- convertStrToJson(query, keys, flat=false) {
964
+ convertStrToJson(query, keys, flat = false) {
965
+ if (query && typeof query === 'object' && !Array.isArray(query)) {
966
+ const out = {};
967
+ if (query.val !== undefined && query.val !== null && String(query.val).trim() !== '') {
968
+ out.val = query.val;
969
+ }
970
+ if (
971
+ query.delay !== undefined &&
972
+ query.delay !== null &&
973
+ query.delay !== '' &&
974
+ this.isNumber(query.delay) &&
975
+ parseInt(query.delay) >= 0
976
+ ) {
977
+ out.delay = query.delay;
978
+ }
979
+ return Object.keys(out).length ? out : null;
980
+ }
941
981
 
942
- if (this.isLikeEmpty(query)) return null;
982
+ if (typeof query !== 'string') {
983
+ if (query === undefined || query === null) {
984
+ return null;
985
+ }
986
+ query = String(query);
987
+ }
988
+
989
+ if (this.isLikeEmpty(query)) {
990
+ return null;
991
+ }
943
992
 
944
993
  let keyFound = false;
945
994
  for (const lpKey of keys) {
@@ -950,8 +999,7 @@ module.exports = function (adapter) {
950
999
  }
951
1000
  }
952
1001
 
953
- if ( keyFound ) {
954
-
1002
+ if (keyFound) {
955
1003
  const arrayOfKeyValues = query.split(',');
956
1004
  const modifiedArray = [];
957
1005
  for (const lpEntryStr of arrayOfKeyValues) {
@@ -964,35 +1012,30 @@ module.exports = function (adapter) {
964
1012
 
965
1013
  if (flat) {
966
1014
  return modifiedArray.toString();
967
- } else {
968
- try {
969
- return JSON.parse('{' + modifiedArray.toString() + '}');
970
- } catch (error) {
971
- adapter.log.error('[convertStrToJson())]: Could not convert given query to JSON object');
972
- return null;
973
- }
1015
+ }
1016
+ try {
1017
+ return JSON.parse(`{${modifiedArray.toString()}}`);
1018
+ } catch {
1019
+ adapter.log.error('[convertStrToJson())]: Could not convert given query to JSON object');
1020
+ return null;
974
1021
  }
975
1022
  } else {
976
1023
  const newVal = this.strCharsRemove(query, /['"`]/g, true)[0];
977
1024
  if (flat) {
978
1025
  return newVal;
979
- } else {
980
- return {val: newVal};
981
1026
  }
1027
+ return { val: newVal };
982
1028
  }
983
-
984
1029
  },
985
1030
 
986
-
987
1031
  /**
988
1032
  * Rounds the given timestamp to the nearest minute
989
1033
  * Inspired by https://github.com/date-fns/date-fns/blob/master/src/roundToNearestMinutes/index.js
990
1034
  *
991
1035
  * @param {number} ts a timestamp
992
- * @return {number} the resulting timestamp
1036
+ * @returns {number} the resulting timestamp
993
1037
  */
994
1038
  roundTimeStampToNearestMinute(ts) {
995
-
996
1039
  const date = new Date(ts);
997
1040
  const minutes = date.getMinutes() + date.getSeconds() / 60;
998
1041
  const roundedMinutes = Math.floor(minutes);
@@ -1003,68 +1046,66 @@ module.exports = function (adapter) {
1003
1046
  date.getMonth(),
1004
1047
  date.getDate(),
1005
1048
  date.getHours(),
1006
- roundedMinutes + addedMinutes
1049
+ roundedMinutes + addedMinutes,
1007
1050
  ).getTime();
1008
-
1009
1051
  },
1010
1052
 
1011
1053
  /**
1012
1054
  * Validate URL
1055
+ *
1013
1056
  * @param {string} url - given URL as string
1014
- * @param {boolean} [clean=false] - removes white spaces if true
1015
- * @param {boolean} [returnUrl=false] - if false: returns boolean, if true: url if successful, null if not
1016
- * @return {boolean|string|null}
1057
+ * @param {boolean} [clean] - removes white spaces if true
1058
+ * @param {boolean} [returnUrl] - if false: returns boolean, if true: url if successful, null if not
1059
+ * @returns {boolean|string|null}
1017
1060
  */
1018
- validateURL(url, clean=false, returnUrl=false) {
1019
- if(clean) url = url.replace(/\s/g,''); // remove all white spaces
1061
+ validateURL(url, clean = false, returnUrl = false) {
1062
+ if (clean) {
1063
+ url = url.replace(/\s/g, '');
1064
+ } // remove all white spaces
1065
+ // eslint-disable-next-line no-useless-escape -- same regex as before (string, no logic change)
1020
1066
  const urlRegexStr = `^(https?)://([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+.?([a-zA-Z]))(:[0-9]+)*(/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$`;
1021
1067
  const regex = new RegExp(urlRegexStr);
1022
1068
  const isUrlValid = url.length < 2083 && regex.test(url);
1023
1069
  if (returnUrl) {
1024
1070
  if (isUrlValid) {
1025
1071
  return url;
1026
- } else {
1027
- return null;
1028
1072
  }
1029
- } else {
1030
- return isUrlValid;
1073
+ return null;
1031
1074
  }
1075
+ return isUrlValid;
1032
1076
  },
1033
1077
 
1034
1078
  /**
1035
1079
  * Pad a number with leading zeros, like 7 => '007' if 3 places.
1080
+ *
1036
1081
  * @param {string|number} num Input number
1037
1082
  * @param {number} digits Number of digits
1038
- * @return {string} The result
1083
+ * @returns {string} The result
1039
1084
  */
1040
1085
  zeroPad(num, digits) {
1041
1086
  const zero = digits - num.toString().length + 1;
1042
- return Array(+(zero > 0 && zero)).join('0') + num;
1087
+ return Array(+(zero > 0 && zero)).join('0') + num;
1043
1088
  },
1044
1089
 
1045
1090
  /**
1046
1091
  * Check string against a forbidden chars regex
1047
1092
  * Mic-M
1048
- *
1093
+ *
1049
1094
  * @param {string} str - the input string
1050
1095
  * @param {RegExp} regex - the regular expression, like: /[\][*,;'"`<>\\?]/g
1051
- * @return {boolean|string} - returns false if nothing found, or all forbidden chars found space separated as string, like '[ ] , ? *'
1096
+ * @returns {boolean|string} - returns false if nothing found, or all forbidden chars found space separated as string, like '[ ] , ? *'
1052
1097
  */
1053
1098
  forbiddenCharsInStr(str, regex) {
1054
-
1055
1099
  let result = str.match(regex);
1056
1100
  if (result) {
1057
1101
  result = this.uniqueArray(result);
1058
1102
  let returnStr = '';
1059
1103
  for (const lpCharForbidden of result) {
1060
- returnStr = returnStr + ' ' + lpCharForbidden;
1104
+ returnStr = `${returnStr} ${lpCharForbidden}`;
1061
1105
  }
1062
- return (returnStr.trim());
1063
- } else {
1064
- return false;
1106
+ return returnStr.trim();
1065
1107
  }
1066
-
1108
+ return false;
1067
1109
  },
1068
-
1069
1110
  };
1070
- };
1111
+ };