iobroker.device-watcher 2.9.0 → 2.9.1

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/main.js CHANGED
@@ -1,7 +1,3 @@
1
- /* jshint -W097 */
2
- /* jshint strict: false */
3
- /* jslint node: true */
4
-
5
1
  'use strict';
6
2
 
7
3
  const utils = require('@iobroker/adapter-core');
@@ -10,9 +6,6 @@ const schedule = require('node-schedule');
10
6
  const arrApart = require('./lib/arrApart.js'); // list of supported adapters
11
7
  const cronParser = require('cron-parser');
12
8
 
13
- // Sentry error reporting, disable when testing code!
14
- const enableSendSentry = true;
15
-
16
9
  // indicator if the adapter is running or not (for intervall/shedule)
17
10
  let isUnloaded = false;
18
11
 
@@ -264,7 +257,7 @@ class DeviceWatcher extends utils.Adapter {
264
257
  }
265
258
  }
266
259
  } catch (error) {
267
- this.errorReporting('[onReady - create and fill datapoints for each adapter]', error);
260
+ this.log.error(`[onReady - create and fill datapoints for each adapter] - ${error}`);
268
261
  }
269
262
  }
270
263
 
@@ -314,7 +307,7 @@ class DeviceWatcher extends utils.Adapter {
314
307
  // send overview of instances with error
315
308
  if (this.config.checkSendInstanceFailedDaily) this.sendScheduleNotifications('errorInstance');
316
309
  } catch (error) {
317
- this.errorReporting('[onReady]', error);
310
+ this.log.error(`[onReady] - ${error}`);
318
311
  this.terminate ? this.terminate(15) : process.exit(15);
319
312
  }
320
313
  } // <-- onReady end
@@ -601,7 +594,7 @@ class DeviceWatcher extends utils.Adapter {
601
594
  });
602
595
  this.sendTo(obj.from, obj.command, sortDevices, obj.callback);
603
596
  } catch (error) {
604
- this.errorReporting('[onMessage - deviceList for blacklisttable]', error);
597
+ this.log.error(`[onMessage - deviceList for blacklisttable] - ${error}`);
605
598
  }
606
599
  }
607
600
  break;
@@ -626,7 +619,7 @@ class DeviceWatcher extends utils.Adapter {
626
619
  });
627
620
  this.sendTo(obj.from, obj.command, sortInstances, obj.callback);
628
621
  } catch (error) {
629
- this.errorReporting('[onMessage - instanceList]', error);
622
+ this.log.error(`[onMessage - instanceList] - ${error}`);
630
623
  }
631
624
  }
632
625
  break;
@@ -650,7 +643,7 @@ class DeviceWatcher extends utils.Adapter {
650
643
  });
651
644
  this.sendTo(obj.from, obj.command, sortInstances, obj.callback);
652
645
  } catch (error) {
653
- this.errorReporting('[onMessage - instanceList]', error);
646
+ this.log.error(`[onMessage - instanceList] - ${error}`);
654
647
  }
655
648
  }
656
649
  break;
@@ -672,7 +665,7 @@ class DeviceWatcher extends utils.Adapter {
672
665
  await this.writeDatapoints(); // fill the datapoints
673
666
  this.log.debug(`Created and filled data for all adapters`);
674
667
  } catch (error) {
675
- this.errorReporting('[main - create data of all adapter]', error);
668
+ this.log.error(`[main - create data of all adapter] - ${error}`);
676
669
  }
677
670
 
678
671
  // fill datapoints for each adapter if selected
@@ -690,7 +683,7 @@ class DeviceWatcher extends utils.Adapter {
690
683
  }
691
684
  }
692
685
  } catch (error) {
693
- this.errorReporting('[main - create and fill datapoints for each adapter]', error);
686
+ this.log.error(`[main - create and fill datapoints for each adapter] - ${error}`);
694
687
  }
695
688
  }
696
689
 
@@ -763,7 +756,7 @@ class DeviceWatcher extends utils.Adapter {
763
756
  this.blacklistNotify.push(blacklistParse.path);
764
757
  }
765
758
  } catch (error) {
766
- this.errorReporting('[createBlacklist]', error);
759
+ this.log.error(`[createBlacklist] - ${error}`);
767
760
  }
768
761
  if (this.blacklistLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistLists}`);
769
762
  if (this.blacklistAdapterLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistAdapterLists}`);
