homebridge-verisure 2.0.2 → 3.0.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 (68) hide show
  1. package/README.md +33 -2
  2. package/config.schema.json +30 -0
  3. package/dist/accessories/alarm.d.ts +28 -0
  4. package/dist/accessories/alarm.js +129 -0
  5. package/dist/accessories/alarm.js.map +1 -0
  6. package/dist/accessories/base.d.ts +39 -0
  7. package/dist/accessories/base.js +63 -0
  8. package/dist/accessories/base.js.map +1 -0
  9. package/dist/accessories/climateSensor.d.ts +14 -0
  10. package/dist/accessories/climateSensor.js +60 -0
  11. package/dist/accessories/climateSensor.js.map +1 -0
  12. package/dist/accessories/contactSensor.d.ts +14 -0
  13. package/dist/accessories/contactSensor.js +39 -0
  14. package/dist/accessories/contactSensor.js.map +1 -0
  15. package/dist/accessories/doorLock.d.ts +32 -0
  16. package/dist/accessories/doorLock.js +162 -0
  17. package/dist/accessories/doorLock.js.map +1 -0
  18. package/dist/accessories/smartPlug.d.ts +15 -0
  19. package/dist/accessories/smartPlug.js +54 -0
  20. package/dist/accessories/smartPlug.js.map +1 -0
  21. package/dist/bin/verisure.d.ts +2 -0
  22. package/dist/bin/verisure.js +56 -0
  23. package/dist/bin/verisure.js.map +1 -0
  24. package/dist/cache.d.ts +14 -0
  25. package/dist/cache.js +35 -0
  26. package/dist/cache.js.map +1 -0
  27. package/dist/deviceNames.d.ts +3 -0
  28. package/dist/deviceNames.js +16 -0
  29. package/dist/deviceNames.js.map +1 -0
  30. package/dist/i18n/index.d.ts +1 -0
  31. package/dist/i18n/index.js +18 -0
  32. package/dist/i18n/index.js.map +1 -0
  33. package/dist/i18n/nb_NO.json +22 -0
  34. package/dist/i18n/sv_SE.json +22 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.js +7 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/operations.d.ts +27 -0
  39. package/dist/operations.js +322 -0
  40. package/dist/operations.js.map +1 -0
  41. package/dist/overviewPoller.d.ts +53 -0
  42. package/dist/overviewPoller.js +169 -0
  43. package/dist/overviewPoller.js.map +1 -0
  44. package/dist/platform.d.ts +27 -0
  45. package/dist/platform.js +272 -0
  46. package/dist/platform.js.map +1 -0
  47. package/dist/settings.d.ts +21 -0
  48. package/dist/settings.js +25 -0
  49. package/dist/settings.js.map +1 -0
  50. package/dist/types.d.ts +117 -0
  51. package/dist/types.js +12 -0
  52. package/dist/types.js.map +1 -0
  53. package/package.json +39 -16
  54. package/CHANGELOG.md +0 -180
  55. package/bin/verisure +0 -55
  56. package/index.js +0 -6
  57. package/lib/accessories/alarm.js +0 -111
  58. package/lib/accessories/climatesensor.js +0 -68
  59. package/lib/accessories/contactsensor.js +0 -45
  60. package/lib/accessories/doorlock.js +0 -216
  61. package/lib/accessories/index.js +0 -13
  62. package/lib/accessories/smartplug.js +0 -60
  63. package/lib/accessories/verisure.js +0 -62
  64. package/lib/i18n/index.js +0 -11
  65. package/lib/i18n/nb_NO.json +0 -22
  66. package/lib/i18n/sv_SE.json +0 -22
  67. package/lib/operations.js +0 -225
  68. package/lib/platform.js +0 -156
