node-red-contrib-mobius-flow-base 3.1.1 → 3.1.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.
@@ -72,15 +72,24 @@ module.exports = function (RED) {
72
72
  this.password
73
73
  );
74
74
  this.apiClient.EngineWebSocket.clearAllCallbacks();
75
- this.apiClient.EngineWebSocket.registerCallback('resource-cov', (response) => {
76
- this.handleCOVEvents(response);
77
- });
78
- this.apiClient.EngineWebSocket.registerCallback('object-cov', (response) => {
79
- this.handleObjectCOVEvents(response);
80
- });
81
- this.apiClient.EngineWebSocket.registerCallback('broadcast-command', (response) => {
82
- this.handleBCMDEvents(response);
83
- });
75
+ this.apiClient.EngineWebSocket.registerCallback(
76
+ 'resource-cov',
77
+ (response) => {
78
+ this.handleCOVEvents(response);
79
+ }
80
+ );
81
+ this.apiClient.EngineWebSocket.registerCallback(
82
+ 'object-cov',
83
+ (response) => {
84
+ this.handleObjectCOVEvents(response);
85
+ }
86
+ );
87
+ this.apiClient.EngineWebSocket.registerCallback(
88
+ 'broadcast-command',
89
+ (response) => {
90
+ this.handleBCMDEvents(response);
91
+ }
92
+ );
84
93
  var node = this;
85
94
  node.serviceList = [];
86
95
  node.hasStarted = false;