@@ -786,7 +779,7 @@ class DeviceWatcher extends utils.Adapter {
786
779
  this.blacklistInstancesNotify.push(blacklistParse.instanceID);
787
780
  }
788
781
  } catch (error) {
789
- this.errorReporting('[createBlacklist]', error);
782
+ this.log.error(`[createBlacklist] - ${error}`);
790
783
  }
791
784
  }
792
785
  if (this.blacklistInstancesLists.length >= 1) this.log.info(`Found instances items on blacklist for lists: ${this.blacklistInstancesLists}`);
@@ -811,7 +804,7 @@ class DeviceWatcher extends utils.Adapter {
811
804
  errorTime: userTimeListInstances[i].errorTime,
812
805
  });
813
806
  } catch (error) {
814
- this.errorReporting('[createTimeListInstances]', error);
807
+ this.log.error(`[createTimeListInstances] - ${error}`);
815
808
  }
816
809
  }
817
810
  if (this.userTimeInstancesList.size >= 1) this.log.info(`Found instances items on lists for timesettings: ${Array.from(this.userTimeInstancesList.keys())}`);
@@ -1077,7 +1070,7 @@ class DeviceWatcher extends utils.Adapter {
1077
1070
  }
1078
1071
  } // <-- end of loop
1079
1072
  } catch (error) {
1080
- this.errorReporting('[createData - create data of devices]', error);
1073
+ this.log.error(`[createData - create data of devices] - ${error}`);
1081
1074
  }
1082
1075
  } // <-- end of createData
1083
1076
 
@@ -1174,7 +1167,7 @@ class DeviceWatcher extends utils.Adapter {
1174
1167
  }
1175
1168
  return deviceName;
1176
1169
  } catch (error) {
1177
- this.errorReporting('[getDeviceName]', error);
1170
+ this.log.error(`[getDeviceName] - ${error}`);
1178
1171
  }
1179
1172
  }
1180
1173
 
@@ -1562,7 +1555,7 @@ class DeviceWatcher extends utils.Adapter {
1562
1555
  }
1563
1556
  return [lastContactString, deviceState, linkQuality];
1564
1557
  } catch (error) {
1565
- this.errorReporting('[getLastContact]', error);
1558
+ this.log.error(`[getLastContact] - ${error}`);
1566
1559
  }
1567
1560
  }
1568
1561
 
@@ -2000,7 +1993,7 @@ class DeviceWatcher extends utils.Adapter {
2000
1993
  const lastCheck = this.formatDate(new Date(), 'DD.MM.YYYY') + ' - ' + this.formatDate(new Date(), 'hh:mm:ss');
2001
1994
  await this.setStateChangedAsync('lastCheck', lastCheck, true);
2002
1995
  } catch (error) {
2003
- this.errorReporting('[writeDatapoints]', error);
1996
+ this.log.error(`[writeDatapoints] - ${error}`);
2004
1997
  }
2005
1998
  this.log.debug(`Function finished: ${this.writeDatapoints.name}`);
2006
1999
  } //<--End of writing Datapoints
@@ -2013,7 +2006,7 @@ class DeviceWatcher extends utils.Adapter {
2013
2006
  const allInstances = `system.adapter.*`;
2014
2007
  await this.getInstanceData(allInstances);
2015
2008
  } catch (error) {
2016
- this.errorReporting('[getInstance]', error);
2009
+ this.log.error(`[getInstance] - ${error}`);
2017
2010
  }
2018
2011
  }
2019
2012
 
@@ -2113,7 +2106,7 @@ class DeviceWatcher extends utils.Adapter {
2113
2106
  await this.createInstanceList();
2114
2107
  await this.writeInstanceDPs();
2115
2108
  } catch (error) {
2116
- this.errorReporting('[getInstanceData]', error);
2109
+ this.log.error(`[getInstanceData] - ${error}`);
2117
2110
  }
2118
2111
  }
2119
2112
 
@@ -2804,7 +2797,7 @@ class DeviceWatcher extends utils.Adapter {
2804
2797
  });
2805
2798
  }
2806
2799
  } catch (error) {
2807
- this.errorReporting('[sendNotification Pushover]', error);
2800
+ this.log.error(`[sendNotification Pushover] - ${error}`);
2808
2801
  }
2809
2802
  }
2810
2803
 
@@ -2824,7 +2817,7 @@ class DeviceWatcher extends utils.Adapter {
2824
2817
  });
2825
2818
  }
