homebridge-deconz 0.0.26 → 0.1.0

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 (41) hide show
  1. package/config.schema.json +0 -7
  2. package/lib/Deconz/ApiError.js +12 -5
  3. package/lib/Deconz/ApiResponse.js +10 -7
  4. package/lib/Deconz/Resource.js +27 -4
  5. package/lib/DeconzAccessory/AirPurifier.js +0 -2
  6. package/lib/DeconzAccessory/Gateway.js +297 -147
  7. package/lib/DeconzAccessory/Light.js +32 -61
  8. package/lib/DeconzAccessory/Sensor.js +89 -1
  9. package/lib/DeconzAccessory/Thermostat.js +5 -8
  10. package/lib/DeconzAccessory/WarningDevice.js +2 -13
  11. package/lib/DeconzAccessory/WindowCovering.js +0 -2
  12. package/lib/DeconzAccessory/index.js +123 -13
  13. package/lib/DeconzPlatform.js +12 -20
  14. package/lib/DeconzService/AirPressure.js +8 -1
  15. package/lib/DeconzService/AirPurifier.js +2 -2
  16. package/lib/DeconzService/AirQuality.js +1 -1
  17. package/lib/DeconzService/Alarm.js +1 -1
  18. package/lib/DeconzService/Battery.js +21 -10
  19. package/lib/DeconzService/Button.js +1 -0
  20. package/lib/DeconzService/CarbonMonoxide.js +1 -1
  21. package/lib/DeconzService/Consumption.js +3 -1
  22. package/lib/DeconzService/Contact.js +1 -25
  23. package/lib/DeconzService/Daylight.js +22 -19
  24. package/lib/DeconzService/Flag.js +1 -1
  25. package/lib/DeconzService/Gateway.js +48 -0
  26. package/lib/DeconzService/Humidity.js +1 -1
  27. package/lib/DeconzService/Leak.js +1 -1
  28. package/lib/DeconzService/Light.js +121 -74
  29. package/lib/DeconzService/LightLevel.js +3 -3
  30. package/lib/DeconzService/LightsResource.js +24 -18
  31. package/lib/DeconzService/Motion.js +3 -9
  32. package/lib/DeconzService/Power.js +2 -1
  33. package/lib/DeconzService/Status.js +1 -1
  34. package/lib/DeconzService/WindowCovering.js +14 -4
  35. package/lib/DeconzService/index.js +14 -3
  36. package/package.json +6 -6
  37. package/lib/DeconzAccessory/Contact.js +0 -54
  38. package/lib/DeconzAccessory/Motion.js +0 -54
  39. package/lib/DeconzAccessory/Temperature.js +0 -63
  40. package/lib/DeconzService/DeviceSettings.js +0 -56
  41. package/lib/DeconzService/GatewaySettings.js +0 -175
@@ -14,13 +14,6 @@
14
14
  "required": true,
15
15
  "default": "deCONZ"
16
16
  },
