homey-api 3.0.10 → 3.0.12
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/assets/specifications/HomeyAPIV3Cloud.json +225 -36
- package/assets/specifications/HomeyAPIV3Local.json +168 -7
- package/assets/types/homey-api.d.ts +57 -11
- package/assets/types/homey-api.private.d.ts +81 -11
- package/lib/AthomCloudAPI/User.js +2 -0
- package/lib/AthomCloudAPI.js +71 -17
- package/lib/EventEmitter.js +1 -0
- package/lib/HomeyAPI/HomeyAPIV2/ManagerDevices/Device.js +0 -1
- package/lib/HomeyAPI/HomeyAPIV2/ManagerDrivers/Driver.js +1 -1
- package/lib/HomeyAPI/HomeyAPIV3/Manager.js +233 -176
- package/lib/HomeyAPI/HomeyAPIV3/ManagerDevices/Capability.js +5 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerDevices/Device.js +24 -10
- package/lib/HomeyAPI/HomeyAPIV3/ManagerDevices/DeviceCapability.js +2 -2
- package/lib/HomeyAPI/HomeyAPIV3/ManagerDrivers/Driver.js +10 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerDrivers/PairSession.js +8 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerFlow/FlowCardAction.js +10 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerFlow/FlowCardCondition.js +10 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerFlow/FlowCardTrigger.js +10 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerFlowToken/FlowToken.js +15 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerInsights/Log.js +15 -0
- package/lib/HomeyAPI/HomeyAPIV3/ManagerUsers.js +57 -0
- package/lib/HomeyAPI/HomeyAPIV3.js +20 -4
- package/package.json +1 -1
|
@@ -24,6 +24,21 @@ class Log extends Item {
|
|
|
24
24
|
return item;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
get uri() {
|
|
28
|
+
console.warn('Log.uri is deprecated. Use Log.ownerUri instead.');
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get uriObj() {
|
|
33
|
+
console.warn('Log.uriObj is deprecated.');
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get ownerName() {
|
|
38
|
+
console.warn('Log.ownerName is deprecated.');
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
module.exports = Log;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Manager = require('./Manager');
|
|
4
|
+
|
|
5
|
+
class ManagerUsers extends Manager {
|
|
6
|
+
|
|
7
|
+
__userMe = null;
|
|
8
|
+
|
|
9
|
+
async getUserMe(...args) {
|
|
10
|
+
const options = args[0] ?? {};
|
|
11
|
+
|
|
12
|
+
if (this.__userMe != null && options.$cache !== false) {
|
|
13
|
+
return await this.__userMe;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// TODO
|
|
17
|
+
//
|
|
18
|
+
// - remove on disconnect manager users
|
|
19
|
+
|
|
20
|
+
this.__userMe = this.__super__getUserMe(...args)
|
|
21
|
+
.then((result) => {
|
|
22
|
+
const ItemClass = this.itemClasses.User;
|
|
23
|
+
const props = ItemClass.transformGet(result);
|
|
24
|
+
|
|
25
|
+
if (this.isConnected()) {
|
|
26
|
+
if (this.__cache[ItemClass.ID][props.id] != null) {
|
|
27
|
+
this.__cache[ItemClass.ID][props.id].__update(props);
|
|
28
|
+
} else {
|
|
29
|
+
this.__cache[ItemClass.ID][props.id] = new ItemClass({
|
|
30
|
+
id: props.id,
|
|
31
|
+
homey: this.homey,
|
|
32
|
+
manager: this,
|
|
33
|
+
properties: props,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this.__cache[ItemClass.ID][props.id];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return new ItemClass({
|
|
41
|
+
id: props.id,
|
|
42
|
+
homey: this.homey,
|
|
43
|
+
manager: this,
|
|
44
|
+
properties: props,
|
|
45
|
+
});
|
|
46
|
+
})
|
|
47
|
+
.catch(err => {
|
|
48
|
+
this.__userMe = null;
|
|
49
|
+
throw err;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return await this.__userMe;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = ManagerUsers;
|
|
@@ -11,6 +11,7 @@ const ManagerDevices = require('./HomeyAPIV3/ManagerDevices');
|
|
|
11
11
|
const ManagerFlow = require('./HomeyAPIV3/ManagerFlow');
|
|
12
12
|
const ManagerFlowToken = require('./HomeyAPIV3/ManagerFlowToken');
|
|
13
13
|
const ManagerInsights = require('./HomeyAPIV3/ManagerInsights');
|
|
14
|
+
const ManagerUsers = require('./HomeyAPIV3/ManagerUsers');
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line no-unused-vars
|
|
16
17
|
const Manager = require('./HomeyAPIV3/Manager');
|
|
@@ -30,6 +31,7 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
30
31
|
ManagerFlow,
|
|
31
32
|
ManagerFlowToken,
|
|
32
33
|
ManagerInsights,
|
|
34
|
+
ManagerUsers,
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
constructor({
|
|
@@ -143,8 +145,9 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
143
145
|
if (!this.__managers[managerName]) {
|
|
144
146
|
const ManagerClass = this.constructor.MANAGERS[managerName]
|
|
145
147
|
? this.constructor.MANAGERS[managerName]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
: (() => {
|
|
149
|
+
return class extends Manager {};
|
|
150
|
+
})();
|
|
148
151
|
|
|
149
152
|
ManagerClass.ID = manager.id;
|
|
150
153
|
|
|
@@ -416,6 +419,11 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
416
419
|
|
|
417
420
|
const resStatusText = res.status;
|
|
418
421
|
const resHeadersContentType = res.headers.get('Content-Type');
|
|
422
|
+
const version = res.headers.get('x-homey-version');
|
|
423
|
+
if (version) this.version = version;
|
|
424
|
+
const tier = res.headers.get('x-homey-tier');
|
|
425
|
+
if (tier) this.tier = tier;
|
|
426
|
+
|
|
419
427
|
const resBodyText = await res.text();
|
|
420
428
|
let resBodyJson;
|
|
421
429
|
if (resHeadersContentType && resHeadersContentType.startsWith('application/json')) {
|
|
@@ -545,7 +553,11 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
545
553
|
await new Promise((resolve, reject) => {
|
|
546
554
|
this.__ioNamespace.once('disconnect', reject);
|
|
547
555
|
this.__ioNamespace.emit('subscribe', uri, err => {
|
|
548
|
-
if (err)
|
|
556
|
+
if (err) {
|
|
557
|
+
this.__debug('Failed to subscribe', uri, err);
|
|
558
|
+
return reject(err)
|
|
559
|
+
}
|
|
560
|
+
|
|
549
561
|
return resolve();
|
|
550
562
|
});
|
|
551
563
|
});
|
|
@@ -570,7 +582,11 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
570
582
|
await this.connect();
|
|
571
583
|
await new Promise((resolve, reject) => {
|
|
572
584
|
this.__ioNamespace.emit('subscribe', uri, err => {
|
|
573
|
-
if (err)
|
|
585
|
+
if (err) {
|
|
586
|
+
this.__debug('Failed to subscribe', uri, err);
|
|
587
|
+
return reject(err)
|
|
588
|
+
}
|
|
589
|
+
|
|
574
590
|
return resolve();
|
|
575
591
|
});
|
|
576
592
|
});
|