2826
2819
  } catch (error) {
2827
- this.errorReporting('[sendNotification Telegram]', error);
2820
+ this.log.error(`[sendNotification Telegram] - ${error}`);
2828
2821
  }
2829
2822
  }
2830
2823
 
@@ -2843,7 +2836,7 @@ class DeviceWatcher extends utils.Adapter {
2843
2836
  });
2844
2837
  }
2845
2838
  } catch (error) {
2846
- this.errorReporting('[sendNotification Whatsapp]', error);
2839
+ this.log.error(`[sendNotification Whatsapp] - ${error}`);
2847
2840
  }
2848
2841
  }
2849
2842
 
@@ -2862,7 +2855,7 @@ class DeviceWatcher extends utils.Adapter {
2862
2855
  });
2863
2856
  }
2864
2857
  } catch (error) {
2865
- this.errorReporting('[sendNotification Matrix]', error);
2858
+ this.log.error(`[sendNotification Matrix] - ${error}`);
2866
2859
  }
2867
2860
  }
2868
2861
 
@@ -2881,7 +2874,7 @@ class DeviceWatcher extends utils.Adapter {
2881
2874
  });
2882
2875
  }
2883
2876
  } catch (error) {
2884
- this.errorReporting('[sendNotification Signal]', error);
2877
+ this.log.error(`[sendNotification Signal] - ${error}`);
2885
2878
  }
2886
2879
  }
2887
2880
 
@@ -2901,7 +2894,7 @@ class DeviceWatcher extends utils.Adapter {
2901
2894
  });
2902
2895
  }
2903
2896
  } catch (error) {
2904
- this.errorReporting('[sendNotification eMail]', error);
2897
+ this.log.error(`[sendNotification eMail] - ${error}`);
2905
2898
  }
2906
2899
  }
2907
2900
 
@@ -2921,7 +2914,7 @@ class DeviceWatcher extends utils.Adapter {
2921
2914
  );
2922
2915
  }
2923
2916
  } catch (error) {
2924
- this.errorReporting('[sendNotification Jarvis]', error);
2917
+ this.log.error(`[sendNotification Jarvis] - ${error}`);
2925
2918
  }
2926
2919
  }
2927
2920
 
@@ -2941,7 +2934,7 @@ class DeviceWatcher extends utils.Adapter {
2941
2934
  );
2942
2935
  }
2943
2936
  } catch (error) {
2944
- this.errorReporting('[sendNotification Lovelace]', error);
2937
+ this.log.error(`[sendNotification Lovelace] - ${error}`);
2945
2938
  }
2946
2939
  }
2947
2940
 
@@ -2961,7 +2954,7 @@ class DeviceWatcher extends utils.Adapter {
2961
2954
  }
2962
2955
  }
2963
2956
  } catch (error) {
2964
- this.errorReporting('[sendNotification Synochat]', error);
2957
+ this.log.error(`[sendNotification Synochat] - ${error}`);
2965
2958
  }
2966
2959
  }
2967
2960
  } // <-- End of sendNotification function
@@ -4354,30 +4347,10 @@ class DeviceWatcher extends utils.Adapter {
4354
4347
  const previous = interval.prev();
4355
4348
  return Math.floor(Date.now() - previous.getTime()); // in ms
4356
4349
  } catch (error) {
4357
- this.log.warn(error);
4358
- return;
4350
+ this.log.error(`[getPreviousCronRun] - ${error}`);
4359
4351
  }
4360
4352
  }
4361
4353
 
4362
- /**
4363
- * @param {string} codePart - Message Prefix
4364
- * @param {object} error - Sentry message
4365
- */
4366
- errorReporting(codePart, error) {
4367
- const msg = `[${codePart}] error: ${error.message}`;
4368
- if (enableSendSentry) {
4369
- if (this.supportsFeature && this.supportsFeature('PLUGINS')) {
4370
- const sentryInstance = this.getPluginInstance('sentry');
4371
- if (sentryInstance) {
4372
- this.log.warn(`Error catched and sent to Sentry, error: ${msg}`);
4373
- sentryInstance.getSentryObject().captureException(msg);
4374
- }
4375
- }
4376
- } else {
4377
- this.log.error(`Sentry disabled, error catched : ${msg}`);
4378
- }
4379
- } // <-- end of errorReporting
4380
-
4381
4354
  /**
4382
4355
  * @param {() => void} callback
4383
4356
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.device-watcher",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Watchdog for devices",
5
5
  "author": {
6
6
  "name": "Christian Behrends",