@@ -98,12 +107,20 @@ module.exports = function (RED) {
98
107
  this.log(`Connected to ${n.host}`);
99
108
  this.apiClient.getHubId((err, hubId) => {
100
109
  if (err) {
101
- node.error('Mobius error getting hub ID' + JSON.stringify(err));
110
+ node.error(
111
+ `Mobius error getting hub ID: ${err.code}, ${
112
+ err.message ? err.message : ''
113
+ }`
114
+ );
102
115
  } else {
103
116
  node.hubId = hubId;
104
117
  this.apiClient.discover(node.hubId, (err, response) => {
105
118
  if (err) {
106
- node.error('Mobius error discovering service list' + JSON.stringify(err));
119
+ node.error(
120
+ `Mobius error discovering service list: ${err.code}, ${
121
+ err.message ? err.message : ''
122
+ }`
123
+ );
107
124
  } else {
108
125
  node.serviceList = response.data;
109
126
  node.hasStarted = true;
@@ -380,8 +397,22 @@ module.exports = function (RED) {
380
397
  * @param {Function} func - The function used to test the resource values
381
398
  * @param {Function} callback - function(err, [object]) {}
382
399
  */
383
- node.filterObjectsByRIDValue = function (uri, pids, rid, limit, func, callback) {
384
- this.apiClient.filterObjectsByRIDValue(uri, pids, rid, limit, func, callback);
400
+ node.filterObjectsByRIDValue = function (
401
+ uri,
402
+ pids,
403
+ rid,
404
+ limit,
405
+ func,
406
+ callback
407
+ ) {
408
+ this.apiClient.filterObjectsByRIDValue(
409
+ uri,
410
+ pids,
411
+ rid,
412
+ limit,
413
+ func,
414
+ callback
415
+ );
385
416
  };
386
417
 
387
418
  /**
@@ -389,9 +420,9 @@ module.exports = function (RED) {
389
420
  * @param {*} password - The new password
390
421
  * @param {*} callback - Callback when complete, function(err, [object]) {}
391
422
  */
392
- node.changeAdminPassword = function(password, callback) {
423
+ node.changeAdminPassword = function (password, callback) {
393
424
  this.apiClient.changeAdminPassword(password, callback);
394
- }
425
+ };
395
426
 
396
427
  /**
397
428
  * Subscribe to a resource COV
@@ -523,8 +554,20 @@ module.exports = function (RED) {
523
554
  * @param {number} timeout - Optional timeout in ms which overrides the default timeout if > 0
524
555
  * @param {Function} callback - Callback when complete
525
556
  */
526
- node.sendDirectCommand = function (uri, cid, commandData, timeout, callback) {
527
- this.apiClient.sendDirectCommand(uri, cid, commandData, timeout, callback);
557
+ node.sendDirectCommand = function (
558
+ uri,
559
+ cid,
560
+ commandData,
561
+ timeout,
562
+ callback
563
+ ) {
564
+ this.apiClient.sendDirectCommand(
565
+ uri,
566
+ cid,
567
+ commandData,
568
+ timeout,
569
+ callback
570
+ );
528
571
  };
529
572
 
530
573
  /**
@@ -546,8 +589,19 @@ module.exports = function (RED) {
546
589
  * @param {Object} config - The new object configuration, structure given by {ins: string, pid: string, uiname: string, rids: array}
547
590
  * @param {Function} callback - Callback when complete
548
591
  */
549
- node.updateObjectInServiceConfig = function (hid, sid, pid, ins, config, callback) {
550
- this.apiClient.updateObject(`${hid}/${sid}/${pid}/${ins}`, config, callback);
592
+ node.updateObjectInServiceConfig = function (
593
+ hid,
594
+ sid,
595
+ pid,
596
+ ins,
597
+ config,
598
+ callback
599
+ ) {
600
+ this.apiClient.updateObject(
601
+ `${hid}/${sid}/${pid}/${ins}`,
602
+ config,
603
+ callback
604
+ );
551
605
  };
552
606
 
553
607
  /**
@@ -557,7 +611,7 @@ module.exports = function (RED) {
557
611
  */
558
612
  node.getNodeConfig = function (uri, callback) {
559
613
  this.apiClient.getNodeConfig(uri, callback);
560
- }
614
+ };
561
615
 
562
616
  /**
563
617
  * Get the list of services on a hub
@@ -566,7 +620,7 @@ module.exports = function (RED) {
566
620
  */
567
621
  node.getNodeConfigTree = function (hid, callback) {
568
622
  this.apiClient.getNodeConfigTree(hid, callback);
569
- }
623
+ };
570
624
 
571
625
  /**
572
626
  * Get the list of services on a hub
@@ -575,11 +629,11 @@ module.exports = function (RED) {
575
629
  */
576
630
  node.getProfileByPid = function (hid, pid, callback) {
577
631
  this.apiClient.getProfileByPid(hid, pid, callback);
578
- }
632
+ };
579
633
 
580
634
  node.getAllObjectProfiles = function (hid, callback) {
581
635
  this.apiClient.getAllObjectProfiles(hid, callback);
582
- }
636
+ };
583
637
  }
584
638
 
585
639
  RED.nodes.registerType('mobius connection', MobiusConnectionNode);
@@ -602,8 +656,12 @@ module.exports = function (RED) {
602
656
 
603
657
  let pid = req.query.pid;
604
658
  if (conn === null || !conn.connected) {
605
- RED.log.error('Discover objects failed - could not to connect to MOBiUS hub.');
606
- throw new Error('Discover objects failed - could not to connect to MOBiUS hub.');
659
+ RED.log.error(
660
+ 'Discover objects failed - could not to connect to MOBiUS hub.'
661
+ );
662
+ throw new Error(
663
+ 'Discover objects failed - could not to connect to MOBiUS hub.'
664
+ );
607
665
  } else {
608
666
  uiFuncs
609
667
  .discoverDevicesByPID(RED, conn, hid, spids, pid)
@@ -626,8 +684,12 @@ module.exports = function (RED) {
626
684
  let hid = req.query.hid;
627
685
  let spid = req.query.spid;
628
686
  if (conn === null || !conn.connected) {
629
- RED.log.error('Discover services failed - could not to connect to MOBiUS hub.');
630
- throw new Error('Discover services failed - could not to connect to MOBiUS hub.');
687
+ RED.log.error(
688
+ 'Discover services failed - could not to connect to MOBiUS hub.'
689
+ );
690
+ throw new Error(
691
+ 'Discover services failed - could not to connect to MOBiUS hub.'
692
+ );
631
693
  } else {
632
694
  uiFuncs
633
695
  .discoverServicesBySPID(RED, conn, hid, spid)
@@ -641,13 +703,20 @@ module.exports = function (RED) {
641
703
  }
642
704
  );
643
705
 
644
- // Register the endpoint for node-red mobius discovery in node-red node config pages
645
- RED.httpAdmin.get('/mdiscover', RED.auth.needsPermission('serial.read'), function (req, res) {
706
+ // Register the endpoint for node-red mobius discovery in node-red node config pages
707
+ RED.httpAdmin.get(
708
+ '/mdiscover',
709
+ RED.auth.needsPermission('serial.read'),
710
+ function (req, res) {
646
711
  let conn = RED.nodes.getNode(req.query.mobius);
647
712
  let uri = req.query.uri;
648
713
  if (conn === null || !conn.connected) {
649
- RED.log.error('Discover services failed - could not to connect to MOBiUS hub.');
650
- throw new Error('Discover services failed - could not to connect to MOBiUS hub.');
714
+ RED.log.error(
715
+ 'Discover services failed - could not to connect to MOBiUS hub.'
716
+ );
717
+ throw new Error(
718
+ 'Discover services failed - could not to connect to MOBiUS hub.'
719
+ );
651
720
  } else {
652
721
  uiFuncs
653
722
  .discover(conn, uri)
@@ -658,16 +727,24 @@ module.exports = function (RED) {
658
727
  throw err;
659
728
  });
660
729
  }
661
- });
730
+ }
731
+ );
662
732
 
663
- // Register the endpoint for node-red get resource options for object type
664
- RED.httpAdmin.get('/mgetresourceoptions', RED.auth.needsPermission('serial.read'), function (req, res) {
733
+ // Register the endpoint for node-red get resource options for object type
734
+ RED.httpAdmin.get(
735
+ '/mgetresourceoptions',
736
+ RED.auth.needsPermission('serial.read'),
737
+ function (req, res) {
665
738
  let conn = RED.nodes.getNode(req.query.mobius);
666
739
  let hid = req.query.hid;
667
740
  let pid = req.query.pid;
668
741
  if (conn === null || !conn.connected) {
669
- RED.log.error('Fetching resource options failed - could not to connect to MOBiUS hub.');
670
- throw new Error('Fetching resource options failed - could not to connect to MOBiUS hub.');
742
+ RED.log.error(
743
+ 'Fetching resource options failed - could not to connect to MOBiUS hub.'
744
+ );
745
+ throw new Error(
746
+ 'Fetching resource options failed - could not to connect to MOBiUS hub.'
747
+ );
671
748
  } else {
672
749
  uiFuncs
673
750
  .getResourceOptions(conn, hid, pid)
@@ -678,15 +755,23 @@ module.exports = function (RED) {
678
755
  throw err;
679
756
  });
680
757
  }
681
- });
682
-
683
- // Register the endpoint for node-red mobius discovery in node-red node config pages
684
- RED.httpAdmin.get('/mgetservices', RED.auth.needsPermission('serial.read'), function (req, res) {
758
+ }
759
+ );
760
+
761
+ // Register the endpoint for node-red mobius discovery in node-red node config pages
762
+ RED.httpAdmin.get(
763
+ '/mgetservices',
764
+ RED.auth.needsPermission('serial.read'),
765
+ function (req, res) {
685
766
  let conn = RED.nodes.getNode(req.query.mobius);
686
767
  let hid = req.query.hid;
687
768
  if (conn === null || !conn.connected) {
688
- RED.log.error('Get services failed - could not to connect to MOBiUS hub.');
689
- throw new Error('Get services failed - could not to connect to MOBiUS hub.');
769
+ RED.log.error(
770
+ 'Get services failed - could not to connect to MOBiUS hub.'
771
+ );
772
+ throw new Error(
773
+ 'Get services failed - could not to connect to MOBiUS hub.'
774
+ );
690
775
  } else {
691
776
  uiFuncs
692
777
  .getServiceList(conn, hid)
@@ -697,15 +782,23 @@ module.exports = function (RED) {
697
782
  RED.log.warn(`Get services failed - ${err}`);
698
783
  });
699
784
  }
700
- });
701
-
702
- RED.httpAdmin.get('/mgetobjects', RED.auth.needsPermission('serial.read'), function (req, res) {
785
+ }
786
+ );
787
+
788
+ RED.httpAdmin.get(
789
+ '/mgetobjects',
790
+ RED.auth.needsPermission('serial.read'),
791
+ function (req, res) {
703
792
  let conn = RED.nodes.getNode(req.query.mobius);
704
793
  let hid = req.query.hid;
705
794
  let sid = req.query.sid;
706
795
  if (conn === null || !conn.connected) {
707
- RED.log.error('Get objects failed - could not to connect to MOBiUS hub.');
708
- throw new Error('Get objects failed - could not to connect to MOBiUS hub.');
796
+ RED.log.error(
797
+ 'Get objects failed - could not to connect to MOBiUS hub.'
798
+ );
799
+ throw new Error(
800
+ 'Get objects failed - could not to connect to MOBiUS hub.'
801
+ );
709
802
  } else {
710
803
  uiFuncs
711
804
  .getConfigObjectsList(conn, hid, sid)
@@ -713,12 +806,20 @@ module.exports = function (RED) {
713
806
  res.json(response);
714
807
  })
715
808
  .catch((err) => {
716
- RED.log.warn(`Get objects failed on service ${req.query.sid} ${err ? ` - ${JSON.stringify(err)}` : ''}`);
809
+ RED.log.warn(
810
+ `Get objects failed on service ${req.query.sid}: ${err.code}, ${
811
+ err.message ? err.message : ''
812
+ }`
813
+ );
717
814
  });
718
815
  }
719
- });
720
-
721
- RED.httpAdmin.get('/mgethid', RED.auth.needsPermission('serial.read'), function (req, res) {
816
+ }
817
+ );
818
+
819
+ RED.httpAdmin.get(
820
+ '/mgethid',
821
+ RED.auth.needsPermission('serial.read'),
822
+ function (req, res) {
722
823
  let conn = RED.nodes.getNode(req.query.mobius);
723
824
  if (conn === null || !conn.connected) {
724
825
  RED.log.error('Get hid failed - could not to connect to MOBiUS hub.');
@@ -726,23 +827,27 @@ module.exports = function (RED) {
726
827
  } else {
727
828
  res.json(conn.hubId);
728
829
  }
729
- });
830
+ }
831
+ );
730
832
 
731
- RED.httpAdmin.get('/mgetconnected', RED.auth.needsPermission('serial.read'), function (req, res) {
833
+ RED.httpAdmin.get(
834
+ '/mgetconnected',
835
+ RED.auth.needsPermission('serial.read'),
836
+ function (req, res) {
732
837
  let conn = RED.nodes.getNode(req.query.mobius);
733
838
  if (conn === null) {
734
839
  res.json(false);
735
840
  } else {
736
841
  res.json(conn.connected);
737
842
  }
738
- });
739
-
740
- RED.httpAdmin.get('/common/*', function (req, res) {
741
- var options = {
742
- root: __dirname + '/common/',
743
- dotfiles: 'deny',
744
- };
745
- res.sendFile(req.params[0], options);
746
- });
843
+ }
844
+ );
747
845
 
846
+ RED.httpAdmin.get('/common/*', function (req, res) {
847
+ var options = {
848
+ root: __dirname + '/common/',
849
+ dotfiles: 'deny',
850
+ };
851
+ res.sendFile(req.params[0], options);
852
+ });
748
853
  };
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusFlowNode (n) {
31
+ function MobiusFlowNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.mobjects = n.mobjects;
34
34
  this.serviceConn = RED.nodes.getNode(n.connection);
@@ -38,7 +38,7 @@ module.exports = function (RED) {
38
38
  node.status({
39
39
  fill: 'red',
40
40
  shape: 'ring',
41
- text: 'Disconnected'
41
+ text: 'Disconnected',
42
42
  });
43
43
 
44
44
  node.serviceConn.register(node);
@@ -47,7 +47,7 @@ module.exports = function (RED) {
47
47
  node.status({
48
48
  fill: 'green',
49
49
  shape: 'ring',
50
- text: 'Busy'
50
+ text: 'Busy',
51
51
  });
52
52
 
53
53
  for (const mobject of node.mobjects) {
@@ -55,7 +55,7 @@ module.exports = function (RED) {
55
55
  node.status({
56
56
  fill: 'yellow',
57
57
  shape: 'dot',
58
- text: 'URIs not Valid'
58
+ text: 'URIs not Valid',
59
59
  });
60
60
  if (done) {
61
61
  return done();
@@ -71,17 +71,21 @@ module.exports = function (RED) {
71
71
  node.status({
72
72
  fill: 'green',
73
73
  shape: 'dot',
74
- text: 'Done'
74
+ text: 'Done',
75
75
  });
76
- node.send({ ...msg, topic: msg.topic, payload: values});
76
+ node.send({ ...msg, topic: msg.topic, payload: values });
77
77
  })
78
78
  .catch((err) => {
79
79
  node.status({
80
80
  fill: 'yellow',
81
81
  shape: 'dot',
82
- text: 'Error: ' + JSON.stringify(err.code)
82
+ text: 'Error: ' + JSON.stringify(err.code),
83
83
  });
84
- node.error('Mobius error reading object ' + JSON.stringify(err));
84
+ node.error(
85
+ `Mobius error reading object: ${err.code}, ${
86
+ err.message ? err.message : ''
87
+ }`
88
+ );
85
89
  })
86
90
  .finally(() => {
87
91
  if (done) {
@@ -98,7 +102,7 @@ module.exports = function (RED) {
98
102
  }
99
103
  }
100
104
 
101
- function validateResourceURI (uri) {
105
+ function validateResourceURI(uri) {
102
106
  let parts = uri.split('/');
103
107
  for (let lp = 0; lp < parts.length; lp++) {
104
108
  if (parts[lp] === null || parts[lp] === '') {
@@ -111,7 +115,7 @@ module.exports = function (RED) {
111
115
  return false;
112
116
  }
113
117
 
114
- function readObject (node, uri) {
118
+ function readObject(node, uri) {
115
119
  return new Promise((resolve, reject) => {
116
120
  node.serviceConn.readObject(uri, (err, response) => {
117
121
  if (err) {
@@ -90,7 +90,11 @@ module.exports = function (RED) {
90
90
  shape: 'dot',
91
91
  text: 'Error: ' + JSON.stringify(err.code),
92
92
  });
93
- node.error('Mobius error reading resource ' + JSON.stringify(err));
93
+ node.error(
94
+ `Mobius error reading resource: ${err.code}, ${
95
+ err.message ? err.message : ''
96
+ }`
97
+ );
94
98
  })
95
99
  .finally(() => {
96
100
  if (done) {
@@ -129,7 +133,11 @@ module.exports = function (RED) {
129
133
  if (node.sendFormat === 'array') {
130
134
  resolve(response.data.pv);
131
135
  } else {
132
- resolve({ uri: uri, pv: response.data.pv, name: response.data.name });
136
+ resolve({
137
+ uri: uri,
138
+ pv: response.data.pv,
139
+ name: response.data.name,
140
+ });
133
141
  }
134
142
  }
135
143
  });
@@ -47,7 +47,10 @@ module.exports = function (RED) {
47
47
 
48
48
  node.on('input', function (msg) {
49
49
  let uri = node.mobject;
50
- if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 4)) {
50
+ if (
51
+ msg.hasOwnProperty('topic') &&
52
+ require('./validateURI')(msg.topic, 4)
53
+ ) {
51
54
  uri = msg.topic;
52
55
  }
53
56
 
@@ -63,9 +66,17 @@ module.exports = function (RED) {
63
66
  shape: 'dot',
64
67
  text: 'Error: ' + JSON.stringify(err.code),
65
68
  });
66
- node.error('Mobius error reading object ' + JSON.stringify(err));
69
+ node.error(
70
+ `Mobius error reading object: ${err.code}, ${
71
+ err.message ? err.message : ''
72
+ }`
73
+ );
67
74
  if (node.detailedOutput === true) {
68
- node.send([null, null, { ...msg, topic: uri, payload: { error: true, response: err } }]);
75
+ node.send([
76
+ null,
77
+ null,
78
+ { ...msg, topic: uri, payload: { error: true, response: err } },
79
+ ]);
69
80
  }
70
81
  } else {
71
82
  node.status({
@@ -82,7 +93,11 @@ module.exports = function (RED) {
82
93
  node.send([
83
94
  { ...msg, topic: uri, payload: allResources },
84
95
  { ...msg, topic: uri, payload: response.data },
85
- { ...msg, topic: uri, payload: { error: false, response: response } },
96
+ {
97
+ ...msg,
98
+ topic: uri,
99
+ payload: { error: false, response: response },
100
+ },
86
101
  ]);
87
102
  } else {
88
103
  node.send({ ...msg, topic: uri, payload: allResources });
@@ -44,7 +44,10 @@ module.exports = function (RED) {
44
44
 
45
45
  node.on('input', function (msg) {
46
46
  let uri = node.resource;
47
- if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 5)) {
47
+ if (
48
+ msg.hasOwnProperty('topic') &&
49
+ require('./validateURI')(msg.topic, 5)
50
+ ) {
48
51
  uri = msg.topic;
49
52
  }
50
53
 
@@ -60,7 +63,11 @@ module.exports = function (RED) {
60
63
  shape: 'dot',
61
64
  text: 'Error: ' + JSON.stringify(err.code),
62
65
  });
63
- node.error('Mobius error reading resource ' + JSON.stringify(err));
66
+ node.error(
67
+ `Mobius error reading resource : ${err.code}, ${
68
+ err.message ? err.message : ''
69
+ }`
70
+ );
64
71
  if (node.detailedOutput === true) {
65
72
  node.send([
66
73
  null,
@@ -78,14 +85,26 @@ module.exports = function (RED) {
78
85
  if (node.detailedOutput === true) {
79
86
  node.send([
80
87
  { ...msg, topic: uri, payload: response.data.pv },
81
- { ...msg, topic: uri, payload: { pv: response.data.pv, name: response.data.name } },
88
+ {
89
+ ...msg,
90
+ topic: uri,
91
+ payload: { pv: response.data.pv, name: response.data.name },
92
+ },
82
93
  { ...msg, topic: uri, payload: response.data },
83
- { ...msg, topic: uri, payload: { error: false, response: response } },
94
+ {
95
+ ...msg,
96
+ topic: uri,
97
+ payload: { error: false, response: response },
98
+ },
84
99
  ]);
85
100
  } else {
86
101
  node.send([
87
102
  { ...msg, topic: uri, payload: response.data.pv },
88
- { ...msg, topic: uri, payload: { pv: response.data.pv, name: response.data.name } },
103
+ {
104
+ ...msg,
105
+ topic: uri,
106
+ payload: { pv: response.data.pv, name: response.data.name },
107
+ },
89
108
  ]);
90
109
  }
91
110
  }
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusSendDCMDNode (n) {
31
+ function MobiusSendDCMDNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.cid = n.cid;
34
34
  this.uri = n.uri;
@@ -40,29 +40,53 @@ module.exports = function (RED) {
40
40
  node.status({
41
41
  fill: 'red',
42
42
  shape: 'ring',
43
- text: 'Disconnected'
43
+ text: 'Disconnected',
44
44
  });
45
45
 
46
46
  node.on('input', function (msg) {
47
47
  if (msg.hasOwnProperty('payload')) {
48
- node.serviceConn.sendDirectCommand(node.uri, node.cid, msg.payload, node.timeout, (err, response) => {
49
- if (err) {
50
- node.status({
51
- fill: 'yellow',
52
- shape: 'dot',
53
- text: 'Error: ' + JSON.stringify(err.code)
54
- });
55
- node.error('Mobius error sending DCMD command ' + JSON.stringify(err));
56
- node.send([null, { ...msg, topic: node.uri, payload: { error: true, response: err }}]);
57
- } else {
58
- node.status({
59
- fill: 'green',
60
- shape: 'dot',
61
- text: 'OK'
62
- });
63
- node.send([{ ...msg, topic: node.uri, payload: response.data}, { ...msg, topic: node.uri, payload: {error: false, response: response}}]);
48
+ node.serviceConn.sendDirectCommand(
49
+ node.uri,
50
+ node.cid,
51
+ msg.payload,
52
+ node.timeout,
53
+ (err, response) => {
54
+ if (err) {
55
+ node.status({
56
+ fill: 'yellow',
57
+ shape: 'dot',
58
+ text: 'Error: ' + JSON.stringify(err.code),
59
+ });
60
+ node.error(
61
+ `Mobius error sending DCMD command: ${err.code}, ${
62
+ err.message ? err.message : ''
63
+ }`
64
+ );
65
+ node.send([
66
+ null,
67
+ {
68
+ ...msg,
69
+ topic: node.uri,
70
+ payload: { error: true, response: err },
71
+ },
72
+ ]);
73
+ } else {
74
+ node.status({
75
+ fill: 'green',
76
+ shape: 'dot',
77
+ text: 'OK',
78
+ });
79
+ node.send([
80
+ { ...msg, topic: node.uri, payload: response.data },
81
+ {
82
+ ...msg,
83
+ topic: node.uri,
84
+ payload: { error: false, response: response },
85
+ },
86
+ ]);
87
+ }
64
88
  }
65
- });
89
+ );
66
90
  }
67
91
  });
68
92