package/CHANGELOG.md DELETED
@@ -1,180 +0,0 @@
1
- ## 2.0.2 (Feb 10, 2026)
2
-
3
- ### Dependencies
4
-
5
- * Bump `verisure` module.
6
-
7
- ## 2.0.1 (Mar 31, 2021)
8
-
9
- ### Dependencies
10
-
11
- * Bump `verisure` module.
12
-
13
- ## 2.0.0 (Mar 20, 2023)
14
-
15
- ### Config
16
-
17
- * __BREAKING__: Property `cookies` replaces `token`. See README for how to get and configure.
18
-
19
- ### Plugin & accessories
20
-
21
- * Use Verisure GraphQL API.
22
-
23
- ### Dependencies
24
-
25
- * Bump `verisure` module to support GraphQL requests.
26
-
27
- ## 1.16.0 (Aug 27, 2022)
28
-
29
- ### Plugin
30
-
31
- * Added config options for door lock; auto-lock and volume.
32
-
33
- ## 1.15.0 (Jan 11, 2022)
34
-
35
- ### Plugin
36
-
37
- * Added config option for installations to initiate.
38
-
39
- ## 1.14.2 (Jan 4, 2022)
40
-
41
- ### Plugin
42
-
43
- * Initiate gracefully, to not affect other plugins.
44
-
45
- ## 1.14.1 (Oct 8, 2021)
46
-
47
- ### Dependencies
48
-
49
- * Bump `verisure` module.
50
-
51
- ## 1.14.0 (Mar 17, 2021)
52
-
53
- ### Config
54
-
55
- * Support for Multi-factor authentication (MFA).
56
-
57
- ### Dependencies
58
-
59
- * Bump `verisure` module.
60
-
61
- ## 1.13.2 (Feb 28, 2021)
62
-
63
- ### Plugin
64
-
65
- * Return empty list of accessories when initiation fails.
66
-
67
- ## 1.13.1 (Feb 27, 2021)
68
-
69
- ### Plugin
70
-
71
- * Safer logging when initiating.
72
-
73
- ## 1.13.0 (Feb 24, 2021)
74
-
75
- ### Dependencies
76
-
77
- * Bump `verisure` module.
78
-
79
- ## 1.12.1 (Sep 2, 2020)
80
-
81
- ### Plugin
82
-
83
- * Correct schema file for UI.
84
-
85
- ## 1.12.0 (Sep 1, 2020)
86
-
87
- ### Plugin
88
-
89
- * Add schema file for UI.
90
-
91
- ## 1.11.0 (Nov 30, 2019)
92
-
93
- ### Dependencies
94
-
95
- * Bump `verisure` module.
96
-
97
- ## 1.10.1 (Feb 4, 2019)
98
-
99
- ### Accessories
100
-
101
- * Remove night arm from supported states.
102
-
103
- ## 1.10.0 (Feb 3, 2019)
104
-
105
- ### Accessories
106
-
107
- * Enable configuration of auto-lock via switch service.
108
-
109
- ### Platform
110
-
111
- * Enable configuration using environment variables.
112
-
113
- ## 1.9.2 (Dec 23, 2018)
114
-
115
- ### Accessories
116
-
117
- * Set supported temperature range.
118
-
119
- ## 1.9.1 (Jul 5, 2018)
120
-
121
- ### Accessories
122
-
123
- * When unable to set SmartPlug state, pass a correctly composed error object.
124
-
125
- ## 1.9.0 (Jun 15, 2018)
126
-
127
- ### Accessories
128
-
129
- * Poll for contact sensor state value.
130
-
131
- ## 1.8.0 (Jun 11, 2018)
132
-
133
- ### Accessories
134
-
135
- * Poll alarm and door lock accessories for current state.
136
-
137
- ## 1.7.0 (Jun 5, 2018)
138
-
139
- ### Refactor
140
-
141
- * Split platform from accessories.
142
- * Setup linting and unit testing with decent coverage.
143
-
144
- ### Accessories
145
-
146
- * Added support for security system.
147
- * Added support for contact sensors.
148
- * Added humidity service to supported climate sensors.
149
-
150
- ## Config
151
-
152
- * Key `doorcode` changed to `doorCode`.
153
-
154
- ## 1.6.0 (Jul 20, 2017)
155
-
156
- ### Accessories
157
-
158
- * Added support for door lock (Yale Doorman).
159
-
160
- ## 1.5.0 (Apr 23, 2017)
161
-
162
- ### Dependencies
163
-
164
- * Bump `verisure` module.
165
-
166
- ## 1.4.0 (Feb 2, 2017)
167
-
168
- ### Accessories
169
-
170
- * Added support for climate sensor type `HUMIDITY1`.
171
-
172
- ## 1.3.0 (Jan 25, 2017)
173
-
174
- ### Accessories
175
-
176
- * Added support for climate sensor type `SIREN1`.
177
-
178
- ## 1.1.0 (Jan 23, 2017)
179
-
180
- Initial release with basic support for climate sensors.
package/bin/verisure DELETED
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
-
4
- const { prompt, Password } = require('enquirer');
5
-
6
- const Verisure = require('verisure');
7
-
8
- const validate = (value) => !!value.length;
9
-
10
- const run = async () => {
11
- const { email } = await prompt({
12
- type: 'input',
13
- name: 'email',
14
- message: 'What is your login email?',
15
- validate,
16
- });
17
-
18
- const password = await new Password({
19
- name: 'password',
20
- message: 'What is your password?',
21
- validate,
22
- }).run();
23
-
24
- const verisure = new Verisure(email.trim(), password);
25
-
26
- await verisure.getToken();
27
-
28
- if (!verisure.getCookie('vid')) {
29
- console.log('\n', 'One-time code sent.', '\n');
30
-
31
- const { code } = await prompt({
32
- type: 'input',
33
- name: 'code',
34
- message: 'What is your one-time code?',
35
- validate,
36
- });
37
-
38
- await verisure.getToken(code.trim());
39
- }
40
-
41
- console.log('\n', 'Your config is ready.', '\n');
42
-
43
- console.log(JSON.stringify({
44
- platform: 'verisure',
45
- name: 'Verisure',
46
- email,
47
- cookies: verisure.cookies,
48
- }, null, 2));
49
- };
50
-
51
- try {
52
- run();
53
- } catch (error) {
54
- console.log(error.message);
55
- }
package/index.js DELETED
@@ -1,6 +0,0 @@
1
- const VerisurePlatform = require('./lib/platform');
2
-
3
- module.exports = (homebridge) => {
4
- VerisurePlatform.init(homebridge);
5
- homebridge.registerPlatform('homebridge-verisure', 'verisure', VerisurePlatform);
6
- };
@@ -1,111 +0,0 @@
1
- const VerisureAccessory = require('./verisure');
2
-
3
- const {
4
- overviewOperation,
5
- armAwayOperation,
6
- armHomeOperation,
7
- disarmOperation,
8
- pollArmStateOperation,
9
- } = require('../operations');
10
-
11
- class Alarm extends VerisureAccessory {
12
- constructor(...args) {
13
- super(...args);
14
-
15
- const { alarmCode } = this.platformConfig;
16
- this.alarmCode = alarmCode.toString();
17
- this.model = 'ALARM';
18
- this.name = VerisureAccessory.getUniqueAccessoryName(`Alarm - ${this.installation.config.alias}`);
19
-
20
- const { SecuritySystemCurrentState } = this.homebridge.hap.Characteristic;
21
- this.armStateMap = {
22
- ARMED_AWAY: SecuritySystemCurrentState.AWAY_ARM,
23
- ARMED_HOME: SecuritySystemCurrentState.STAY_ARM,
24
- DISARMED: SecuritySystemCurrentState.DISARMED,
25
- };
26
- }
27
-
28
- resolveArmState(input) {
29
- let output;
30
-
31
- // Verisure to HAP
32
- if (typeof input === 'string') {
33
- output = this.armStateMap[input];
34
- }
35
-
36
- // HAP to Verisure
37
- if (typeof input === 'number') {
38
- output = Object.keys(this.armStateMap).find((key) => this.armStateMap[key] === input);
39
- }
40
-
41
- if (typeof output === 'undefined') {
42
- throw Error(`Cannot resolve arm state from unknown input: ${input}`);
43
- }
44
-
45
- return output;
46
- }
47
-
48
- getCurrentAlarmState(callback) {
49
- this.log('Getting current alarm state.', 'debug');
50
-
51
- this.installation.client(overviewOperation)
52
- .then((overview) => {
53
- callback(null, this.resolveArmState(overview.installation.armState.statusType));
54
- })
55
- .catch(callback);
56
- }
57
-
58
- setTargetAlarmState(value, callback) {
59
- this.log(`Setting target alarm state to: ${value}`);
60
-
61
- const targetArmState = this.resolveArmState(value);
62
-
63
- const operation = {
64
- ARMED_AWAY: armAwayOperation,
65
- ARMED_HOME: armHomeOperation,
66
- DISARMED: disarmOperation,
67
- }[targetArmState](this.alarmCode);
68
-
69
- this.installation.client(operation)
70
- .then(({ transactionId }) => this.resolveChangeResult(
71
- pollArmStateOperation(transactionId, targetArmState),
72
- ))
73
- .then(() => {
74
- callback(); // Successful action.
75
-
76
- setImmediate(() => {
77
- const { SecuritySystemCurrentState } = this.homebridge.hap.Characteristic;
78
- this.service.setCharacteristic(SecuritySystemCurrentState, value);
79
- });
80
- })
81
- .catch(callback);
82
- }
83
-
84
- getServices() {
85
- const { Service, Characteristic } = this.homebridge.hap;
86
-
87
- this.service = new Service.SecuritySystem(this.name);
88
-
89
- const currentStateCharacteristic = this.service
90
- .getCharacteristic(Characteristic.SecuritySystemCurrentState)
91
- .on('get', this.getCurrentAlarmState.bind(this));
92
-
93
- const targetStateCharacteristic = this.service
94
- .getCharacteristic(Characteristic.SecuritySystemTargetState)
95
- .on('get', this.getCurrentAlarmState.bind(this))
96
- .on('set', this.setTargetAlarmState.bind(this));
97
-
98
- const { NIGHT_ARM } = Characteristic.SecuritySystemTargetState;
99
- const validValues = targetStateCharacteristic.props.validValues
100
- .filter((state) => state !== NIGHT_ARM);
101
- targetStateCharacteristic.setProps({ validValues });
102
-
103
- this.accessoryInformation.setCharacteristic(Characteristic.Model, this.model);
104
-
105
- this.pollCharacteristics.push(currentStateCharacteristic);
106
-
107
- return [this.accessoryInformation, this.service];
108
- }
109
- }
110
-
111
- module.exports = Alarm;
@@ -1,68 +0,0 @@
1
- const VerisureAccessory = require('./verisure');
2
- const { overviewOperation } = require('../operations');
3
- const i18n = require('../i18n');
4
-
5
- const deviceNames = {
6
- HOMEPAD: 'VoiceBox',
7
- HUMIDITY: 'Climate sensor',
8
- SIREN: 'Siren',
9
- SMOKE: 'Smoke detector',
10
- VOICEBOX: 'VoiceBox',
11
- // TODO: Old ones, not verified from GraphQL.
12
- SMARTCAMERA1: 'SmartCam',
13
- WATER1: 'Water detector',
14
- };
15
-
16
- class ClimateSensor extends VerisureAccessory {
17
- constructor(...args) {
18
- super(...args);
19
-
20
- const { device: { area, gui: { label } } } = this.config;
21
- const _ = i18n(this.installation.locale);
22
- const name = _(deviceNames[label]) || label;
23
-
24
- this.model = label;
25
- this.name = VerisureAccessory.getUniqueAccessoryName(`${name} - ${area}`);
26
- }
27
-
28
- getCurrentPropertyValue(property, callback) {
29
- this.log(`Getting current ${property} value.`);
30
-
31
- this.installation.client(overviewOperation)
32
- .then((overview) => overview.installation.climates
33
- .find((climate) => climate.device.deviceLabel === this.serialNumber))
34
- .then((device) => {
35
- callback(null, device[`${property}Value`]);
36
- })
37
- .catch(callback);
38
- }
39
-
40
- getServices() {
41
- const { Service, Characteristic } = this.homebridge.hap;
42
-
43
- const services = [];
44
-
45
- services.push(this.accessoryInformation.setCharacteristic(Characteristic.Model, this.model));
46
-
47
- if (this.config.temperatureValue) {
48
- this.temperatureService = new Service.TemperatureSensor(this.name);
49
- this.temperatureService
50
- .getCharacteristic(Characteristic.CurrentTemperature)
51
- .setProps({ minValue: -40.0, maxValue: 60.0 })
52
- .on('get', this.getCurrentPropertyValue.bind(this, 'temperature'));
53
- services.push(this.temperatureService);
54
- }
55
-
56
- if (this.config.humidityValue) {
57
- this.humidityService = new Service.HumiditySensor(this.name);
58
- this.humidityService
59
- .getCharacteristic(Characteristic.CurrentRelativeHumidity)
60
- .on('get', this.getCurrentPropertyValue.bind(this, 'humidity'));
61
- services.push(this.humidityService);
62
- }
63
-
64
- return services;
65
- }
66
- }
67
-
68
- module.exports = ClimateSensor;
@@ -1,45 +0,0 @@
1
- const VerisureAccessory = require('./verisure');
2
- const { overviewOperation } = require('../operations');
3
-
4
- class ContactSensor extends VerisureAccessory {
5
- constructor(...args) {
6
- super(...args);
7
-
8
- const { device: { area }, state } = this.config;
9
-
10
- this.name = VerisureAccessory.getUniqueAccessoryName(area);
11
- this.value = ContactSensor.resolveSensorState(state);
12
- }
13
-
14
- static resolveSensorState(input) {
15
- return input !== 'CLOSE';
16
- }
17
-
18
- getCurrentSensorState(callback) {
19
- this.log('Getting current sensor state.', 'debug');
20
-
21
- this.installation.client(overviewOperation)
22
- .then((overview) => overview.installation.doorWindows
23
- .find((doorWindow) => doorWindow.device.deviceLabel === this.serialNumber))
24
- .then((doorWindow) => {
25
- this.value = ContactSensor.resolveSensorState(doorWindow.state);
26
- callback(null, this.value);
27
- })
28
- .catch(callback);
29
- }
30
-
31
- getServices() {
32
- const { Service, Characteristic } = this.homebridge.hap;
33
-
34
- this.service = new Service.ContactSensor(this.name);
35
- const currentStateCharacteristic = this.service
36
- .getCharacteristic(Characteristic.ContactSensorState)
37
- .on('get', this.getCurrentSensorState.bind(this));
38
-
39
- this.pollCharacteristics.push(currentStateCharacteristic);
40
-
41
- return [this.accessoryInformation, this.service];
42
- }
43
- }
44
-
45
- module.exports = ContactSensor;
@@ -1,216 +0,0 @@
1
- const VerisureAccessory = require('./verisure');
2
- const {
3
- overviewOperation,
4
- doorLockOperation,
5
- doorUnlockOperation,
6
- pollLockStateOperation,
7
- doorLockConfigOperation,
8
- doorLockUpdateConfigOperation,
9
- } = require('../operations');
10
-
11
- class DoorLock extends VerisureAccessory {
12
- constructor(...args) {
13
- super(...args);
14
-
15
- const { area } = this.config.device;
16
- this.name = VerisureAccessory.getUniqueAccessoryName(`SmartLock - ${area}`);
17
-
18
- this.doorCode = this.platformConfig.doorCode;
19
- this.switchName = VerisureAccessory.getUniqueAccessoryName(`Auto-lock - ${area}`);
20
- this.audioName = VerisureAccessory.getUniqueAccessoryName(`Audio - ${area}`);
21
-
22
- // TODO: Could set currentLockState here.
23
- }
24
-
25
- resolveCurrentLockState({ currentLockState, motorJam }) {
26
- const { LockCurrentState } = this.homebridge.hap.Characteristic;
27
-
28
- if (motorJam) {
29
- return LockCurrentState.JAMMED;
30
- }
31
-
32
- return currentLockState === 'LOCKED'
33
- ? LockCurrentState.SECURED
34
- : LockCurrentState.UNSECURED;
35
- }
36
-
37
- getDoorLockState() {
38
- this.log('Getting current lock state.', 'debug');
39
-
40
- return this.installation.client(overviewOperation)
41
- .then((overview) => overview.installation.doorlocks
42
- .find((doorlock) => doorlock.device.deviceLabel === this.serialNumber))
43
- .then((doorLock) => {
44
- if (!doorLock) {
45
- throw Error(`Could not find lock state for ${this.name}.`);
46
- }
47
- return doorLock;
48
- });
49
- }
50
-
51
- getCurrentLockState(callback) {
52
- // TODO: Use this.cachedValue, if available?
53
-
54
- this.getDoorLockState().then((doorLock) => {
55
- callback(null, this.resolveCurrentLockState(doorLock));
56
- }).catch(callback);
57
- }
58
-
59
- getTargetLockState(callback) {
60
- this.log('Getting target lock state.');
61
-
62
- this.getDoorLockState().then(({ currentLockState }) => {
63
- const { LockTargetState } = this.homebridge.hap.Characteristic;
64
-
65
- const targetLockState = this.targetLockState || currentLockState;
66
-
67
- callback(null, targetLockState === 'LOCKED'
68
- ? LockTargetState.SECURED
69
- : LockTargetState.UNSECURED);
70
- }).catch((error) => {
71
- callback(error);
72
- });
73
- }
74
-
75
- setTargetLockState(value, callback) {
76
- this.log(`Setting target lock state to: ${value}`);
77
-
78
- this.targetLockState = value === this.homebridge.hap.Characteristic.LockCurrentState.SECURED
79
- ? 'LOCKED'
80
- : 'UNLOCKED';
81
-
82
- const operation = this.targetLockState === 'LOCKED'
83
- ? doorLockOperation
84
- : doorUnlockOperation;
85
-
86
- this.installation.client(operation(this.serialNumber, this.doorCode))
87
- .then(({ transactionId }) => this.resolveChangeResult(
88
- pollLockStateOperation(transactionId, this.serialNumber, this.targetLockState),
89
- ))
90
- .catch((error) => {
91
- const isAlreadyAtTargetStateError = error.errors && error.errors
92
- .find(({ data: { errorCode } }) => errorCode === 'VAL_00819');
93
- if (isAlreadyAtTargetStateError) {
94
- return true; // Lock at desired state.
95
- }
96
-
97
- throw error;
98
- })
99
- .then(() => {
100
- callback(); // Successful action.
101
-
102
- setImmediate(() => {
103
- const { LockCurrentState } = this.homebridge.hap.Characteristic;
104
- this.lockService.setCharacteristic(LockCurrentState, value);
105
- });
106
- // TODO: Set this.cachedValue with TTL?
107
- })
108
- .catch(callback);
109
- }
110
-
111
- static resolveAutoLockState(config) {
112
- return config.autoLockEnabled === true;
113
- }
114
-
115
- getAutoLockState(callback) {
116
- this.log('Getting current auto lock config.');
117
-
118
- this.installation.client(doorLockConfigOperation(this.serialNumber))
119
- .then(({ installation: { smartLocks: [smartLock] } }) => {
120
- this.autoLockState = DoorLock.resolveAutoLockState(smartLock.configuration);
121
- callback(null, this.autoLockState);
122
- })
123
- .catch(callback);
124
- }
125
-
126
- setAutoLockState(value, callback) {
127
- this.log(`Setting auto lock to: ${value}`);
128
-
129
- this.autoLockState = value;
130
-
131
- this.installation.client(
132
- doorLockUpdateConfigOperation(this.serialNumber, { autoLockEnabled: value }),
133
- )
134
- .then(() => callback(null))
135
- .catch((error) => {
136
- this.log(error.message, 'debug');
137
- // TODO: Revert config state in this.value?
138
- callback({ message: error.errorMessage });
139
- });
140
- }
141
-
142
- getAudioState(callback) {
143
- this.log('Getting current audio config.');
144
-
145
- this.installation.client(doorLockConfigOperation(this.serialNumber))
146
- .then(({ installation: { smartLocks: [smartLock] } }) => {
147
- this.audioState = smartLock.configuration.volume !== this.platformConfig.audioOffValue;
148
- callback(null, this.audioState);
149
- })
150
- .catch(callback);
151
- }
152
-
153
- setAudioState(value, callback) {
154
- this.audioState = value;
155
-
156
- const volume = value
157
- ? this.platformConfig.audioOnValue
158
- : this.platformConfig.audioOffValue;
159
-
160
- this.log(`Setting audio volume to: ${volume}`);
161
-
162
- this.installation.client(
163
- doorLockUpdateConfigOperation(this.serialNumber, { volume }),
164
- )
165
- .then(() => callback(null))
166
- .catch((error) => {
167
- this.log(error.message, 'debug');
168
- // TODO: Revert config state in this.value?
169
- callback({ message: error.errorMessage });
170
- });
171
- }
172
-
173
- getServices() {
174
- const { Service, Characteristic } = this.homebridge.hap;
175
-
176
- const services = [this.accessoryInformation];
177
-
178
- this.lockService = new Service.LockMechanism(this.name);
179
- const currentStateCharacteristic = this.lockService
180
- .getCharacteristic(Characteristic.LockCurrentState)
181
- .on('get', this.getCurrentLockState.bind(this));
182
-
183
- this.lockService
184
- .getCharacteristic(Characteristic.LockTargetState)
185
- .on('get', this.getTargetLockState.bind(this))
186
- .on('set', this.setTargetLockState.bind(this));
187
-
188
- services.push(this.lockService);
189
-
190
- if (this.platformConfig.showAutoLockSwitch) {
191
- this.autoLockService = new Service.Switch(this.switchName, this.switchName);
192
- this.autoLockService
193
- .getCharacteristic(Characteristic.On)
194
- .on('get', this.getAutoLockState.bind(this))
195
- .on('set', this.setAutoLockState.bind(this));
196
-
197
- services.push(this.autoLockService);
198
- }
199
-
200
- if (this.platformConfig.showAudioSwitch) {
201
- this.audioService = new Service.Switch(this.audioName, this.audioName);
202
- this.audioService
203
- .getCharacteristic(Characteristic.On)
204
- .on('get', this.getAudioState.bind(this))
205
- .on('set', this.setAudioState.bind(this));
206
-
207
- services.push(this.audioService);
208
- }
209
-
210
- this.pollCharacteristics.push(currentStateCharacteristic);
211
-
212
- return services;
213
- }
214
- }
215
-
216
- module.exports = DoorLock;
@@ -1,13 +0,0 @@
1
- const Alarm = require('./alarm');
2
- const ClimateSensor = require('./climatesensor');
3
- const ContactSensor = require('./contactsensor');
4
- const DoorLock = require('./doorlock');
5
- const SmartPlug = require('./smartplug');
6
-
7
- module.exports = {
8
- alarm: Alarm,
9
- climateSensor: ClimateSensor,
10
- contactSensor: ContactSensor,
11
- doorLock: DoorLock,
12
- smartPlug: SmartPlug,
13
- };