homebridge-deconz 0.0.9 → 0.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/README.md +3 -6
- package/cli/deconz.js +12 -0
- package/config.schema.json +2 -1
- package/homebridge-ui/public/index.html +26 -0
- package/homebridge-ui/public/style.css +0 -0
- package/homebridge-ui/server.js +43 -0
- package/lib/Deconz/ApiClient.js +34 -1
- package/lib/Deconz/ApiResponse.js +1 -1
- package/lib/Deconz/Device.js +0 -7
- package/lib/Deconz/Resource.js +752 -27
- package/lib/DeconzAccessory/Contact.js +54 -0
- package/lib/DeconzAccessory/Gateway.js +102 -66
- package/lib/DeconzAccessory/Light.js +42 -35
- package/lib/DeconzAccessory/Motion.js +51 -0
- package/lib/DeconzAccessory/Sensor.js +35 -0
- package/lib/DeconzAccessory/Temperature.js +63 -0
- package/lib/DeconzAccessory/Thermostat.js +50 -0
- package/lib/DeconzAccessory/WarningDevice.js +56 -0
- package/lib/DeconzAccessory/WindowCovering.js +47 -0
- package/lib/DeconzAccessory/index.js +145 -4
- package/lib/DeconzPlatform.js +6 -3
- package/lib/DeconzService/AirPressure.js +43 -0
- package/lib/DeconzService/AirQuality.js +20 -11
- package/lib/DeconzService/Alarm.js +13 -9
- package/lib/DeconzService/Battery.js +53 -0
- package/lib/DeconzService/Button.js +9 -2
- package/lib/DeconzService/CarbonMonoxide.js +38 -0
- package/lib/DeconzService/Consumption.js +65 -0
- package/lib/DeconzService/Contact.js +60 -0
- package/lib/DeconzService/Daylight.js +132 -0
- package/lib/DeconzService/DeviceSettings.js +12 -4
- package/lib/DeconzService/Flag.js +52 -0
- package/lib/DeconzService/GatewaySettings.js +1 -4
- package/lib/DeconzService/Humidity.js +37 -0
- package/lib/DeconzService/Leak.js +38 -0
- package/lib/DeconzService/Light.js +289 -280
- package/lib/DeconzService/LightLevel.js +54 -0
- package/lib/DeconzService/LightsResource.js +112 -0
- package/lib/DeconzService/Motion.js +101 -0
- package/lib/DeconzService/Outlet.js +76 -0
- package/lib/DeconzService/Power.js +83 -0
- package/lib/DeconzService/SensorsResource.js +96 -0
- package/lib/DeconzService/Smoke.js +38 -0
- package/lib/DeconzService/Status.js +53 -0
- package/lib/DeconzService/Switch.js +93 -0
- package/lib/DeconzService/Temperature.js +63 -0
- package/lib/DeconzService/Thermostat.js +175 -0
- package/lib/DeconzService/WarningDevice.js +68 -0
- package/lib/DeconzService/WindowCovering.js +139 -0
- package/lib/DeconzService/index.js +79 -25
- package/package.json +6 -5
- package/lib/Client/ApiError.js +0 -42
- package/lib/DeconzAccessory/Device.js +0 -69
- package/lib/DeconzService/Sensor.js +0 -61
package/README.md
CHANGED
@@ -19,8 +19,7 @@ Copyright © 2022 Erik Baauw. All rights reserved.
|
|
19
19
|
### Work in Progress
|
20
20
|
See [Future Development of Homebridge Hue](https://github.com/ebaauw/homebridge-hue/issues/1070) for positioning Homebridge deCONZ versus Homebridge Hue.
|
21
21
|
|
22
|
-
|
23
|
-
I'm using it to stress-test the technical framework.
|
22
|
+
Homebridge deCONZ is still under development.
|
24
23
|
See [Releases](https://github.com/ebaauw/homebridge-deconz/releases) for more details.
|
25
24
|
|
26
25
|
If you have a question, please post a message to the **#hue** channel of the Homebridge community on [Discord](https://discord.gg/hZubhrz).
|
@@ -60,13 +59,13 @@ See the [Wiki](https://github.com/ebaauw/homebridge-deconz/wiki/Configuration) f
|
|
60
59
|
Homebridge deCONZ exposes a [gateway accessory](https://github.com/ebaauw/homebridge-deconz/wiki/Gateway-Accessory) for each deCONZ gateway.
|
61
60
|
In Apple's Home app, this accessory looks like a wireless switch; you'll need another HomeKit app to configure the accessory.
|
62
61
|
|
63
|
-
When
|
62
|
+
When it connects to a deCONZ gateway for the first time, Homebridge deCONZ will try to obtain an API key for two minutes, before exposing the gateway accessory.
|
64
63
|
Unless Homebridge deCONZ runs on the same server as the deCONZ gateway, you need to unlock the gateway to allow Homebridge deCONZ to obtain an API key.
|
65
64
|
After two minutes, Homebridge deCONZ will give up, exposing the gateway accessory anyways, but marking it inactive.
|
66
65
|
Set _Expose_ on the _Gateway Settings_ service of the gateway accessory to retry obtaining an API key.
|
67
66
|
Homebridge deCONZ will **not** retry to obtain an API key on Homebridge restart.
|
68
67
|
|
69
|
-
After setting _Expose Lights_, _Expose Sensors_, or _Expose Groups_ on the _Gateway Settings_ service, Homebridge
|
68
|
+
After setting _Expose Lights_, _Expose Sensors_, or _Expose Groups_ on the _Gateway Settings_ service, Homebridge deCONZ will expose a [device accessory](https://github.com/ebaauw/homebridge-deconz/wiki/Device-Accessory) for each of the corresponding devices.
|
70
69
|
When clearing the characteristic, the corresponding device accessories are removed from HomeKit.
|
71
70
|
Each device accessory has a _Device Settings_ service, to configure the device.
|
72
71
|
Clear _Expose_ on that service, to blacklist the device, and remove the associated accessory from HomeKit.
|
@@ -77,8 +76,6 @@ Setting _Expose Lights_ will include the ZHAConsumption and ZHAPower `/sensors`
|
|
77
76
|
Note that HomeKit doesn't like configuration changes.
|
78
77
|
Allow ample time after exposing or removing accessories for HomeKit to sync the changed configuration to all Apple devices.
|
79
78
|
|
80
|
-
Note that currently, each device accessory only carries a dummy _Stateless Programmable Switch_ service (to make it visible in Home).
|
81
|
-
|
82
79
|
### Command-Line Utility
|
83
80
|
Homebridge deCONZ includes the `deconz` command-line utility, to discover,
|
84
81
|
monitor, and interact with a deCONZ gateway.
|
package/cli/deconz.js
CHANGED
@@ -301,6 +301,18 @@ Usage: ${b('deconz')} ${usage.unlock}
|
|
301
301
|
|
302
302
|
${description.unlock}
|
303
303
|
|
304
|
+
Parameters:
|
305
|
+
${b('-h')}, ${b('--help')}
|
306
|
+
Print this help and exit.
|
307
|
+
|
308
|
+
${b('-v')}, ${b('--verbose')}
|
309
|
+
Print full API output.`,
|
310
|
+
search: `${description.search}
|
311
|
+
|
312
|
+
Usage: ${b('deconz')} ${usage.search}
|
313
|
+
|
314
|
+
${description.search}
|
315
|
+
|
304
316
|
Parameters:
|
305
317
|
${b('-h')}, ${b('--help')}
|
306
318
|
Print this help and exit.
|
package/config.schema.json
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
"pluginAlias": "deCONZ",
|
3
3
|
"pluginType": "platform",
|
4
4
|
"singular": true,
|
5
|
+
"customUi": true,
|
5
6
|
"headerDisplay": "Homebridge plugin for deCONZ",
|
6
7
|
"footerDisplay": "For a detailed description, see the [wiki](https://github.com/ebaauw/homebridge-deconz/wiki/Configuration).",
|
7
8
|
"schema": {
|
@@ -69,7 +70,7 @@
|
|
69
70
|
"maximum": 2000
|
70
71
|
},
|
71
72
|
"waitTimeUpdate": {
|
72
|
-
"description": "The time, in milliseconds, to wait for a change from HomeKit to another characteristic for the same light or group, before updating the deCONZ gateway. Default:
|
73
|
+
"description": "The time, in milliseconds, to wait for a change from HomeKit to another characteristic for the same light or group, before updating the deCONZ gateway. Default: 100.",
|
73
74
|
"type": "integer",
|
74
75
|
"minimum": 0,
|
75
76
|
"maximum": 500
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!--
|
2
|
+
homebridge-deconz/homebridge-ui/public/index.html
|
3
|
+
|
4
|
+
Homebridge plug-in for deCONZ.
|
5
|
+
Copyright © 2022 Erik Baauw. All rights reserved.
|
6
|
+
-->
|
7
|
+
|
8
|
+
<link rel="stylesheet" href="style.css">
|
9
|
+
|
10
|
+
<script>
|
11
|
+
(async () => {
|
12
|
+
try {
|
13
|
+
homebridge.showSchemaForm()
|
14
|
+
|
15
|
+
// const pluginConfig = await homebridge.getPluginConfig()
|
16
|
+
// const pluginConfigSchema = await homebridge.getPluginConfigSchema()
|
17
|
+
const cachedAccessories = await homebridge.getCachedAccessories()
|
18
|
+
|
19
|
+
const result = await homebridge.request('/cachedAccessories', cachedAccessories)
|
20
|
+
const nGateways = Object.keys(result).length
|
21
|
+
homebridge.toast.success(`${nGateways} gateways`)
|
22
|
+
} catch (error) {
|
23
|
+
console.error(error)
|
24
|
+
}
|
25
|
+
})()
|
26
|
+
</script>
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// homebridge-deconz/homebridge-ui/server.js
|
2
|
+
//
|
3
|
+
// Homebridge plug-in for deCONZ.
|
4
|
+
// Copyright © 2022 Erik Baauw. All rights reserved.
|
5
|
+
|
6
|
+
'use strict'
|
7
|
+
|
8
|
+
const {
|
9
|
+
HomebridgePluginUiServer, RequestError
|
10
|
+
} = require('@homebridge/plugin-ui-utils')
|
11
|
+
|
12
|
+
class UiServer extends HomebridgePluginUiServer {
|
13
|
+
constructor () {
|
14
|
+
super()
|
15
|
+
|
16
|
+
this.onRequest('/cachedAccessories', async (cachedAccessories) => {
|
17
|
+
try {
|
18
|
+
// console.log('%d accessories', cachedAccessories.length)
|
19
|
+
const gateways = cachedAccessories.filter((accessory) => {
|
20
|
+
return accessory.plugin === 'homebridge-deconz' &&
|
21
|
+
accessory.context != null &&
|
22
|
+
accessory.context.className === 'Gateway'
|
23
|
+
})
|
24
|
+
// console.log('%d gateways', gateways.length)
|
25
|
+
const result = {}
|
26
|
+
for (const gateway of gateways) {
|
27
|
+
const { host, apiKey } = gateway.context
|
28
|
+
if (apiKey != null) {
|
29
|
+
result[host] = apiKey
|
30
|
+
}
|
31
|
+
}
|
32
|
+
console.log('%d gateways: %j', Object.keys(result).length, result)
|
33
|
+
return result
|
34
|
+
} catch (error) {
|
35
|
+
throw new RequestError(error)
|
36
|
+
}
|
37
|
+
})
|
38
|
+
|
39
|
+
this.ready()
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
new UiServer() // eslint-disable-line no-new
|
package/lib/Deconz/ApiClient.js
CHANGED
@@ -9,7 +9,7 @@ const events = require('events')
|
|
9
9
|
const homebridgeLib = require('homebridge-lib')
|
10
10
|
const os = require('os')
|
11
11
|
|
12
|
-
const Deconz = require('
|
12
|
+
const Deconz = require('../Deconz')
|
13
13
|
|
14
14
|
// Estmate the number of Zigbee messages resulting from PUT body.
|
15
15
|
function numberOfZigbeeMessages (body = {}) {
|
@@ -43,6 +43,29 @@ function numberOfZigbeeMessages (body = {}) {
|
|
43
43
|
* @memberof Deconz
|
44
44
|
*/
|
45
45
|
class ApiClient extends homebridgeLib.HttpClient {
|
46
|
+
/** Events reported through `buttonevent`.
|
47
|
+
* @type {Object<string, integer>}
|
48
|
+
*/
|
49
|
+
static get buttonEvent () {
|
50
|
+
return {
|
51
|
+
PRESS: 0,
|
52
|
+
HOLD: 1,
|
53
|
+
SHORT_RELEASE: 2,
|
54
|
+
LONG_RELEASE: 3,
|
55
|
+
DOUBLE_PRESS: 4,
|
56
|
+
TRIPLE_PRESS: 5,
|
57
|
+
QUADRUPLE_PRESS: 6,
|
58
|
+
SHAKE: 7,
|
59
|
+
DROP: 8,
|
60
|
+
TILT: 9
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
/** Convert date as reported by deCONZ to human readable string.
|
65
|
+
* @param {string} date - The ISO-8601 date string.
|
66
|
+
* @param {boolean} [utc=true] - Treat date as UTC, even with missing `Z`.
|
67
|
+
* @param {string} date - The human readable date string.
|
68
|
+
*/
|
46
69
|
static dateToString (date, utc = true) {
|
47
70
|
if (date == null || date === 'none') {
|
48
71
|
return 'n/a'
|
@@ -53,6 +76,16 @@ class ApiClient extends homebridgeLib.HttpClient {
|
|
53
76
|
return String(new Date(date)).slice(0, 24)
|
54
77
|
}
|
55
78
|
|
79
|
+
/** Convert `lightlevel` to lux.
|
80
|
+
* @param {integer} lightLevel - The `lightlevel` as reported by deCONZ.
|
81
|
+
* @return {integer} lux - The value in lux.
|
82
|
+
*/
|
83
|
+
static lightLevelToLux (v) {
|
84
|
+
let lux = v ? Math.pow(10, (v - 1) / 10000) : 0.0001
|
85
|
+
lux = Math.round(lux * 10000) / 10000
|
86
|
+
return Math.max(0.0001, Math.min(lux, 100000))
|
87
|
+
}
|
88
|
+
|
56
89
|
/** Create a new instance of a Deconz.Client.
|
57
90
|
*
|
58
91
|
* The caller is expected to verify that the given host is a reachable
|
package/lib/Deconz/Device.js
CHANGED
@@ -92,13 +92,6 @@ class Device {
|
|
92
92
|
this.resourceBySubtype[subtype] = resource
|
93
93
|
const p = this.resourceBySubtype[this.primary]
|
94
94
|
if (p.rtype === rtype && p.prio < prio) {
|
95
|
-
/** The key of the delegate for the primary resource for the device in
|
96
|
-
* {@link DeconzDevice#resourceBySubtype resourceBySubtype}
|
97
|
-
*
|
98
|
-
* This is the {@link DeconzDevice.Resource#subtype subtype} of the
|
99
|
-
* HomeKit service corresponding to the primary resource.
|
100
|
-
* @type {string}
|
101
|
-
*/
|
102
95
|
this.primary = resource.subtype
|
103
96
|
}
|
104
97
|
}
|