homebridge-deconz 0.1.17 → 0.1.19
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/cli/deconz.js +4 -975
- package/homebridge-ui/server.js +2 -2
- package/lib/Deconz/Resource.js +4 -19
- package/lib/Deconz/index.js +0 -5
- package/lib/DeconzAccessory/Gateway.js +4 -4
- package/lib/DeconzAccessory/index.js +3 -3
- package/lib/DeconzPlatform.js +2 -2
- package/lib/DeconzService/AirQuality.js +2 -2
- package/lib/DeconzService/Battery.js +2 -2
- package/lib/DeconzService/Consumption.js +2 -2
- package/lib/DeconzService/Daylight.js +2 -2
- package/lib/DeconzService/LightLevel.js +2 -2
- package/lib/DeconzService/LightsResource.js +2 -2
- package/lib/DeconzService/Motion.js +1 -2
- package/lib/DeconzService/Power.js +2 -2
- package/lib/DeconzService/Schedule.js +2 -2
- package/lib/DeconzService/SensorsResource.js +6 -3
- package/lib/DeconzService/index.js +2 -2
- package/package.json +4 -5
- package/lib/Deconz/ApiClient.js +0 -442
- package/lib/Deconz/ApiError.js +0 -49
- package/lib/Deconz/ApiResponse.js +0 -57
- package/lib/Deconz/Discovery.js +0 -238
- package/lib/Deconz/WsClient.js +0 -205
package/homebridge-ui/server.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
'use strict'
|
7
7
|
|
8
8
|
const { UiServer } = require('homebridge-lib')
|
9
|
-
const
|
9
|
+
const { Discovery } = require('hb-deconz-tools')
|
10
10
|
|
11
11
|
class DeconzUiServer extends UiServer {
|
12
12
|
constructor () {
|
@@ -14,7 +14,7 @@ class DeconzUiServer extends UiServer {
|
|
14
14
|
|
15
15
|
this.onRequest('discover', async (params) => {
|
16
16
|
if (this.discovery == null) {
|
17
|
-
this.discovery = new
|
17
|
+
this.discovery = new Discovery({
|
18
18
|
// forceHttp: this.config.forceHttp,
|
19
19
|
// timeout: this.config.timeout
|
20
20
|
})
|
package/lib/Deconz/Resource.js
CHANGED
@@ -6,17 +6,16 @@
|
|
6
6
|
'use strict'
|
7
7
|
|
8
8
|
const { OptionParser } = require('homebridge-lib')
|
9
|
-
const
|
9
|
+
const { ApiClient } = require('hb-deconz-tools')
|
10
10
|
const DeconzAccessory = require('../DeconzAccessory')
|
11
11
|
const DeconzService = require('../DeconzService')
|
12
12
|
|
13
13
|
const { toInstance, toInt, toObject, toString } = OptionParser
|
14
|
-
const { buttonEvent } =
|
14
|
+
const { buttonEvent } = ApiClient
|
15
15
|
const { SINGLE, DOUBLE, LONG } = DeconzService.Button
|
16
16
|
const rtypes = ['lights', 'sensors', 'groups']
|
17
17
|
|
18
18
|
const patterns = {
|
19
|
-
uniqueid: /^([0-9a-f]{1,2}(?:[:-]?(?:[0-9a-f]{1,2})){7})-([0-9a-z]{2})(?:-([0-9a-z]{4}))?$/i,
|
20
19
|
clipId: /^(S[0-9]{1,3})-([0-9a-z]{2})-([0-9a-z]{4})$/i,
|
21
20
|
swversion: /^([0-9]+)(?:\.([0-9]+)(?:\.([0-9]+)(?:_([0-9]{4}))?)?)?$/
|
22
21
|
}
|
@@ -52,20 +51,6 @@ const hueTapMap = {
|
|
52
51
|
* @memberof Deconz
|
53
52
|
*/
|
54
53
|
class Resource {
|
55
|
-
/** Parse the `uniqueid` in the resource body of a resource for a Zigbee device.
|
56
|
-
* @param {string} uniqueid - The `uniqueid`.
|
57
|
-
* @return {object} The Zigbee `mac`, `endpoint`, and `cluster`.
|
58
|
-
*/
|
59
|
-
static parseUniqueid (uniqueid) {
|
60
|
-
toString('uniqueid', uniqueid, true)
|
61
|
-
const a = patterns.uniqueid.exec(uniqueid.replace(/:/g, '').toUpperCase())
|
62
|
-
return {
|
63
|
-
mac: a?.[1],
|
64
|
-
endpoint: a?.[2],
|
65
|
-
cluster: a?.[3]
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
54
|
/** Parse the `uniqueid` in the resource body of a resource for a CLIP sensor.
|
70
55
|
* @param {string} uniqueid - The `uniqueid`.
|
71
56
|
* @return {object} The MultiCLIP `id`, `endpoint`, and `cluster`.
|
@@ -132,7 +117,7 @@ class Resource {
|
|
132
117
|
this.rtype === 'lights' ||
|
133
118
|
(this.rtype === 'sensors' && this.body.type.startsWith('Z'))
|
134
119
|
) {
|
135
|
-
const { mac, endpoint, cluster } =
|
120
|
+
const { mac, endpoint, cluster } = ApiClient.parseUniqueid(body.uniqueid)
|
136
121
|
|
137
122
|
/** The device ID.
|
138
123
|
*
|
@@ -170,7 +155,7 @@ class Resource {
|
|
170
155
|
|
171
156
|
realDevice = true
|
172
157
|
} else if (this.rtype === 'sensors') {
|
173
|
-
const { mac, endpoint, cluster } =
|
158
|
+
const { mac, endpoint, cluster } = ApiClient.parseUniqueid(body.uniqueid)
|
174
159
|
if (mac != null && endpoint != null && cluster != null) {
|
175
160
|
// uniqueid for proxy device has proper mac, endpoint, cluster
|
176
161
|
this.id = mac
|
package/lib/Deconz/index.js
CHANGED
@@ -9,13 +9,8 @@
|
|
9
9
|
* @hideconstructor
|
10
10
|
*/
|
11
11
|
class Deconz {
|
12
|
-
static get ApiClient () { return require('./ApiClient') }
|
13
|
-
static get ApiError () { return require('./ApiError') }
|
14
|
-
static get ApiResponse () { return require('./ApiResponse') }
|
15
12
|
static get Device () { return require('./Device') }
|
16
|
-
static get Discovery () { return require('./Discovery') }
|
17
13
|
static get Resource () { return require('./Resource') }
|
18
|
-
static get WsClient () { return require('./WsClient') }
|
19
14
|
}
|
20
15
|
|
21
16
|
module.exports = Deconz
|
@@ -8,7 +8,7 @@
|
|
8
8
|
const {
|
9
9
|
AccessoryDelegate, HttpClient, OptionParser, timeout
|
10
10
|
} = require('homebridge-lib')
|
11
|
-
|
11
|
+
const { ApiClient, ApiError, WsClient } = require('hb-deconz-tools')
|
12
12
|
const Deconz = require('../Deconz')
|
13
13
|
const DeconzAccessory = require('../DeconzAccessory')
|
14
14
|
const DeconzService = require('../DeconzService')
|
@@ -381,7 +381,7 @@ class Gateway extends AccessoryDelegate {
|
|
381
381
|
/** REST API client for the gateway.
|
382
382
|
* @type {DeconzClient}
|
383
383
|
*/
|
384
|
-
this.client = new
|
384
|
+
this.client = new ApiClient({
|
385
385
|
apiKey: this.values.apiKey,
|
386
386
|
config: this.context.config,
|
387
387
|
host: this.values.host,
|
@@ -437,7 +437,7 @@ class Gateway extends AccessoryDelegate {
|
|
437
437
|
/** Client for gateway web socket notifications.
|
438
438
|
* @type {DeconzWsClient}
|
439
439
|
*/
|
440
|
-
this.wsClient = new
|
440
|
+
this.wsClient = new WsClient({
|
441
441
|
host: this.values.host.split(':')[0] + ':' + this.values.wsPort,
|
442
442
|
retryTime: 15
|
443
443
|
})
|
@@ -514,7 +514,7 @@ class Gateway extends AccessoryDelegate {
|
|
514
514
|
this.pollFullState = true
|
515
515
|
} catch (error) {
|
516
516
|
if (
|
517
|
-
error instanceof
|
517
|
+
error instanceof ApiError && error.type === 101 && retry < 8
|
518
518
|
) {
|
519
519
|
this.log('unlock gateway to obtain API key - retrying in 15s')
|
520
520
|
await timeout(15000)
|
@@ -6,10 +6,10 @@
|
|
6
6
|
'use strict'
|
7
7
|
|
8
8
|
const { AccessoryDelegate, OptionParser } = require('homebridge-lib')
|
9
|
-
const
|
9
|
+
const { ApiClient } = require('hb-deconz-tools')
|
10
10
|
const DeconzService = require('../DeconzService')
|
11
11
|
|
12
|
-
const { HttpError } =
|
12
|
+
const { HttpError } = ApiClient
|
13
13
|
const { SINGLE, DOUBLE, LONG } = DeconzService.Button
|
14
14
|
|
15
15
|
/** Abstract superclass for a delegate of a HomeKit accessory,
|
@@ -65,7 +65,7 @@ class DeconzAccessory extends AccessoryDelegate {
|
|
65
65
|
this.device = device
|
66
66
|
|
67
67
|
/** The API client instance for the gateway.
|
68
|
-
* @type {
|
68
|
+
* @type {ApiClient}
|
69
69
|
*/
|
70
70
|
this.client = gateway.client
|
71
71
|
|
package/lib/DeconzPlatform.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
const events = require('events')
|
9
9
|
const { HttpClient, OptionParser, Platform, timeout } = require('homebridge-lib')
|
10
|
-
const
|
10
|
+
const { Discovery } = require('hb-deconz-tools')
|
11
11
|
const DeconzAccessory = require('./DeconzAccessory')
|
12
12
|
|
13
13
|
class DeconzPlatform extends Platform {
|
@@ -65,7 +65,7 @@ class DeconzPlatform extends Platform {
|
|
65
65
|
if (this.config.host != null) {
|
66
66
|
this.config.hosts.push(this.config.host)
|
67
67
|
}
|
68
|
-
this.discovery = new
|
68
|
+
this.discovery = new Discovery({
|
69
69
|
forceHttp: this.config.forceHttp,
|
70
70
|
timeout: this.config.timeout
|
71
71
|
})
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
9
9
|
const DeconzService = require('../DeconzService')
|
10
10
|
|
11
|
-
const { dateToString } =
|
11
|
+
const { dateToString } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -5,9 +5,9 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
9
9
|
const { ServiceDelegate } = require('homebridge-lib')
|
10
|
-
const { dateToString } =
|
10
|
+
const { dateToString } = ApiClient
|
11
11
|
|
12
12
|
/**
|
13
13
|
* @memberof DeconzService
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
9
9
|
const DeconzService = require('../DeconzService')
|
10
10
|
|
11
|
-
const { dateToString } =
|
11
|
+
const { dateToString } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
8
9
|
const DeconzService = require('../DeconzService')
|
9
|
-
const Deconz = require('../Deconz')
|
10
10
|
|
11
|
-
const { dateToString } =
|
11
|
+
const { dateToString } = ApiClient
|
12
12
|
|
13
13
|
const daylightEvents = {
|
14
14
|
100: { name: 'Solar Midnight', period: 'Night' },
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
8
9
|
const DeconzService = require('../DeconzService')
|
9
|
-
const Deconz = require('../Deconz')
|
10
10
|
|
11
|
-
const { lightLevelToLux } =
|
11
|
+
const { lightLevelToLux } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -6,10 +6,10 @@
|
|
6
6
|
'use strict'
|
7
7
|
|
8
8
|
const { timeout } = require('homebridge-lib')
|
9
|
-
const
|
9
|
+
const { ApiClient } = require('hb-deconz-tools')
|
10
10
|
const DeconzService = require('../DeconzService')
|
11
11
|
|
12
|
-
const { HttpError } =
|
12
|
+
const { HttpError } = ApiClient
|
13
13
|
|
14
14
|
class LightsResource extends DeconzService {
|
15
15
|
constructor (accessory, resource, params) {
|
@@ -26,8 +26,7 @@ class Motion extends DeconzService.SensorsResource {
|
|
26
26
|
|
27
27
|
this.addCharacteristicDelegate({
|
28
28
|
key: 'sensitivity',
|
29
|
-
Characteristic: this.Characteristics.eve.Sensitivity
|
30
|
-
value: this.Characteristics.hap.TemperatureDisplayUnits.CELSIUS
|
29
|
+
Characteristic: this.Characteristics.eve.Sensitivity
|
31
30
|
}).on('didSet', async (value, fromHomeKit) => {
|
32
31
|
if (fromHomeKit) {
|
33
32
|
const sensitivity = value === this.Characteristics.eve.Sensitivity.HIGH
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const Deconz = require('../Deconz')
|
9
8
|
const DeconzService = require('../DeconzService')
|
9
|
+
const { ApiClient } = require('hb-deconz-tools')
|
10
10
|
|
11
|
-
const { dateToString } =
|
11
|
+
const { dateToString } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
9
9
|
const { ServiceDelegate } = require('homebridge-lib')
|
10
10
|
|
11
|
-
const { HttpError } =
|
11
|
+
const { HttpError } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
-
const
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
9
9
|
const DeconzService = require('../DeconzService')
|
10
10
|
|
11
|
-
const { dateToString, HttpError } =
|
11
|
+
const { dateToString, HttpError } = ApiClient
|
12
12
|
|
13
13
|
/**
|
14
14
|
* @memberof DeconzService
|
@@ -30,8 +30,11 @@ class SensorsResource extends DeconzService {
|
|
30
30
|
this.addCharacteristicDelegate({
|
31
31
|
key: 'enabled',
|
32
32
|
Characteristic: this.Characteristics.my.Enabled
|
33
|
-
}).on('didSet', (value) => {
|
33
|
+
}).on('didSet', async (value, fromHomeKit) => {
|
34
34
|
this.values.statusActive = value
|
35
|
+
if (fromHomeKit) {
|
36
|
+
await this.put('/config', { on: value })
|
37
|
+
}
|
35
38
|
})
|
36
39
|
|
37
40
|
this.addCharacteristicDelegate({
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
'use strict'
|
7
7
|
|
8
|
+
const { ApiClient } = require('hb-deconz-tools')
|
8
9
|
const { ServiceDelegate } = require('homebridge-lib')
|
9
|
-
const Deconz = require('../Deconz')
|
10
10
|
|
11
|
-
const { dateToString } =
|
11
|
+
const { dateToString } = ApiClient
|
12
12
|
|
13
13
|
/** Service delegates.
|
14
14
|
* @extends ServiceDelegate
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"displayName": "Homebridge deCONZ",
|
5
5
|
"author": "Erik Baauw",
|
6
6
|
"license": "Apache-2.0",
|
7
|
-
"version": "0.1.
|
7
|
+
"version": "0.1.19",
|
8
8
|
"keywords": [
|
9
9
|
"homebridge-plugin",
|
10
10
|
"homekit",
|
@@ -23,12 +23,11 @@
|
|
23
23
|
"engines": {
|
24
24
|
"deCONZ": "2.21.2",
|
25
25
|
"homebridge": "^1.6.1",
|
26
|
-
"node": "^18.16.
|
26
|
+
"node": "^18.16.1"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"xml2js": "~0.5.0"
|
29
|
+
"hb-deconz-tools": "~1.0.3",
|
30
|
+
"homebridge-lib": "~6.3.18"
|
32
31
|
},
|
33
32
|
"scripts": {
|
34
33
|
"prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",
|