homey-api 3.4.15 → 3.4.17
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/HomeyAPI/HomeyAPIV3.js +25 -2
- package/package.json +1 -1
|
@@ -72,6 +72,12 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
72
72
|
writable: true,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
Object.defineProperty(this, '__destroyed', {
|
|
76
|
+
value: false,
|
|
77
|
+
enumerable: false,
|
|
78
|
+
writable: true,
|
|
79
|
+
});
|
|
80
|
+
|
|
75
81
|
Object.defineProperty(this, '__token', {
|
|
76
82
|
value: token,
|
|
77
83
|
enumerable: false,
|
|
@@ -297,7 +303,7 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
297
303
|
|
|
298
304
|
// Ping localSecure (https://xxx-xxx-xxx-xx.homey.homeylocal.com)
|
|
299
305
|
if (urls[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE]) {
|
|
300
|
-
pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE] = ping(HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE,
|
|
306
|
+
pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE] = ping(HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE, 5000);
|
|
301
307
|
pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE].catch(err => {
|
|
302
308
|
this.__debug(`Ping ${HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE} Error:`, err && err.message)
|
|
303
309
|
this.__debug(urls[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE]);
|
|
@@ -779,6 +785,8 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
779
785
|
}
|
|
780
786
|
|
|
781
787
|
destroy() {
|
|
788
|
+
this.__destroyed = true;
|
|
789
|
+
|
|
782
790
|
if (this.__homeySocket) {
|
|
783
791
|
this.__homeySocket.removeAllListeners();
|
|
784
792
|
this.__homeySocket.close();
|
|
@@ -794,6 +802,10 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
794
802
|
this.removeAllListeners();
|
|
795
803
|
}
|
|
796
804
|
|
|
805
|
+
isDestroyed() {
|
|
806
|
+
return this.__destroyed;
|
|
807
|
+
}
|
|
808
|
+
|
|
797
809
|
async __handshakeClient() {
|
|
798
810
|
this.__debug('__handshakeClient');
|
|
799
811
|
|
|
@@ -839,7 +851,18 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
839
851
|
token: this.__token,
|
|
840
852
|
homeyId: this.id,
|
|
841
853
|
}, (err, result) => {
|
|
842
|
-
if (err)
|
|
854
|
+
if (err) {
|
|
855
|
+
if (err instanceof Error) {
|
|
856
|
+
return reject(err)
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
if (typeof err === 'object') {
|
|
860
|
+
return reject(new Error(err.message));
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
return reject(new Error(String(err)));
|
|
864
|
+
}
|
|
865
|
+
|
|
843
866
|
return resolve(result);
|
|
844
867
|
});
|
|
845
868
|
});
|