homebridge-deconz 0.0.10 → 0.0.13
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/README.md +3 -6
- package/cli/deconz.js +12 -0
- package/config.schema.json +1 -0
- package/homebridge-ui/public/index.html +26 -0
- package/homebridge-ui/public/style.css +0 -0
- package/homebridge-ui/server.js +43 -0
- package/lib/Deconz/ApiClient.js +34 -1
- package/lib/Deconz/ApiResponse.js +1 -1
- package/lib/Deconz/Device.js +0 -7
- package/lib/Deconz/Resource.js +751 -25
- package/lib/DeconzAccessory/Contact.js +54 -0
- package/lib/DeconzAccessory/Gateway.js +102 -66
- package/lib/DeconzAccessory/Light.js +42 -37
- package/lib/DeconzAccessory/Motion.js +51 -0
- package/lib/DeconzAccessory/Sensor.js +35 -0
- package/lib/DeconzAccessory/Temperature.js +63 -0
- package/lib/DeconzAccessory/Thermostat.js +50 -0
- package/lib/DeconzAccessory/WarningDevice.js +56 -0
- package/lib/DeconzAccessory/WindowCovering.js +47 -0
- package/lib/DeconzAccessory/index.js +144 -2
- package/lib/DeconzPlatform.js +5 -2
- package/lib/DeconzService/AirPressure.js +43 -0
- package/lib/DeconzService/AirQuality.js +20 -11
- package/lib/DeconzService/Alarm.js +13 -9
- package/lib/DeconzService/Battery.js +53 -0
- package/lib/DeconzService/Button.js +9 -2
- package/lib/DeconzService/CarbonMonoxide.js +38 -0
- package/lib/DeconzService/Consumption.js +65 -0
- package/lib/DeconzService/Contact.js +60 -0
- package/lib/DeconzService/Daylight.js +132 -0
- package/lib/DeconzService/DeviceSettings.js +11 -0
- package/lib/DeconzService/Flag.js +52 -0
- package/lib/DeconzService/Humidity.js +37 -0
- package/lib/DeconzService/Leak.js +38 -0
- package/lib/DeconzService/Light.js +122 -172
- package/lib/DeconzService/LightLevel.js +54 -0
- package/lib/DeconzService/LightsResource.js +112 -0
- package/lib/DeconzService/Motion.js +101 -0
- package/lib/DeconzService/Outlet.js +76 -0
- package/lib/DeconzService/Power.js +83 -0
- package/lib/DeconzService/SensorsResource.js +96 -0
- package/lib/DeconzService/Smoke.js +38 -0
- package/lib/DeconzService/Status.js +53 -0
- package/lib/DeconzService/Switch.js +93 -0
- package/lib/DeconzService/Temperature.js +63 -0
- package/lib/DeconzService/Thermostat.js +175 -0
- package/lib/DeconzService/WarningDevice.js +68 -0
- package/lib/DeconzService/WindowCovering.js +162 -0
- package/lib/DeconzService/index.js +79 -25
- package/package.json +6 -5
- package/lib/Client/ApiError.js +0 -42
- package/lib/DeconzAccessory/Device.js +0 -69
- package/lib/DeconzService/Sensor.js +0 -61
@@ -1,69 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzAccessory/Device.js
|
2
|
-
// Copyright © 2022 Erik Baauw. All rights reserved.
|
3
|
-
//
|
4
|
-
// Homebridge plugin for deCONZ.
|
5
|
-
|
6
|
-
'use strict'
|
7
|
-
|
8
|
-
const DeconzAccessory = require('.')
|
9
|
-
const DeconzService = require('../DeconzService')
|
10
|
-
|
11
|
-
/** Delegate class for a HomeKit accessory,
|
12
|
-
* corresponding to a Zigbee or virtual device on a deCONZ gateway,
|
13
|
-
* that is not yet supported.
|
14
|
-
* @extends DeconzAccessory
|
15
|
-
* @memberof DeconzAccessory
|
16
|
-
*/
|
17
|
-
class Device extends DeconzAccessory {
|
18
|
-
/** Instantiate a delegate for an accessory corresponding to a device.
|
19
|
-
* @param {DeconzAccessory.Gateway} gateway - The gateway.
|
20
|
-
* @param {Deconz.Device} device - The device.
|
21
|
-
*/
|
22
|
-
constructor (gateway, device) {
|
23
|
-
super(gateway, device)
|
24
|
-
|
25
|
-
this.identify()
|
26
|
-
|
27
|
-
this.service = new DeconzService.Button(this, {
|
28
|
-
name: this.name + ' Button',
|
29
|
-
button: 1,
|
30
|
-
events: DeconzService.Button.SINGLE | DeconzService.Button.LONG,
|
31
|
-
primaryService: true
|
32
|
-
})
|
33
|
-
|
34
|
-
this.settingsService = new DeconzService.DeviceSettings(this, {
|
35
|
-
name: this.name + ' Settings',
|
36
|
-
subtype: this.id,
|
37
|
-
resource: this.device.rpaths.join(', '),
|
38
|
-
expose: true,
|
39
|
-
logLevel: gateway.logLevel
|
40
|
-
})
|
41
|
-
|
42
|
-
this
|
43
|
-
.on('polled', (device) => {
|
44
|
-
this.vdebug('%s: polled', this.device.rpaths.join(', '))
|
45
|
-
this.service.update(1003)
|
46
|
-
})
|
47
|
-
.on('changed', (rpath, body) => {
|
48
|
-
if (Object.keys(body).length === 1) {
|
49
|
-
if (body.state != null) {
|
50
|
-
rpath += '/state'
|
51
|
-
body = body.state
|
52
|
-
} else if (body.config != null) {
|
53
|
-
rpath += '/config'
|
54
|
-
body = body.config
|
55
|
-
}
|
56
|
-
}
|
57
|
-
this.debug('%s: changed: %j', rpath, body)
|
58
|
-
this.service.update(1002)
|
59
|
-
})
|
60
|
-
.on('identify', this.identify)
|
61
|
-
|
62
|
-
setImmediate(() => {
|
63
|
-
this.debug('initialised')
|
64
|
-
this.emit('initialised')
|
65
|
-
})
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
module.exports = Device
|
@@ -1,61 +0,0 @@
|
|
1
|
-
// homebridge-deconz/lib/DeconzService/Sensor.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 Deconz = require('../Deconz')
|
10
|
-
|
11
|
-
/**
|
12
|
-
* @memberof DeconzService
|
13
|
-
*/
|
14
|
-
class Sensor extends homebridgeLib.ServiceDelegate {
|
15
|
-
constructor (device, params = {}) {
|
16
|
-
super(device, params)
|
17
|
-
this.id = params.id
|
18
|
-
this.platform = device.platform
|
19
|
-
this.gateway = device.gateway
|
20
|
-
this.client = device.client
|
21
|
-
this.rtype = '/sensors'
|
22
|
-
this.rid = params.rid
|
23
|
-
this.resouce = this.rtype + '/' + this.rid
|
24
|
-
}
|
25
|
-
|
26
|
-
addCharacteristicDelegates (params = {}) {
|
27
|
-
this.addCharacteristicDelegate({
|
28
|
-
key: 'lastUpdated',
|
29
|
-
Characteristic: this.Characteristics.my.LastUpdated,
|
30
|
-
silent: true
|
31
|
-
})
|
32
|
-
this.addCharacteristicDelegate({
|
33
|
-
key: 'enabled',
|
34
|
-
Characteristic: this.Characteristics.my.Enabled
|
35
|
-
}).on('didSet', (value) => {
|
36
|
-
this.values.statusActive = value
|
37
|
-
})
|
38
|
-
this.addCharacteristicDelegate({
|
39
|
-
key: 'statusActive',
|
40
|
-
Characteristic: this.Characteristics.hap.StatusActive
|
41
|
-
})
|
42
|
-
this.addCharacteristicDelegate({
|
43
|
-
key: 'statusFault',
|
44
|
-
Characteristic: this.Characteristics.hap.StatusFault
|
45
|
-
})
|
46
|
-
}
|
47
|
-
|
48
|
-
update (sensor) {
|
49
|
-
this.values.lastUpdated = Deconz.Client.dateToString(sensor.state.lastupdated)
|
50
|
-
this.values.enabled = sensor.config.on
|
51
|
-
this.values.statusFault = sensor.config.reachable === false
|
52
|
-
? this.Characteristics.hap.StatusFault.GENERAL_FAULT
|
53
|
-
: this.Characteristics.hap.StatusFault.NO_FAULT
|
54
|
-
}
|
55
|
-
|
56
|
-
async put (resource, body) {
|
57
|
-
return this.client.put(this.resource + resource, body)
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
module.exports = Sensor
|