homebridge-deconz 0.0.22 → 0.0.23

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.
@@ -256,7 +256,7 @@ class Resource {
256
256
  */
257
257
  get prio () {
258
258
  if (this.rtype === 'groups') return -1
259
- if (this.rtype === 'lights') return this.endpoint
259
+ if (this.rtype === 'lights') return 0xFF - this.endpoint
260
260
  return sensorsPrios.indexOf(this.serviceName)
261
261
  }
262
262
 
@@ -21,6 +21,8 @@ class Light extends DeconzAccessory {
21
21
  * @param {Deconz.Device} device - The device.
22
22
  */
23
23
  constructor (gateway, device, settings = {}) {
24
+ // settings.forceEveEnergy = true
25
+
24
26
  super(gateway, device, gateway.Accessory.Categories.LIGHTBULB)
25
27
 
26
28
  this.identify()
@@ -35,12 +37,14 @@ class Light extends DeconzAccessory {
35
37
  serviceName: this.values.serviceName
36
38
  })
37
39
 
40
+ let nLights = 1
38
41
  for (const subtype in device.resourceBySubtype) {
39
42
  const resource = device.resourceBySubtype[subtype]
40
43
  if (subtype === device.primary) {
41
44
  continue
42
45
  }
43
46
  if (resource.rtype === 'lights') {
47
+ nLights++
44
48
  this.createService(resource, { serviceName: this.values.serviceName })
45
49
  } else {
46
50
  this.createService(resource)
@@ -48,16 +52,66 @@ class Light extends DeconzAccessory {
48
52
  }
49
53
 
50
54
  if (this.serviceByServiceName.Consumption != null) {
55
+ // Current Consumption to be computed by history if not exposed by device
56
+ const currentConsumption =
57
+ this.service.values.currentConsumption === undefined
58
+ ? this.service.addCharacteristicDelegate({
59
+ key: 'currentConsumption',
60
+ Characteristic: this.Characteristics.eve.CurrentConsumption,
61
+ unit: ' W'
62
+ })
63
+ : null
51
64
  this.historyService = new History.Consumption(
52
65
  this, {},
53
- this.serviceByServiceName.Consumption.characteristicDelegate('totalConsumption'),
54
- this.serviceByServiceName.Consumption.characteristicDelegate('currentConsumption')
66
+ this.service.characteristicDelegate('totalConsumption'),
67
+ currentConsumption,
68
+ this.service.characteristicDelegate('on')
55
69
  )
56
70
  } else if (this.serviceByServiceName.Power != null) {
71
+ // Total Consumption to be computed by history
72
+ const TotalConsumption = this.service.addCharacteristicDelegate({
73
+ key: 'totalConsumption',
74
+ Characteristic: this.Characteristics.eve.TotalConsumption,
75
+ unit: ' kWh',
76
+ value: 0
77
+ })
57
78
  this.historyService = new History.Power(
58
79
  this, {},
59
- this.serviceByServiceName.Power.characteristicDelegate('currentConsumption')
80
+ this.service.characteristicDelegate('currentConsumption'),
81
+ TotalConsumption,
82
+ this.service.characteristicDelegate('on')
60
83
  )
84
+ } else if (this.values.serviceName === 'Outlet' && settings.forceEveEnergy) {
85
+ if (nLights > 1) {
86
+ // Eve would recognise device as Eve Energy Strip.
87
+ } else if (this.serviceByServiceName.Switch != null) {
88
+ // Eve would recognise device as Eve Button.
89
+ } else {
90
+ // Needed for Eve to recognise device as Eve Energy.
91
+ this.service.addCharacteristicDelegate({
92
+ key: 'totalConsumption',
93
+ Characteristic: this.Characteristics.eve.TotalConsumption,
94
+ unit: ' kWh'
95
+ })
96
+ this.historyService = new History.On(
97
+ this, {},
98
+ this.service.characteristicDelegate('on')
99
+ )
100
+ }
101
+ }
102
+
103
+ if (this.values.serviceName === 'Outlet' && this.historyService != null) {
104
+ if (nLights > 1) {
105
+ // Eve would recognise device as Eve Energy Strip.
106
+ } else if (this.serviceByServiceName.Switch != null) {
107
+ // Eve would recognise device as Eve Button.
108
+ } else {
109
+ // Needed for Eve to show history for On.
110
+ this.service.addCharacteristicDelegate({
111
+ key: 'lockPhysicalControls',
112
+ Characteristic: this.Characteristics.hap.LockPhysicalControls
113
+ })
114
+ }
61
115
  }
62
116
 
63
117
  this.createSettingsService()
@@ -157,7 +157,6 @@ class DeconzAccessory extends homebridgeLib.AccessoryDelegate {
157
157
  if (service != null) {
158
158
  service.addResource(resource)
159
159
  }
160
- this.consumptionService = service
161
160
  } else if (params.serviceName === 'Switch') {
162
161
  // Default button
163
162
  if (resource.capabilities.buttons == null) {
@@ -71,7 +71,7 @@ class GatewaySettings extends homebridgeLib.ServiceDelegate {
71
71
  this.addCharacteristicDelegate({
72
72
  key: 'logLevel',
73
73
  Characteristic: this.Characteristics.my.LogLevel,
74
- value: gateway.platform.logLevel
74
+ value: this.accessoryDelegate.logLevel
75
75
  })
76
76
 
77
77
  this.addCharacteristicDelegate({
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.0.22",
7
+ "version": "0.0.23",
8
8
  "keywords": [
9
9
  "homebridge-plugin",
10
10
  "homekit",
@@ -20,14 +20,13 @@
20
20
  "deconz": "cli/deconz.js"
21
21
  },
22
22
  "engines": {
23
- "deCONZ": "2.17.1",
23
+ "deCONZ": "2.18.2",
24
24
  "homebridge": "^1.5.0",
25
- "node": "^16.17.0"
25
+ "node": "^16.17.1"
26
26
  },
27
27
  "dependencies": {
28
- "homebridge-lib": "~5.6.5",
29
- "semver": "^7.3.7",
30
- "ws": "^8.8.1",
28
+ "homebridge-lib": "~5.6.8",
29
+ "ws": "^8.9.0",
31
30
  "xml2js": "~0.4.23"
32
31
  },
33
32
  "scripts": {
@@ -42,8 +41,14 @@
42
41
  "url": "https://github.com/ebaauw/homebridge-deconz/issues"
43
42
  },
44
43
  "homepage": "https://github.com/ebaauw/homebridge-deconz#readme",
45
- "funding": {
46
- "type": "paypal",
47
- "url": "https://www.paypal.me/ebaauw/EUR"
48
- }
44
+ "funding": [
45
+ {
46
+ "type": "github",
47
+ "url": "https://github.com/sponsors/ebaauw"
48
+ },
49
+ {
50
+ "type": "paypal",
51
+ "url": "https://www.paypal.me/ebaauw/EUR"
52
+ }
53
+ ]
49
54
  }