homebridge-deconz 0.0.27 → 0.1.1
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/config.schema.json +0 -7
- package/lib/Deconz/Resource.js +27 -4
- package/lib/DeconzAccessory/AirPurifier.js +0 -2
- package/lib/DeconzAccessory/Gateway.js +298 -149
- package/lib/DeconzAccessory/Light.js +27 -37
- package/lib/DeconzAccessory/Sensor.js +91 -1
- package/lib/DeconzAccessory/Thermostat.js +1 -3
- package/lib/DeconzAccessory/WarningDevice.js +0 -8
- package/lib/DeconzAccessory/WindowCovering.js +0 -2
- package/lib/DeconzAccessory/index.js +123 -13
- package/lib/DeconzPlatform.js +12 -20
- package/lib/DeconzService/AirPressure.js +1 -1
- package/lib/DeconzService/AirPurifier.js +2 -2
- package/lib/DeconzService/AirQuality.js +1 -1
- package/lib/DeconzService/Alarm.js +1 -1
- package/lib/DeconzService/Battery.js +19 -9
- package/lib/DeconzService/Button.js +1 -0
- package/lib/DeconzService/CarbonMonoxide.js +1 -1
- package/lib/DeconzService/Consumption.js +3 -1
- package/lib/DeconzService/Contact.js +1 -25
- package/lib/DeconzService/Daylight.js +22 -19
- package/lib/DeconzService/Flag.js +1 -1
- package/lib/DeconzService/Gateway.js +48 -0
- package/lib/DeconzService/Humidity.js +1 -1
- package/lib/DeconzService/Leak.js +1 -1
- package/lib/DeconzService/Light.js +111 -86
- package/lib/DeconzService/LightLevel.js +3 -3
- package/lib/DeconzService/Motion.js +3 -9
- package/lib/DeconzService/Power.js +2 -1
- package/lib/DeconzService/Status.js +1 -1
- package/lib/DeconzService/Switch.js +1 -1
- package/lib/DeconzService/WindowCovering.js +14 -4
- package/lib/DeconzService/index.js +11 -12
- package/package.json +6 -6
- package/lib/DeconzAccessory/Contact.js +0 -53
- package/lib/DeconzAccessory/Motion.js +0 -53
- package/lib/DeconzAccessory/Temperature.js +0 -61
- package/lib/DeconzService/DeviceSettings.js +0 -65
- package/lib/DeconzService/GatewaySettings.js +0 -176
@@ -1,53 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzAccessory/Motion.js
|
2
|
-
// Copyright © 2022 Erik Baauw. All rights reserved.
|
3
|
-
//
|
4
|
-
// Homebridge plugin for deCONZ.
|
5
|
-
|
6
|
-
'use strict'
|
7
|
-
|
8
|
-
const homebridgeLib = require('homebridge-lib')
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
10
|
-
|
11
|
-
const { History } = homebridgeLib.ServiceDelegate
|
12
|
-
|
13
|
-
class Motion extends DeconzAccessory {
|
14
|
-
/** Instantiate a delegate for an accessory corresponding to a device.
|
15
|
-
* @param {DeconzAccessory.Gateway} gateway - The gateway.
|
16
|
-
* @param {Deconz.Device} device - The device.
|
17
|
-
*/
|
18
|
-
constructor (gateway, device) {
|
19
|
-
super(gateway, device, gateway.Accessory.Categories.SENSOR)
|
20
|
-
|
21
|
-
this.identify()
|
22
|
-
|
23
|
-
this.service = this.createService(device.resource, { primaryService: true })
|
24
|
-
|
25
|
-
for (const subtype in device.resourceBySubtype) {
|
26
|
-
const resource = device.resourceBySubtype[subtype]
|
27
|
-
if (subtype === device.primary) {
|
28
|
-
continue
|
29
|
-
}
|
30
|
-
this.createService(resource)
|
31
|
-
}
|
32
|
-
|
33
|
-
this.historyService = new History.Motion(this, {
|
34
|
-
motionDelegate: this.service.characteristicDelegate('motion'),
|
35
|
-
lastActivationDelegate: this.service.characteristicDelegate('lastActivation'),
|
36
|
-
lightLevelDelegate: this.serviceByServiceName.LightLevel == null
|
37
|
-
? null
|
38
|
-
: this.serviceByServiceName.LightLevel.characteristicDelegate('lightlevel'),
|
39
|
-
temperatureDelegate: this.serviceByServiceName.Temperature == null
|
40
|
-
? null
|
41
|
-
: this.serviceByServiceName.Temperature.characteristicDelegate('temperature')
|
42
|
-
})
|
43
|
-
|
44
|
-
this.createSettingsService()
|
45
|
-
|
46
|
-
setImmediate(() => {
|
47
|
-
this.debug('initialised')
|
48
|
-
this.emit('initialised')
|
49
|
-
})
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
module.exports = Motion
|
@@ -1,61 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzAccessory/Temperature.js
|
2
|
-
// Copyright © 2022 Erik Baauw. All rights reserved.
|
3
|
-
//
|
4
|
-
// Homebridge plugin for deCONZ.
|
5
|
-
|
6
|
-
'use strict'
|
7
|
-
|
8
|
-
const homebridgeLib = require('homebridge-lib')
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
10
|
-
|
11
|
-
const { History } = homebridgeLib.ServiceDelegate
|
12
|
-
|
13
|
-
class Temperature extends DeconzAccessory {
|
14
|
-
/** Instantiate a delegate for an accessory corresponding to a device.
|
15
|
-
* @param {DeconzAccessory.Gateway} gateway - The gateway.
|
16
|
-
* @param {Deconz.Device} device - The device.
|
17
|
-
*/
|
18
|
-
constructor (gateway, device, settings = {}) {
|
19
|
-
super(gateway, device, gateway.Accessory.Categories.SENSOR)
|
20
|
-
this.identify()
|
21
|
-
|
22
|
-
this.service = this.createService(device.resource, { primaryService: true })
|
23
|
-
|
24
|
-
for (const subtype in device.resourceBySubtype) {
|
25
|
-
const resource = device.resourceBySubtype[subtype]
|
26
|
-
if (subtype === device.primary) {
|
27
|
-
continue
|
28
|
-
}
|
29
|
-
this.createService(resource)
|
30
|
-
}
|
31
|
-
|
32
|
-
if (this.serviceByServiceName.AirQuality == null) {
|
33
|
-
this.historyService = new History.Weather(this, {
|
34
|
-
temperatureDelegate: this.service.characteristicDelegate('temperature'),
|
35
|
-
humidityDelegate: this.serviceByServiceName.Humidity == null
|
36
|
-
? null
|
37
|
-
: this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
|
38
|
-
airPressureDelegate: this.serviceByServiceName.AirPressure == null
|
39
|
-
? null
|
40
|
-
: this.serviceByServiceName.AirPressure.characteristicDelegate('airPressure')
|
41
|
-
})
|
42
|
-
} else {
|
43
|
-
this.historyService = new History.Room(this, {
|
44
|
-
temperatureDelegate: this.service.characteristicDelegate('temperature'),
|
45
|
-
humidityDelegate: this.serviceByServiceName.Humidity == null
|
46
|
-
? null
|
47
|
-
: this.serviceByServiceName.Humidity.characteristicDelegate('humidity'),
|
48
|
-
airQualityDelegate: this.serviceByServiceName.AirQuality.characteristicDelegate('vocDensity')
|
49
|
-
})
|
50
|
-
}
|
51
|
-
|
52
|
-
this.createSettingsService()
|
53
|
-
|
54
|
-
setImmediate(() => {
|
55
|
-
this.debug('initialised')
|
56
|
-
this.emit('initialised')
|
57
|
-
})
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
module.exports = Temperature
|
@@ -1,65 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzService/DeviceSettings.js
|
2
|
-
// Copyright © 2022 Erik Baauw. All rights reserved.
|
3
|
-
//
|
4
|
-
// Homebridge plugin for deCONZ.
|
5
|
-
|
6
|
-
'use strict'
|
7
|
-
|
8
|
-
const homebridgeLib = require('homebridge-lib')
|
9
|
-
const DeconzAccessory = require('../DeconzAccessory')
|
10
|
-
|
11
|
-
/** Delegate class for a DeconzDevice service.
|
12
|
-
* @extends ServiceDelegate
|
13
|
-
* @memberof DeconzService
|
14
|
-
*/
|
15
|
-
class DeviceSettings extends homebridgeLib.ServiceDelegate {
|
16
|
-
constructor (accessory, params = {}) {
|
17
|
-
params.Service = accessory.Services.my.DeconzDevice
|
18
|
-
params.exposeConfiguredName = true
|
19
|
-
super(accessory, params)
|
20
|
-
|
21
|
-
this.debug('settings: %j', params)
|
22
|
-
|
23
|
-
this.addCharacteristicDelegate({
|
24
|
-
key: 'expose',
|
25
|
-
Characteristic: this.Characteristics.my.Expose,
|
26
|
-
value: params.expose,
|
27
|
-
silent: true
|
28
|
-
}).on('didSet', (value) => {
|
29
|
-
accessory.gateway.exposeDevice(params.subtype, value)
|
30
|
-
})
|
31
|
-
|
32
|
-
if (params.hasRepeat) {
|
33
|
-
this.addCharacteristicDelegate({
|
34
|
-
key: 'repeat',
|
35
|
-
Characteristic: this.Characteristics.my.Repeat,
|
36
|
-
props: { minValue: 0, maxValue: 1, minStep: 1 },
|
37
|
-
value: 0
|
38
|
-
})
|
39
|
-
}
|
40
|
-
|
41
|
-
if (params.logLevel != null) {
|
42
|
-
this.addCharacteristicDelegate({
|
43
|
-
key: 'logLevel',
|
44
|
-
Characteristic: this.Characteristics.my.LogLevel,
|
45
|
-
value: params.logLevel
|
46
|
-
})
|
47
|
-
}
|
48
|
-
|
49
|
-
this.addCharacteristicDelegate({
|
50
|
-
key: 'resource',
|
51
|
-
Characteristic: this.Characteristics.my.Resource,
|
52
|
-
value: params.resource,
|
53
|
-
silent: true
|
54
|
-
})
|
55
|
-
|
56
|
-
if (!(accessory instanceof DeconzAccessory.Gateway)) {
|
57
|
-
accessory.propertyDelegate('name')
|
58
|
-
.on('didSet', (name) => {
|
59
|
-
this.values.configuredName = name + ' Settings'
|
60
|
-
})
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
module.exports = DeviceSettings
|
@@ -1,176 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzService/GatewaySettings.js
|
2
|
-
// Copyright © 2022 Erik Baauw. All rights reserved.
|
3
|
-
//
|
4
|
-
// Homebridge plugin for deCONZ.
|
5
|
-
|
6
|
-
'use strict'
|
7
|
-
|
8
|
-
const homebridgeLib = require('homebridge-lib')
|
9
|
-
|
10
|
-
/** Delegate class for a DeconzGateway service.
|
11
|
-
* @extends ServiceDelegate
|
12
|
-
* @memberof DeconzService
|
13
|
-
*/
|
14
|
-
class GatewaySettings extends homebridgeLib.ServiceDelegate {
|
15
|
-
constructor (gateway, params = {}) {
|
16
|
-
params.Service = gateway.Services.my.DeconzGateway
|
17
|
-
params.exposeConfiguredName = true
|
18
|
-
super(gateway, params)
|
19
|
-
this.gateway = gateway
|
20
|
-
|
21
|
-
this.addCharacteristicDelegate({
|
22
|
-
key: 'expose',
|
23
|
-
Characteristic: this.Characteristics.my.Expose,
|
24
|
-
value: true
|
25
|
-
}).on('didSet', async (value, fromHomeKit) => {
|
26
|
-
try {
|
27
|
-
this.values.statusActve = value
|
28
|
-
if (value) {
|
29
|
-
await gateway.connect()
|
30
|
-
} else if (fromHomeKit) {
|
31
|
-
await gateway.reset()
|
32
|
-
}
|
33
|
-
} catch (error) { this.error(error) }
|
34
|
-
})
|
35
|
-
|
36
|
-
this.addCharacteristicDelegate({
|
37
|
-
key: 'lights',
|
38
|
-
Characteristic: this.Characteristics.my.ExposeLights,
|
39
|
-
value: false
|
40
|
-
}).on('didSet', (value) => { this.updateRtypes('lights', value) })
|
41
|
-
|
42
|
-
this.addCharacteristicDelegate({
|
43
|
-
key: 'sensors',
|
44
|
-
Characteristic: this.Characteristics.my.ExposeSensors,
|
45
|
-
value: false
|
46
|
-
}).on('didSet', (value) => { this.updateRtypes('sensors', value) })
|
47
|
-
|
48
|
-
this.addCharacteristicDelegate({
|
49
|
-
key: 'groups',
|
50
|
-
Characteristic: this.Characteristics.my.ExposeGroups,
|
51
|
-
value: false
|
52
|
-
}).on('didSet', (value) => { this.updateRtypes('groups', value) })
|
53
|
-
|
54
|
-
this.addCharacteristicDelegate({
|
55
|
-
key: 'schedules',
|
56
|
-
Characteristic: this.Characteristics.my.ExposeSchedules,
|
57
|
-
value: false
|
58
|
-
})
|
59
|
-
|
60
|
-
this.addCharacteristicDelegate({
|
61
|
-
key: 'heartrate',
|
62
|
-
Characteristic: this.Characteristics.my.Heartrate,
|
63
|
-
value: 30
|
64
|
-
})
|
65
|
-
|
66
|
-
this.addCharacteristicDelegate({
|
67
|
-
key: 'lastUpdated',
|
68
|
-
Characteristic: this.Characteristics.my.LastUpdated,
|
69
|
-
silent: true
|
70
|
-
})
|
71
|
-
|
72
|
-
this.addCharacteristicDelegate({
|
73
|
-
key: 'logLevel',
|
74
|
-
Characteristic: this.Characteristics.my.LogLevel,
|
75
|
-
value: this.accessoryDelegate.logLevel
|
76
|
-
})
|
77
|
-
|
78
|
-
this.addCharacteristicDelegate({
|
79
|
-
key: 'restart',
|
80
|
-
Characteristic: this.Characteristics.my.Restart,
|
81
|
-
value: false
|
82
|
-
}).on('didSet', async (value, fromHomeKit) => {
|
83
|
-
try {
|
84
|
-
if (value) {
|
85
|
-
try {
|
86
|
-
await gateway.client.restart()
|
87
|
-
this.values.search = false
|
88
|
-
this.values.unlock = false
|
89
|
-
return
|
90
|
-
} catch (error) { this.warn(error) }
|
91
|
-
}
|
92
|
-
if (fromHomeKit) {
|
93
|
-
await homebridgeLib.timeout(this.platform.config.waitTimeReset)
|
94
|
-
this.values.restart = !value
|
95
|
-
}
|
96
|
-
} catch (error) { this.error(error) }
|
97
|
-
})
|
98
|
-
this.values.restart = false
|
99
|
-
|
100
|
-
this.addCharacteristicDelegate({
|
101
|
-
key: 'search',
|
102
|
-
Characteristic: this.Characteristics.my.Search,
|
103
|
-
value: false
|
104
|
-
}).on('didSet', async (value, fromHomeKit) => {
|
105
|
-
try {
|
106
|
-
if (value) {
|
107
|
-
try {
|
108
|
-
await gateway.client.search()
|
109
|
-
await homebridgeLib.timeout(120000)
|
110
|
-
this.values.search = false
|
111
|
-
return
|
112
|
-
} catch (error) { this.warn(error) }
|
113
|
-
}
|
114
|
-
if (fromHomeKit) {
|
115
|
-
await homebridgeLib.timeout(this.platform.config.waitTimeReset)
|
116
|
-
this.values.search = !value
|
117
|
-
}
|
118
|
-
} catch (error) { this.error(error) }
|
119
|
-
})
|
120
|
-
this.values.search = false
|
121
|
-
|
122
|
-
this.addCharacteristicDelegate({
|
123
|
-
key: 'statusActve',
|
124
|
-
Characteristic: this.Characteristics.hap.StatusActive,
|
125
|
-
value: true,
|
126
|
-
silent: true
|
127
|
-
})
|
128
|
-
|
129
|
-
this.addCharacteristicDelegate({
|
130
|
-
key: 'transitionTime',
|
131
|
-
Characteristic: this.Characteristics.my.TransitionTime,
|
132
|
-
value: this.gateway.defaultTransitionTime
|
133
|
-
})
|
134
|
-
this.values.transitionTime = this.gateway.defaultTransitionTime
|
135
|
-
|
136
|
-
this.addCharacteristicDelegate({
|
137
|
-
key: 'unlock',
|
138
|
-
Characteristic: this.Characteristics.my.Unlock,
|
139
|
-
value: false
|
140
|
-
}).on('didSet', async (value, fromHomeKit) => {
|
141
|
-
try {
|
142
|
-
if (value) {
|
143
|
-
try {
|
144
|
-
await gateway.client.unlock()
|
145
|
-
await homebridgeLib.timeout(60000)
|
146
|
-
this.values.unlock = false
|
147
|
-
return
|
148
|
-
} catch (error) { this.warn(error) }
|
149
|
-
}
|
150
|
-
if (fromHomeKit) {
|
151
|
-
await homebridgeLib.timeout(this.platform.config.waitTimeReset)
|
152
|
-
this.values.unlock = !value
|
153
|
-
}
|
154
|
-
} catch (error) { this.error(error) }
|
155
|
-
})
|
156
|
-
this.values.unlock = false
|
157
|
-
}
|
158
|
-
|
159
|
-
async updateRtypes (rtype, value) {
|
160
|
-
const rtypes = this.gateway.values.rtypes.slice()
|
161
|
-
if (value) {
|
162
|
-
rtypes.push(rtype)
|
163
|
-
} else {
|
164
|
-
rtypes.splice(rtypes.indexOf(rtype), 1)
|
165
|
-
}
|
166
|
-
this.gateway.values.rtypes = rtypes
|
167
|
-
}
|
168
|
-
|
169
|
-
update (config) {
|
170
|
-
this.values.expose = true
|
171
|
-
this.values.lastUpdated = new Date().toString().slice(0, 24)
|
172
|
-
this.values.restart = false
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
|
-
module.exports = GatewaySettings
|