17
- "brightnessAdjustment": {
18
- "description": "Adjustment factor for brightness for adaptive lighting. Default: 100.",
19
- "type": "integer",
20
- "placeholder": 100,
21
- "minimum": 10,
22
- "maximum": 100
23
- },
24
17
  "forceHttp": {
25
18
  "description": "Use plain http instead of https.",
26
19
  "type": "boolean"
@@ -21,21 +21,28 @@ const nonCriticalApiErrorTypes = [
21
21
  * @memberof Deconz
22
22
  */
23
23
  class ApiError extends homebridgeLib.HttpClient.HttpError {
24
- constructor (message, response, type, description) {
25
- super(message, response.request, response.statusCode, response.statusMessage)
24
+ constructor (e, response) {
25
+ super(
26
+ `${e.address}: api error ${e.type}: ${e.description}`,
27
+ response.request, response.statusCode, response.statusMessage
28
+ )
26
29
 
27
30
  /** @member {integer} - The API error type.
28
31
  */
29
- this.type = type
32
+ this.type = e.type
33
+
34
+ /** @member {string} - The address causing the error.
35
+ */
36
+ this.address = e.address
30
37
 
31
38
  /** @member {string} - The API error description.
32
39
  */
33
- this.description = description
40
+ this.description = e.description
34
41
 
35
42
  /** @member {boolean} - Indication that the request might still succeed
36
43
  * for other attributes.
37
44
  */
38
- this.nonCritical = nonCriticalApiErrorTypes.includes(type)
45
+ this.nonCritical = nonCriticalApiErrorTypes.includes(e.type)
39
46
  }
40
47
  }
41
48
 
@@ -33,17 +33,20 @@ class ApiResponse extends homebridgeLib.HttpClient.HttpResponse {
33
33
  for (const id in response.body) {
34
34
  const e = response.body[id].error
35
35
  if (e != null && typeof e === 'object') {
36
- this.errors.push(new Deconz.ApiError(
37
- `api error ${e.type}: ${e.description}`,
38
- response, e.type, e.description
39
- ))
36
+ this.errors.push(new Deconz.ApiError(e, response))
40
37
  }
41
38
  const s = response.body[id].success
42
39
  if (s != null && typeof s === 'object') {
43
40
  for (const path of Object.keys(s)) {
44
- const a = path.split('/')
45
- const key = a[a.length - 1]
46
- this.success[key] = s[path]
41
+ const keys = path.split('/')
42
+ let obj = this.success
43
+ for (let i = 1; i < keys.length - 1; i++) {
44
+ if (obj[keys[i]] == null) {
45
+ obj[keys[i]] = {}
46
+ }
47
+ obj = obj[keys[i]]
48
+ }
49
+ obj[keys[keys.length - 1]] = s[path]
47
50
  }
48
51
  }
49
52
  }
@@ -21,6 +21,7 @@ const sensorsPrios = [
21
21
  'Power',
22
22
  'Consumption',
23
23
  'Temperature',
24
+ 'LightLevel',
24
25
  'Motion',
25
26
  'OpenClose',
26
27
  'AirPurifier',
@@ -231,6 +232,27 @@ class Resource {
231
232
  alert: body.state.alert !== undefined,
232
233
  colorLoop: body.state.effect !== undefined
233
234
  }
235
+ if (body.capabilities != null) {
236
+ const cap = body.capabilities
237
+ if (cap.color != null) {
238
+ if (cap.color.ct != null) {
239
+ this.capabilities.ctMax = cap.color.ct.max
240
+ this.capabilities.ctMin = cap.color.ct.min
241
+ }
242
+ if (cap.color.effects != null && cap.color.effects.length > 2) {
243
+ this.capabilities.effects = cap.color.effects.slice(2).map((effect) => {
244
+ return effect[0].toUpperCase() + effect.slice(1)
245
+ })
246
+ }
247
+ if (cap.color.xy != null) {
248
+ this.capabilities.gamut = {
249
+ r: cap.color.xy.red,
250
+ g: cap.color.xy.green,
251
+ b: cap.color.xy.blue
252
+ }
253
+ }
254
+ }
255
+ }
234
256
  break
235
257
  }
236
258
  case 'WarningDevice':
@@ -487,14 +509,15 @@ class Resource {
487
509
  }
488
510
  break
489
511
  case 'Philips':
490
- case 'Signify Netherlands B.V.': {
512
+ case 'Signify Netherlands B.V.':
491
513
  // See: http://www.developers.meethue.com/documentation/supported-lights
492
514
  this.manufacturer = 'Signify Netherlands B.V.'
493
515
  this.capabilities.breathe = true
494
516
  this.capabilities.computesXy = true
495
- const gamut = hueGamutTypeByModel[this.model] || 'C'
496
- this.capabilities.gamut = hueGamutType[gamut]
497
- }
517
+ if (this.body.capabilities == null) {
518
+ const gamut = hueGamutTypeByModel[this.model] || 'C'
519
+ this.capabilities.gamut = hueGamutType[gamut]
520
+ }
498
521
  break
499
522
  default:
500
523
  break
@@ -26,8 +26,6 @@ class AirPurifier extends DeconzAccessory {
26
26
  this.createService(resource)
27
27
  }
28
28
 
29
- this.createSettingsService()
30
-
31
29
  setImmediate(() => {
32
30
  this.debug('initialised')
33
31
  this.emit('initialised')