homebridge-deconz 0.0.10 → 0.0.11

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.
Files changed (47) hide show
  1. package/cli/deconz.js +12 -0
  2. package/lib/Deconz/ApiClient.js +34 -1
  3. package/lib/Deconz/ApiResponse.js +1 -1
  4. package/lib/Deconz/Device.js +0 -7
  5. package/lib/Deconz/Resource.js +749 -24
  6. package/lib/DeconzAccessory/Contact.js +54 -0
  7. package/lib/DeconzAccessory/Gateway.js +83 -61
  8. package/lib/DeconzAccessory/Light.js +42 -37
  9. package/lib/DeconzAccessory/Motion.js +51 -0
  10. package/lib/DeconzAccessory/Sensor.js +35 -0
  11. package/lib/DeconzAccessory/Temperature.js +63 -0
  12. package/lib/DeconzAccessory/Thermostat.js +50 -0
  13. package/lib/DeconzAccessory/WarningDevice.js +56 -0
  14. package/lib/DeconzAccessory/WindowCovering.js +47 -0
  15. package/lib/DeconzAccessory/index.js +142 -2
  16. package/lib/DeconzPlatform.js +5 -0
  17. package/lib/DeconzService/AirPressure.js +43 -0
  18. package/lib/DeconzService/AirQuality.js +17 -10
  19. package/lib/DeconzService/Alarm.js +13 -9
  20. package/lib/DeconzService/Battery.js +43 -0
  21. package/lib/DeconzService/Button.js +9 -2
  22. package/lib/DeconzService/CarbonMonoxide.js +38 -0
  23. package/lib/DeconzService/Consumption.js +65 -0
  24. package/lib/DeconzService/Contact.js +60 -0
  25. package/lib/DeconzService/Daylight.js +132 -0
  26. package/lib/DeconzService/DeviceSettings.js +11 -0
  27. package/lib/DeconzService/Flag.js +52 -0
  28. package/lib/DeconzService/Humidity.js +37 -0
  29. package/lib/DeconzService/Leak.js +38 -0
  30. package/lib/DeconzService/Light.js +12 -164
  31. package/lib/DeconzService/LightLevel.js +54 -0
  32. package/lib/DeconzService/LightsResource.js +112 -0
  33. package/lib/DeconzService/Motion.js +101 -0
  34. package/lib/DeconzService/Outlet.js +76 -0
  35. package/lib/DeconzService/Power.js +83 -0
  36. package/lib/DeconzService/SensorsResource.js +96 -0
  37. package/lib/DeconzService/Smoke.js +38 -0
  38. package/lib/DeconzService/Status.js +53 -0
  39. package/lib/DeconzService/Switch.js +93 -0
  40. package/lib/DeconzService/Temperature.js +63 -0
  41. package/lib/DeconzService/Thermostat.js +175 -0
  42. package/lib/DeconzService/WarningDevice.js +68 -0
  43. package/lib/DeconzService/WindowCovering.js +139 -0
  44. package/lib/DeconzService/index.js +76 -25
  45. package/package.json +2 -2
  46. package/lib/DeconzAccessory/Device.js +0 -69
  47. package/lib/DeconzService/Sensor.js +0 -61
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.
@@ -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('./index')
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
@@ -7,7 +7,7 @@
7
7
 
8
8
  const homebridgeLib = require('homebridge-lib')
9
9
 
10
- const Deconz = require('./index')
10
+ const Deconz = require('../Deconz')
11
11
 
12
12
  /** Deconz API response.
13
13
  * @hideconstructor
@@ -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
  }