iobroker.parcel 0.0.6 → 0.0.7
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/io-package.json +16 -1
- package/main.js +39 -3
- package/package.json +1 -1
package/io-package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "parcel",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.0.7": {
|
|
7
|
+
"en": "Datenpunkt für in Zustellung hinzugefügt, Fix für wiederholende Benachrichtigungen"
|
|
8
|
+
},
|
|
6
9
|
"0.0.6": {
|
|
7
10
|
"en": "initial release",
|
|
8
11
|
"de": "Erstveröffentlichung",
|
|
@@ -166,6 +169,18 @@
|
|
|
166
169
|
},
|
|
167
170
|
"native": {}
|
|
168
171
|
},
|
|
172
|
+
{
|
|
173
|
+
"_id": "inDelivery",
|
|
174
|
+
"type": "state",
|
|
175
|
+
"common": {
|
|
176
|
+
"role": "state",
|
|
177
|
+
"name": "In delivery packages",
|
|
178
|
+
"type": "json",
|
|
179
|
+
"read": true,
|
|
180
|
+
"write": false
|
|
181
|
+
},
|
|
182
|
+
"native": {}
|
|
183
|
+
},
|
|
169
184
|
{
|
|
170
185
|
"_id": "auth",
|
|
171
186
|
"type": "channel",
|
package/main.js
CHANGED
|
@@ -32,6 +32,7 @@ class Parcel extends utils.Adapter {
|
|
|
32
32
|
this.json2iob = new Json2iob(this);
|
|
33
33
|
this.sessions = {};
|
|
34
34
|
this.mergedJson = [];
|
|
35
|
+
this.inDelivery = [];
|
|
35
36
|
this.mergedJsonObject = {};
|
|
36
37
|
this.images = {};
|
|
37
38
|
this.alreadySentMessages = {};
|
|
@@ -48,6 +49,10 @@ class Parcel extends utils.Adapter {
|
|
|
48
49
|
this.config.interval = 0.5;
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
// const alreadySentMessagesState = await this.getStateAsync("alreadySentMessages");
|
|
53
|
+
// if (alreadySentMessagesState && alreadySentMessagesState.val) {
|
|
54
|
+
// this.alreadySentMessages = JSON.parse(alreadySentMessagesState.val);
|
|
55
|
+
// }
|
|
51
56
|
this.cookieJar = new tough.CookieJar();
|
|
52
57
|
const cookieState = await this.getStateAsync("auth.cookie");
|
|
53
58
|
if (cookieState && cookieState.val) {
|
|
@@ -508,12 +513,18 @@ class Parcel extends utils.Adapter {
|
|
|
508
513
|
})
|
|
509
514
|
.then(async (res) => {
|
|
510
515
|
this.sessions["gls"] = res.data;
|
|
516
|
+
if (!res.data.token) {
|
|
517
|
+
this.log.error(res.data);
|
|
518
|
+
}
|
|
511
519
|
this.glstoken = res.data.token;
|
|
512
520
|
})
|
|
513
521
|
.catch(async (error) => {
|
|
514
522
|
error.response && this.log.error(JSON.stringify(error.response.data));
|
|
515
523
|
this.log.error(error);
|
|
516
524
|
});
|
|
525
|
+
if (!this.glstoken) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
517
528
|
await this.requestClient({
|
|
518
529
|
method: "get",
|
|
519
530
|
url: "https://gls-one.de/api/auth/login",
|
|
@@ -524,7 +535,7 @@ class Parcel extends utils.Adapter {
|
|
|
524
535
|
Accept: "application/json, text/plain, */*",
|
|
525
536
|
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",
|
|
526
537
|
"X-Client-Id": "iOS",
|
|
527
|
-
"X-Auth-Token": this.
|
|
538
|
+
"X-Auth-Token": this.glstoken,
|
|
528
539
|
},
|
|
529
540
|
jar: this.cookieJar,
|
|
530
541
|
withCredentials: true,
|
|
@@ -664,12 +675,14 @@ class Parcel extends utils.Adapter {
|
|
|
664
675
|
this.log.debug(JSON.stringify(res.data));
|
|
665
676
|
if (
|
|
666
677
|
res.data.GetEnrollmentsResponse &&
|
|
678
|
+
res.data.GetEnrollmentsResponse.MYCEnrollmentSummaries &&
|
|
667
679
|
res.data.GetEnrollmentsResponse.MYCEnrollmentSummaries.MYCEnrollmentSummary &&
|
|
668
680
|
res.data.GetEnrollmentsResponse.MYCEnrollmentSummaries.MYCEnrollmentSummary.AddressToken
|
|
669
681
|
) {
|
|
670
682
|
this.upsAddressToken = res.data.GetEnrollmentsResponse.MYCEnrollmentSummaries.MYCEnrollmentSummary.AddressToken;
|
|
671
683
|
} else {
|
|
672
684
|
this.log.warn("No UPS address found");
|
|
685
|
+
this.log.info(JSON.stringify(res.data));
|
|
673
686
|
}
|
|
674
687
|
})
|
|
675
688
|
.catch(async (error) => {
|
|
@@ -810,6 +823,7 @@ class Parcel extends utils.Adapter {
|
|
|
810
823
|
let dataDhl = [];
|
|
811
824
|
this.mergedJson = [];
|
|
812
825
|
this.mergedJsonObject = {};
|
|
826
|
+
this.inDelivery = [];
|
|
813
827
|
if (this.sessions["17track"]) {
|
|
814
828
|
try {
|
|
815
829
|
const trackList = await this.getStateAsync("17t.trackList");
|
|
@@ -1071,6 +1085,7 @@ class Parcel extends utils.Adapter {
|
|
|
1071
1085
|
}
|
|
1072
1086
|
const sendungsObject = { id: sendung.id, name: sendung.sendungsinfo.sendungsname, status: status, source: "DHL", direction: sendung.sendungsinfo.sendungsrichtung };
|
|
1073
1087
|
this.mergedJsonObject[sendung.id] = sendungsObject;
|
|
1088
|
+
this.inDeliveryCheck(sendungsObject);
|
|
1074
1089
|
return sendungsObject;
|
|
1075
1090
|
});
|
|
1076
1091
|
this.mergedJson = this.mergedJson.concat(sendungsArray);
|
|
@@ -1079,6 +1094,7 @@ class Parcel extends utils.Adapter {
|
|
|
1079
1094
|
const sendungsArray = data.sendungen.map((sendung) => {
|
|
1080
1095
|
const sendungsObject = { id: sendung.id, name: sendung.label || sendung.parcelNumber, status: sendung.status, source: "GLS", direction: sendung.type };
|
|
1081
1096
|
this.mergedJsonObject[sendung.id] = sendungsObject;
|
|
1097
|
+
this.inDeliveryCheck(sendungsObject);
|
|
1082
1098
|
return sendungsObject;
|
|
1083
1099
|
});
|
|
1084
1100
|
this.mergedJson = this.mergedJson.concat(sendungsArray);
|
|
@@ -1087,6 +1103,7 @@ class Parcel extends utils.Adapter {
|
|
|
1087
1103
|
const sendungsArray = data.sendungen.map((sendung) => {
|
|
1088
1104
|
const sendungsObject = { id: sendung.id, name: sendung.shipFromName, status: sendung.locStatus || sendung.status, source: "UPS" };
|
|
1089
1105
|
this.mergedJsonObject[sendung.id] = sendungsObject;
|
|
1106
|
+
this.inDeliveryCheck(sendungsObject);
|
|
1090
1107
|
return sendungsObject;
|
|
1091
1108
|
});
|
|
1092
1109
|
this.mergedJson = this.mergedJson.concat(sendungsArray);
|
|
@@ -1096,6 +1113,7 @@ class Parcel extends utils.Adapter {
|
|
|
1096
1113
|
for (const sendung of data.sendungen) {
|
|
1097
1114
|
sendung.source = "DPD";
|
|
1098
1115
|
this.mergedJsonObject[sendung.id] = sendung;
|
|
1116
|
+
this.inDeliveryCheck(sendung);
|
|
1099
1117
|
}
|
|
1100
1118
|
this.mergedJson = this.mergedJson.concat(data.sendungen);
|
|
1101
1119
|
}
|
|
@@ -1103,6 +1121,7 @@ class Parcel extends utils.Adapter {
|
|
|
1103
1121
|
for (const sendung of data.sendungen) {
|
|
1104
1122
|
sendung.source = "AMZ";
|
|
1105
1123
|
this.mergedJsonObject[sendung.id] = sendung;
|
|
1124
|
+
this.inDeliveryCheck(sendung);
|
|
1106
1125
|
}
|
|
1107
1126
|
this.mergedJson = this.mergedJson.concat(data.sendungen);
|
|
1108
1127
|
}
|
|
@@ -1111,6 +1130,7 @@ class Parcel extends utils.Adapter {
|
|
|
1111
1130
|
const sendungsObject = { id: sendung.number, name: sendung.number, status: sendung.track.z0 ? sendung.track.z0.z : "", source: "17track" };
|
|
1112
1131
|
if (!this.mergedJsonObject[sendung.id]) {
|
|
1113
1132
|
this.mergedJsonObject[sendung.id] = sendungsObject;
|
|
1133
|
+
this.inDeliveryCheck(sendungsObject);
|
|
1114
1134
|
}
|
|
1115
1135
|
return sendungsObject;
|
|
1116
1136
|
});
|
|
@@ -1125,6 +1145,7 @@ class Parcel extends utils.Adapter {
|
|
|
1125
1145
|
const sendungsObject = { id: sendung.FTrackNo, name: sendung.FTrackInfoId, status: sendung.FLastEvent ? sendung.FLastEvent.z : "", source: "17tuser" };
|
|
1126
1146
|
if (!this.mergedJsonObject[sendung.id]) {
|
|
1127
1147
|
this.mergedJsonObject[sendung.id] = sendungsObject;
|
|
1148
|
+
this.inDeliveryCheck(sendungsObject);
|
|
1128
1149
|
}
|
|
1129
1150
|
return sendungsObject;
|
|
1130
1151
|
} catch (error) {
|
|
@@ -1136,18 +1157,33 @@ class Parcel extends utils.Adapter {
|
|
|
1136
1157
|
|
|
1137
1158
|
this.setState("allProviderJson", JSON.stringify(this.mergedJson), true);
|
|
1138
1159
|
this.setState("allProviderObjects", JSON.stringify(this.mergedJsonObject), true);
|
|
1160
|
+
this.setState("inDelivery", JSON.stringify(this.inDelivery), true);
|
|
1161
|
+
|
|
1139
1162
|
if (this.config.sendToActive) {
|
|
1140
1163
|
const sendungen = this.mergedJsonObject;
|
|
1141
1164
|
const ids = Object.keys(sendungen);
|
|
1142
1165
|
for (const id of ids) {
|
|
1143
|
-
if (this.alreadySentMessages[id] === sendungen[id].status) {
|
|
1166
|
+
if (this.alreadySentMessages[id + sendungen[id].source] === sendungen[id].status) {
|
|
1144
1167
|
continue;
|
|
1145
1168
|
}
|
|
1146
1169
|
this.sendTo(this.config.sendToInstance, "📦 " + sendungen[id].name + "\n" + sendungen[id].status);
|
|
1147
|
-
this.alreadySentMessages[id] = sendungen[id].status;
|
|
1170
|
+
this.alreadySentMessages[id + sendungen[id].source] = sendungen[id].status;
|
|
1148
1171
|
}
|
|
1172
|
+
|
|
1173
|
+
// this.setState("alreadySentMessages", JSON.stringify(this.alreadySentMessages), true);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
inDeliveryCheck(sendungsObject) {
|
|
1177
|
+
if (
|
|
1178
|
+
sendungsObject.status.toLocaleLowerCase().includes("in zustellung") ||
|
|
1179
|
+
(sendungsObject.status.toLocaleLowerCase().includes("heute") && !sendungsObject.status.toLocaleLowerCase().includes("heute bestellt")) ||
|
|
1180
|
+
sendungsObject.status.toLocaleLowerCase().includes("wird zugestellt") ||
|
|
1181
|
+
sendungsObject.status.toLocaleLowerCase().includes("zustellfahrzeug")
|
|
1182
|
+
) {
|
|
1183
|
+
this.inDelivery.push(sendungsObject);
|
|
1149
1184
|
}
|
|
1150
1185
|
}
|
|
1186
|
+
|
|
1151
1187
|
async activateToken(grant_token, url) {
|
|
1152
1188
|
await this.requestClient({
|
|
1153
1189
|
method: "post",
|