homebridge-lib 5.7.1 → 5.7.2

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.
@@ -188,7 +188,7 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
188
188
  unit: 'kWh',
189
189
  minValue: 0,
190
190
  maxValue: 1000000,
191
- minStep: 0.1,
191
+ minStep: 0.01,
192
192
  perms: [this.Perms.READ, this.Perms.NOTIFY]
193
193
  }, 'Total Consumption')
194
194
 
@@ -168,6 +168,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
168
168
  * <br>Used by: homebridge-hue for Hue Entertainment groups.
169
169
  * @property {Class} SubEnabled - Enabled/disable Sub.
170
170
  * <br>Used by: homebridge-zp in Speaker service.
171
+ * @property {Class} SubLevel - Level for the Sub.
172
+ * <br>Used by: homebridge-zp in Speaker service.
171
173
  * @property {Class} Sunrise - Date/time of today's sun rise.
172
174
  * <br>Used by: homebridge-hue, homebridge-ws.
173
175
  * @property {Class} Sunset - Date/time of today's sun set.
@@ -749,6 +751,14 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
749
751
  adminOnlyAccess: [this.Access.WRITE]
750
752
  }, 'Expose Schedules')
751
753
 
754
+ this.createCharacteristicClass('SubLevel', uuid('07D'), {
755
+ format: this.Formats.INT,
756
+ minValue: -15,
757
+ maxValue: 15,
758
+ minStep: 1,
759
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
760
+ }, 'Sub Level')
761
+
752
762
  // Characteristic for Unique ID, used by homebridge-hue.
753
763
  // Source: as exposed by the Philips Hue bridge. This characteristic is
754
764
  // used by the Hue app to select the accessories when syncing Hue bridge
@@ -96,11 +96,11 @@ class Consumption extends History {
96
96
  if (this._consumption != null && this._time != null) {
97
97
  const delta = this._consumptionDelegate.value - this._consumption // kWh
98
98
  const period = now - this._time // s
99
- const power = Math.round(1000 * 3600 * delta / period) // W
99
+ const power = 1000 * 3600 * delta / period // W
100
100
  if (this._powerDelegate != null) {
101
- this._powerDelegate.value = power
101
+ this._powerDelegate.value = Math.round(power) // W
102
102
  }
103
- this._entry.power = power
103
+ this._entry.power = Math.round(power * 10) // 0.1 W * 10 min
104
104
  super._addEntry(now)
105
105
  }
106
106
  this._consumption = this._consumptionDelegate.value
@@ -115,7 +115,7 @@ class Consumption extends History {
115
115
  '|0c %s %s 01 %s',
116
116
  numToHex(swap32(this._h.currentEntry), 8),
117
117
  numToHex(swap32(entry.time - this._h.initialTime), 8),
118
- numToHex(swap16(entry.power * 10), 4)
118
+ numToHex(swap16(entry.power), 4)
119
119
  )
120
120
  }
121
121
  if (entry.power == null) {
@@ -130,7 +130,7 @@ class Consumption extends History {
130
130
  '|0d %s %s 03 %s %s',
131
131
  numToHex(swap32(this._h.currentEntry), 8),
132
132
  numToHex(swap32(entry.time - this._h.initialTime), 8),
133
- numToHex(swap16(entry.power * 10), 4),
133
+ numToHex(swap16(entry.power), 4),
134
134
  numToHex(entry.on, 2)
135
135
  )
136
136
  }
@@ -79,8 +79,7 @@ class Contact extends History {
79
79
  key: 'resetTotal',
80
80
  Characteristic: this.Characteristics.eve.ResetTotal,
81
81
  value: params.resetTotal
82
- })
83
- this._characteristicDelegates.resetTotal.on('didSet', (value) => {
82
+ }).on('didSet', (value) => {
84
83
  timesOpenedDelegate.value = 0
85
84
  })
86
85
  }
