homey-api 1.4.0 → 1.4.4
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/README.md +1 -1
- package/assets/specifications/AthomAppsAPI.json +11 -0
- package/lib/API.js +1 -1
- package/lib/AthomCloudAPI.js +9 -2
- package/lib/HomeyAPI/HomeyAPIV2.js +29 -23
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ const AthomCloudAPI = require('homey-api/lib/AthomCloudAPI');
|
|
|
35
35
|
Include Homey API from our CDN:
|
|
36
36
|
|
|
37
37
|
```html
|
|
38
|
-
<script type="text/javascript" src="https://cdn.athom.com/homey-api
|
|
38
|
+
<script type="text/javascript" src="https://cdn.athom.com/homey-api/$VERSION.js"></script>
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
You can then access the APIs using `window.AthomCloudAPI` etc.
|
|
@@ -140,6 +140,17 @@
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
|
+
"getAppChangelog": {
|
|
144
|
+
"path": "/app/{appId}/changelog",
|
|
145
|
+
"method": "get",
|
|
146
|
+
"parameters": {
|
|
147
|
+
"appId": {
|
|
148
|
+
"in": "path",
|
|
149
|
+
"type": "string",
|
|
150
|
+
"required": true
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
143
154
|
"updateAppAuthor": {
|
|
144
155
|
"path": "/app/{appId}/author",
|
|
145
156
|
"method": "put",
|
package/lib/API.js
CHANGED
|
@@ -195,7 +195,7 @@ class API {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// Body
|
|
198
|
-
if (['PUT', 'POST'].includes(request.method)) {
|
|
198
|
+
if (['PUT', 'POST', 'DELETE'].includes(request.method)) {
|
|
199
199
|
if (request.body && request.bodyJSON !== false) {
|
|
200
200
|
request.headers['Content-Type'] = 'application/json';
|
|
201
201
|
|
package/lib/AthomCloudAPI.js
CHANGED
|
@@ -13,6 +13,13 @@ const StorageAdapterNodeJS = require('./AthomCloudAPI/StorageAdapterNodeJS');
|
|
|
13
13
|
|
|
14
14
|
class AthomCloudAPI extends API {
|
|
15
15
|
|
|
16
|
+
static User = User;
|
|
17
|
+
static Homey = Homey;
|
|
18
|
+
static Token = Token;
|
|
19
|
+
static StorageAdapter = StorageAdapter;
|
|
20
|
+
static StorageAdapterBrowser = StorageAdapterBrowser;
|
|
21
|
+
static StorageAdapterNodeJS = StorageAdapterNodeJS;
|
|
22
|
+
|
|
16
23
|
static SPECIFICATION = require('../assets/specifications/AthomCloudAPI.json');
|
|
17
24
|
static SPECIFICATION_URL = 'https://api.athom.com/specification.json';
|
|
18
25
|
static DEFINITION_CLASSES = {
|
|
@@ -112,7 +119,7 @@ for(const device of Object.values(devices)) {
|
|
|
112
119
|
async isLoggedIn() {
|
|
113
120
|
const store = await this.__getStore();
|
|
114
121
|
if (!store.token
|
|
115
|
-
|
|
122
|
+
|| !store.token.access_token) return false;
|
|
116
123
|
|
|
117
124
|
try {
|
|
118
125
|
this.__user = await this.getAuthenticatedUser({
|
|
@@ -484,7 +491,7 @@ for(const device of Object.values(devices)) {
|
|
|
484
491
|
});
|
|
485
492
|
|
|
486
493
|
this.__refreshTokenPromise
|
|
487
|
-
.catch(() => {})
|
|
494
|
+
.catch(() => { })
|
|
488
495
|
.finally(() => {
|
|
489
496
|
this.__refreshTokenPromise = null;
|
|
490
497
|
});
|
|
@@ -275,24 +275,30 @@ class HomeyAPIV2 extends HomeyAPI {
|
|
|
275
275
|
pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL_SECURE]
|
|
276
276
|
.then(result => resolve(result))
|
|
277
277
|
.catch(() => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
278
|
+
const promises = [];
|
|
279
|
+
|
|
280
|
+
if (pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]) {
|
|
281
|
+
promises.push(pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (pings[HomeyAPI.DISCOVERY_STRATEGIES.MDNS]) {
|
|
285
|
+
promises.push(pings[HomeyAPI.DISCOVERY_STRATEGIES.MDNS]);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// TODO: Move this to the catch handler to always fallback on cloud
|
|
289
|
+
// Now mdns or local will error first and cloud won't have a chance!!
|
|
290
|
+
if (pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD]) {
|
|
291
|
+
promises.push(pings[HomeyAPI.DISCOVERY_STRATEGIES.CLOUD]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!promises.length) {
|
|
295
|
+
throw new HomeyOfflineError();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return Promise.race(promises);
|
|
299
|
+
})
|
|
300
|
+
.then(result => resolve(result))
|
|
301
|
+
.catch(() => reject(new HomeyOfflineError()));
|
|
296
302
|
} else if (pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]) {
|
|
297
303
|
pings[HomeyAPI.DISCOVERY_STRATEGIES.LOCAL]
|
|
298
304
|
.then(result => resolve(result))
|
|
@@ -466,11 +472,11 @@ class HomeyAPIV2 extends HomeyAPI {
|
|
|
466
472
|
}
|
|
467
473
|
|
|
468
474
|
async subscribe(uri, {
|
|
469
|
-
onConnect = () => {},
|
|
470
|
-
onReconnect = () => {},
|
|
471
|
-
onReconnectError = () => {},
|
|
472
|
-
onDisconnect = () => {},
|
|
473
|
-
onEvent = () => {},
|
|
475
|
+
onConnect = () => { },
|
|
476
|
+
onReconnect = () => { },
|
|
477
|
+
onReconnectError = () => { },
|
|
478
|
+
onDisconnect = () => { },
|
|
479
|
+
onEvent = () => { },
|
|
474
480
|
}) {
|
|
475
481
|
this.__debug('subscribe', uri);
|
|
476
482
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homey-api",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Homey API",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "assets/types/homey-api.d.ts",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"ejs": "^3.1.6",
|
|
53
53
|
"eslint": "^7.32.0",
|
|
54
54
|
"eslint-config-athom": "^2.1.1",
|
|
55
|
-
"filemanager-webpack-plugin": "^5.0.0",
|
|
56
55
|
"fs-extra": "^10.0.0",
|
|
57
56
|
"homey-jsdoc-template": "github:athombv/homey-jsdoc-template#1.4",
|
|
58
57
|
"http-server": "^0.12.3",
|