iobroker.javascript 5.4.0 → 5.4.3

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/lib/scheduler.js CHANGED
@@ -83,20 +83,15 @@ class Scheduler {
83
83
  for (const id in this.list) {
84
84
  if (!this.list.hasOwnProperty(id)) continue;
85
85
  if (this.checkSchedule(context, this.list[id])) {
86
- typeof this.list[id].cb === 'function' && this.list[id].cb(id);
86
+ setImmediate(id => this.list[id] && typeof this.list[id].cb === 'function' && this.list[id].cb(id), id);
87
87
  }
88
88
  }
89
89
 
90
90
  const d = new this.Date();
91
- // if callback last more than a minute
92
- if (d.getTime() - context.now > 60000) {
93
- setImmediate(() => this.checkSchedules());
94
- } else {
95
- d.setMilliseconds(0);
96
- d.setSeconds(0);
97
- d.setMinutes(d.getMinutes() + 1);
98
- this.timer = setTimeout(() => this.checkSchedules(), d.getTime() - this.Date.now());
99
- }
91
+ d.setMilliseconds(0);
92
+ d.setSeconds(0);
93
+ d.setMinutes(d.getMinutes() + 1);
94
+ this.timer = setTimeout(() => this.checkSchedules(), d.getTime() - this.Date.now());
100
95
  }
101
96
 
102
97
  monthDiff(d1, d2) {
@@ -145,7 +140,7 @@ class Scheduler {
145
140
  }
146
141
  }
147
142
  } else if (schedule.period.months) {
148
- if (schedule.period.months && schedule.period.months.indexOf(context.M) === -1) {
143
+ if (Array.isArray(schedule.period.months) && schedule.period.months.indexOf(context.M) === -1) {
149
144
  return;
150
145
  }
151
146
  if (schedule.period.fromDate && typeof schedule.period.months === 'number' && schedule.period.months > 1) {
@@ -154,6 +149,9 @@ class Scheduler {
154
149
  return;
155
150
  }
156
151
  }
152
+ if (schedule.period.dates && schedule.period.dates.indexOf(context.d) === -1) {
153
+ return;
154
+ }
157
155
  } else if (schedule.period.years) {
158
156
  if (schedule.period.yearMonth !== undefined && schedule.period.yearMonth !== context.M) {
159
157
  return;
@@ -327,7 +325,7 @@ class Scheduler {
327
325
  return;
328
326
  }
329
327
  }
330
- if (sch.period.months) {
328
+ if (sch.period.months && typeof sch.period.months !== 'number') { // can be number or array-string
331
329
  try {
332
330
  sch.period.months = JSON.parse(sch.period.months);
333
331
  } catch (e) {
package/main.js CHANGED
@@ -1376,7 +1376,7 @@ function createActiveObject(id, enabled, cb) {
1376
1376
  if (state && state.val !== enabled) {
1377
1377
  const intermediateStateValue = prepareStateObject(idActive, !!enabled, true);
1378
1378
  adapter.setForeignState(idActive, !!enabled, true, () => {
1379
- if (!!enabled) {
1379
+ if (enabled) {
1380
1380
  context.interimStateValues[id] = intermediateStateValue;
1381
1381
  }
1382
1382
  cb && cb();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.javascript",
3
- "version": "5.4.0",
3
+ "version": "5.4.3",
4
4
  "description": "Rules Engine for ioBroker",
5
5
  "author": "bluefox <dogafox@gmail.com>",
6
6
  "contributors": [