@@ -77,8 +77,8 @@ class Power extends History {
77
77
  const now = Math.round(new Date().valueOf() / 1000)
78
78
  if (this._time != null) {
79
79
  const delta = this._power * (now - this._time) // Ws
80
- this._runningConsumption += Math.round(delta / 600.0) // W * 10 min
81
- this._totalConsumption += Math.round(delta / 3600000.0) // kWh
80
+ this._runningConsumption += Math.round(delta / 60.0) // 0.1W * 10 min
81
+ this._totalConsumption += delta / 36000.0 // 0.01 kWh
82
82
  }
83
83
  this._power = value
84
84
  this._time = now
@@ -87,8 +87,7 @@ class Power extends History {
87
87
  key: 'resetTotal',
88
88
  Characteristic: this.Characteristics.eve.ResetTotal,
89
89
  value: params.resetTotal
90
- })
91
- this._characteristicDelegates.resetTotal.on('didSet', (value) => {
90
+ }).on('didSet', (value) => {
92
91
  this._runningConsumption = 0
93
92
  this._totalConsumption = 0
94
93
  this._consumptionDelegate.value = this._totalConsumption
@@ -106,14 +105,14 @@ class Power extends History {
106
105
  }
107
106
 
108
107
  _addEntry () {
109
- // Sensor delivers currentConsumption, compute totalConsumption
110
108
  const now = Math.round(new Date().valueOf() / 1000)
109
+ // Sensor delivers currentConsumption, compute totalConsumption
111
110
  if (this._time != null) {
112
111
  const delta = this._power * (now - this._time) // Ws
113
- this._runningConsumption += Math.round(delta / 600.0) // W * 10 min
114
- this._totalConsumption += Math.round(delta / 3600000.0) // kWh
115
- this._consumptionDelegate.value = this._totalConsumption
116
- this._entry.power = this._runningConsumption
112
+ this._runningConsumption += delta / 60.0 // 0.1 W * 10 min
113
+ this._totalConsumption += delta / 36000.0 // 0.01 kWh
114
+ this._consumptionDelegate.value = Math.round(this._totalConsumption) / 100.0 // kWh
115
+ this._entry.power = Math.round(this._runningConsumption) // 0.1 W * 10 min
117
116
  super._addEntry(now)
118
117
  } else if (this._entry.on != null) {
119
118
  super._addEntry(now)
@@ -131,7 +130,7 @@ class Power extends History {
131
130
  '|0c %s %s 01 %s',
132
131
  numToHex(swap32(this._h.currentEntry), 8),
133
132
  numToHex(swap32(entry.time - this._h.initialTime), 8),
134
- numToHex(swap16(entry.power * 10), 4)
133
+ numToHex(swap16(entry.power), 4)
135
134
  )
136
135
  }
137
136
  if (entry.power == null) {
@@ -146,7 +145,7 @@ class Power extends History {
146
145
  '|0d %s %s 03 %s %s',
147
146
  numToHex(swap32(this._h.currentEntry), 8),
148
147
  numToHex(swap32(entry.time - this._h.initialTime), 8),
149
- numToHex(swap16(entry.power * 10), 4),
148
+ numToHex(swap16(entry.power), 4),
150
149
  numToHex(entry.on, 2)
151
150
  )
152
151
  }
@@ -72,12 +72,15 @@ class Thermo extends ServiceDelegate.History {
72
72
  setTemp: targetTemperatureDelegate.value,
73
73
  valvePosition: valvePositionDelegate.value
74
74
  }
75
- temperatureDelegate
76
- .on('didSet', (value) => { this._entry.currentTemp = value })
77
- targetTemperatureDelegate
78
- .on('didSet', (value) => { this._entry.setTemp = value })
79
- valvePositionDelegate
80
- .on('didSet', (value) => { this._entry.valvePosition = value })
75
+ temperatureDelegate.on('didSet', (value) => {
76
+ this._entry.currentTemp = value
77
+ })
78
+ targetTemperatureDelegate.on('didSet', (value) => {
79
+ this._entry.setTemp = value
80
+ })
81
+ valvePositionDelegate.on('didSet', (value) => {
82
+ this._entry.valvePosition = value
83
+ })
81
84
  }
82
85
 
83
86
  // I think 1201 and 1d01 are for current mode and target more, but it doesn't
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Library for homebridge plugins",
4
4
  "author": "Erik Baauw",
5
5
  "license": "Apache-2.0",
6
- "version": "5.7.1",
6
+ "version": "5.7.2",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"