@gotillit/tillit-node-red 1.2.1 → 1.2.2
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/dist/nodes/node-api.js +34 -27
- package/dist/nodes/node-api.js.map +1 -1
- package/dist/nodes/node-broker.d.ts +11 -3
- package/dist/nodes/node-broker.js +137 -61
- package/dist/nodes/node-broker.js.map +1 -1
- package/dist/nodes/node-event.js +40 -31
- package/dist/nodes/node-event.js.map +1 -1
- package/dist/nodes/node-in.js +134 -72
- package/dist/nodes/node-in.js.map +1 -1
- package/dist/nodes/node-out.js +125 -65
- package/dist/nodes/node-out.js.map +1 -1
- package/dist/nodes/node-progress.js +123 -69
- package/dist/nodes/node-progress.js.map +1 -1
- package/dist/nodes/node-pv.js +144 -81
- package/dist/nodes/node-pv.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,88 +1,142 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.buildNodeProgressFunction = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
var NodeProgress = /** @class */ (function () {
|
|
41
|
+
function NodeProgress(n, RED, node) {
|
|
42
|
+
var _this = this;
|
|
43
|
+
this.options = { qos: 1 };
|
|
44
|
+
this.broker = RED.nodes.getNode(n.device).broker;
|
|
45
|
+
this.node = node;
|
|
46
|
+
this.assetId = n.assetId;
|
|
47
|
+
this.node.on('input', (function (msg) { return _this.onInput(msg); }));
|
|
48
|
+
this.broker.on('statusUpdate', function (report) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
_this.node.status({
|
|
51
|
+
fill: report.status === 'connected' ? 'green' : 'red',
|
|
52
|
+
shape: 'ring',
|
|
53
|
+
text: ((_b = (_a = report === null || report === void 0 ? void 0 : report.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || report.status
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
NodeProgress.prototype.onInput = function (msg) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var topic, finalPayload, buffer, _a, result, error, e_1, e_2;
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
_b.trys.push([0, 8, , 9]);
|
|
64
|
+
if (!this.broker) return [3 /*break*/, 6];
|
|
65
|
+
this.node.status({
|
|
28
66
|
fill: "blue",
|
|
29
67
|
shape: "ring",
|
|
30
68
|
text: "sending..."
|
|
31
69
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
return [4 /*yield*/, this.broker.connect()];
|
|
71
|
+
case 1:
|
|
72
|
+
_b.sent();
|
|
73
|
+
topic = "$aws/rules/".concat(this.broker.environment, "_edge_data/").concat(this.broker.tenant, "/").concat(this.broker.clientId, "/order-progress");
|
|
74
|
+
finalPayload = {
|
|
75
|
+
format: 'json', body: [Object.assign({
|
|
76
|
+
assetId: (this.assetId > 0) ? (this.assetId > 0) : msg.topic * 1,
|
|
77
|
+
timestamp: new Date().toISOString()
|
|
78
|
+
}, msg.payload)]
|
|
79
|
+
};
|
|
80
|
+
this.node.log("SEND> " + topic + ' ' + JSON.stringify(finalPayload));
|
|
81
|
+
buffer = new Buffer(JSON.stringify(finalPayload), "utf-8");
|
|
82
|
+
_b.label = 2;
|
|
83
|
+
case 2:
|
|
84
|
+
_b.trys.push([2, 4, , 5]);
|
|
85
|
+
return [4 /*yield*/, this.broker.mqttClient.publish(topic, buffer, this.options.qos, false)];
|
|
86
|
+
case 3:
|
|
87
|
+
_a = _b.sent(), result = _a.result, error = _a.error;
|
|
88
|
+
if (error) {
|
|
89
|
+
this.node.status({
|
|
90
|
+
fill: "red",
|
|
91
|
+
shape: "ring",
|
|
92
|
+
text: error.message
|
|
48
93
|
});
|
|
49
94
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
fill: "
|
|
95
|
+
else {
|
|
96
|
+
this.node.status({
|
|
97
|
+
fill: "green",
|
|
53
98
|
shape: "ring",
|
|
54
|
-
text:
|
|
99
|
+
text: "sent"
|
|
55
100
|
});
|
|
56
101
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
102
|
+
return [3 /*break*/, 5];
|
|
103
|
+
case 4:
|
|
104
|
+
e_1 = _b.sent();
|
|
105
|
+
this.node.status({
|
|
61
106
|
fill: "red",
|
|
62
107
|
shape: "ring",
|
|
63
|
-
text:
|
|
108
|
+
text: e_1.message
|
|
64
109
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
110
|
+
return [3 /*break*/, 5];
|
|
111
|
+
case 5: return [3 /*break*/, 7];
|
|
112
|
+
case 6:
|
|
113
|
+
this.node.error("connection is not configured");
|
|
114
|
+
this.node.status({
|
|
115
|
+
fill: "red",
|
|
116
|
+
shape: "ring",
|
|
117
|
+
text: "not configured"
|
|
118
|
+
});
|
|
119
|
+
_b.label = 7;
|
|
120
|
+
case 7: return [3 /*break*/, 9];
|
|
121
|
+
case 8:
|
|
122
|
+
e_2 = _b.sent();
|
|
123
|
+
this.node.error("something went wrong", e_2);
|
|
124
|
+
this.node.status({
|
|
125
|
+
fill: "red",
|
|
126
|
+
shape: "ring",
|
|
127
|
+
text: e_2.message
|
|
128
|
+
});
|
|
129
|
+
return [3 /*break*/, 9];
|
|
130
|
+
case 9: return [2 /*return*/];
|
|
131
|
+
}
|
|
83
132
|
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
return NodeProgress;
|
|
136
|
+
}());
|
|
137
|
+
var buildNodeProgressFunction = function (RED) { return (function awsMqttNodeProgress(n) {
|
|
138
|
+
RED.nodes.createNode(this, n);
|
|
139
|
+
this.tillitProgress = new NodeProgress(n, RED, this);
|
|
86
140
|
}); };
|
|
87
141
|
exports.buildNodeProgressFunction = buildNodeProgressFunction;
|
|
88
142
|
//# sourceMappingURL=node-progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-progress.js","sourceRoot":"","sources":["../../src/nodes/node-progress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-progress.js","sourceRoot":"","sources":["../../src/nodes/node-progress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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BACf,CAAC,CAAC;yBACN;;;;wBAGD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,KAAK,EAAE,MAAM;4BACb,IAAI,EAAE,GAAC,CAAC,OAAO;yBAClB,CAAC,CAAC;;;;wBAIP,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;wBAChD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,KAAK,EAAE,MAAM;4BACb,IAAI,EAAE,gBAAgB;yBACzB,CAAC,CAAC;;;;;wBAIP,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAC,CAAC,CAAC;wBAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,KAAK,EAAE,MAAM;4BACb,IAAI,EAAE,GAAC,CAAC,OAAO;yBAClB,CAAC,CAAC;;;;;;KAEV;IACL,mBAAC;AAAD,CAAC,AA1FD,IA0FC;AAGM,IAAM,yBAAyB,GAAG,UAAC,GAAQ,IAAK,OAAA,CACnD,SAAS,mBAAmB,CAAC,CAAW;IACpC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC,CAAC,EAJiD,CAIjD,CAAA;AAJO,QAAA,yBAAyB,6BAIhC"}
|
package/dist/nodes/node-pv.js
CHANGED
|
@@ -1,96 +1,159 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.buildNodePvFunction = void 0;
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
var NodeProcessVariable = /** @class */ (function () {
|
|
41
|
+
function NodeProcessVariable(n, RED, node) {
|
|
42
|
+
var _this = this;
|
|
43
|
+
this.options = { qos: 1 };
|
|
44
|
+
this.broker = RED.nodes.getNode(n.device).broker;
|
|
45
|
+
this.node = node;
|
|
46
|
+
this.assetId = n.assetId;
|
|
47
|
+
this.node.on('input', (function (msg) { return _this.onInput(msg); }));
|
|
48
|
+
this.broker.on('statusUpdate', function (report) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
_this.node.status({
|
|
51
|
+
fill: report.status === 'connected' ? 'green' : 'red',
|
|
52
|
+
shape: 'ring',
|
|
53
|
+
text: ((_b = (_a = report === null || report === void 0 ? void 0 : report.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || report.status
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
NodeProcessVariable.prototype.onInput = function (msg) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var body, topic, payload, finalPayload, buffer, _a, result, error, e_1, e_2;
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
_b.trys.push([0, 8, , 9]);
|
|
64
|
+
if (!this.broker) return [3 /*break*/, 6];
|
|
65
|
+
this.node.status({
|
|
66
|
+
fill: "blue",
|
|
67
|
+
shape: "ring",
|
|
68
|
+
text: "sending..."
|
|
69
|
+
});
|
|
70
|
+
return [4 /*yield*/, this.broker.connect()];
|
|
71
|
+
case 1:
|
|
72
|
+
_b.sent();
|
|
73
|
+
body = {
|
|
74
|
+
assetId: this.assetId,
|
|
75
|
+
processVariableId: this.processVariableId,
|
|
76
|
+
timestamp: new Date().toISOString()
|
|
77
|
+
};
|
|
78
|
+
topic = "$aws/rules/".concat(this.broker.environment, "_edge_data/").concat(this.broker.tenant, "/").concat(this.broker.clientId, "/timeseries");
|
|
79
|
+
if (body.assetId < 1)
|
|
80
|
+
body.assetId = msg.topic;
|
|
81
|
+
payload = void 0;
|
|
82
|
+
if (typeof msg.payload === 'object') {
|
|
83
|
+
body = Object.assign(body, msg.payload);
|
|
39
84
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var buffer = new Buffer(JSON.stringify(finalPayload), "utf-8");
|
|
44
|
-
self.status({
|
|
45
|
-
fill: "blue",
|
|
46
|
-
shape: "ring",
|
|
47
|
-
text: "sending..."
|
|
48
|
-
});
|
|
49
|
-
try {
|
|
50
|
-
self.broker.mqttClient.publish(topic, buffer, options.qos, false).then(function (result, error) {
|
|
51
|
-
if (error) {
|
|
52
|
-
self.status({
|
|
53
|
-
fill: "red",
|
|
54
|
-
shape: "ring",
|
|
55
|
-
text: error.message
|
|
56
|
-
});
|
|
85
|
+
else {
|
|
86
|
+
if (this.dataType === 'number') {
|
|
87
|
+
body['numericValue'] = msg.payload;
|
|
57
88
|
}
|
|
58
|
-
else {
|
|
59
|
-
|
|
60
|
-
fill: "green",
|
|
61
|
-
shape: "ring",
|
|
62
|
-
text: "done"
|
|
63
|
-
});
|
|
89
|
+
else if (this.dataType === 'string') {
|
|
90
|
+
body['stringValue'] = msg.payload;
|
|
64
91
|
}
|
|
92
|
+
else if (this.dataType === 'boolean') {
|
|
93
|
+
body['booleanValue'] = msg.payload;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
finalPayload = { format: 'json', body: [body] };
|
|
97
|
+
this.node.log("SEND> " + topic + ' ' + JSON.stringify(finalPayload));
|
|
98
|
+
buffer = new Buffer(JSON.stringify(finalPayload), "utf-8");
|
|
99
|
+
_b.label = 2;
|
|
100
|
+
case 2:
|
|
101
|
+
_b.trys.push([2, 4, , 5]);
|
|
102
|
+
return [4 /*yield*/, this.broker.mqttClient.publish(topic, buffer, this.options.qos, false)];
|
|
103
|
+
case 3:
|
|
104
|
+
_a = _b.sent(), result = _a.result, error = _a.error;
|
|
105
|
+
if (error) {
|
|
106
|
+
this.node.status({
|
|
107
|
+
fill: "red",
|
|
108
|
+
shape: "ring",
|
|
109
|
+
text: error.message
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
this.node.status({
|
|
114
|
+
fill: "green",
|
|
115
|
+
shape: "ring",
|
|
116
|
+
text: "sent"
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return [3 /*break*/, 5];
|
|
120
|
+
case 4:
|
|
121
|
+
e_1 = _b.sent();
|
|
122
|
+
this.node.status({
|
|
123
|
+
fill: "red",
|
|
124
|
+
shape: "ring",
|
|
125
|
+
text: e_1.message
|
|
65
126
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
127
|
+
return [3 /*break*/, 5];
|
|
128
|
+
case 5: return [3 /*break*/, 7];
|
|
129
|
+
case 6:
|
|
130
|
+
this.node.error("connection is not configured");
|
|
131
|
+
this.node.status({
|
|
69
132
|
fill: "red",
|
|
70
133
|
shape: "ring",
|
|
71
|
-
text:
|
|
134
|
+
text: "not configured"
|
|
72
135
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
136
|
+
_b.label = 7;
|
|
137
|
+
case 7: return [3 /*break*/, 9];
|
|
138
|
+
case 8:
|
|
139
|
+
e_2 = _b.sent();
|
|
140
|
+
this.node.error("something went wrong", e_2);
|
|
141
|
+
this.node.status({
|
|
142
|
+
fill: "red",
|
|
143
|
+
shape: "ring",
|
|
144
|
+
text: e_2.message
|
|
145
|
+
});
|
|
146
|
+
return [3 /*break*/, 9];
|
|
147
|
+
case 9: return [2 /*return*/];
|
|
82
148
|
}
|
|
83
149
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
return NodeProcessVariable;
|
|
153
|
+
}());
|
|
154
|
+
var buildNodePvFunction = function (RED) { return (function awsMqttNodePv(n) {
|
|
155
|
+
RED.nodes.createNode(this, n);
|
|
156
|
+
this.tillitProcessVariable = new NodeProcessVariable(n, RED, this);
|
|
94
157
|
}); };
|
|
95
158
|
exports.buildNodePvFunction = buildNodePvFunction;
|
|
96
159
|
//# sourceMappingURL=node-pv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-pv.js","sourceRoot":"","sources":["../../src/nodes/node-pv.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-pv.js","sourceRoot":"","sources":["../../src/nodes/node-pv.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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