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
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VerisurePlatform = void 0;
7
+ const verisure_1 = __importDefault(require("verisure"));
8
+ const alarm_1 = require("./accessories/alarm");
9
+ const climateSensor_1 = require("./accessories/climateSensor");
10
+ const contactSensor_1 = require("./accessories/contactSensor");
11
+ const doorLock_1 = require("./accessories/doorLock");
12
+ const smartPlug_1 = require("./accessories/smartPlug");
13
+ const deviceNames_1 = require("./deviceNames");
14
+ const i18n_1 = require("./i18n");
15
+ const overviewPoller_1 = require("./overviewPoller");
16
+ const settings_1 = require("./settings");
17
+ const types_1 = require("./types");
18
+ class VerisurePlatform {
19
+ log;
20
+ api;
21
+ config;
22
+ verisure;
23
+ accessories = new Map();
24
+ handlers = new Map();
25
+ pollers = new Map();
26
+ constructor(log, config, api) {
27
+ this.log = log;
28
+ this.api = api;
29
+ const { VERISURE_ALARM_CODE, VERISURE_DOOR_CODE, VERISURE_EMAIL, VERISURE_PASSWORD, VERISURE_COOKIES, VERISURE_TOKEN, // Deprecated.
30
+ } = process.env;
31
+ this.config = {
32
+ ...config,
33
+ alarmCode: VERISURE_ALARM_CODE || config.alarmCode,
34
+ doorCode: VERISURE_DOOR_CODE || config.doorcode || config.doorCode,
35
+ email: VERISURE_EMAIL || config.email,
36
+ password: VERISURE_PASSWORD || config.password,
37
+ cookies: (VERISURE_COOKIES && VERISURE_COOKIES.split(';')) || config.cookies,
38
+ installations: config.installations ?? [],
39
+ pollInterval: config.pollInterval ?? 60,
40
+ showAutoLockSwitch: config.showAutoLockSwitch ?? true,
41
+ showAudioSwitch: config.showAudioSwitch ?? true,
42
+ audioOffValue: config.audioOffValue ?? 'LOW',
43
+ audioOnValue: config.audioOnValue ?? 'HIGH',
44
+ forceArm: config.forceArm ?? true,
45
+ excludedAccessoryTypes: config.excludedAccessoryTypes ?? [],
46
+ excludedDevices: config.excludedDevices ?? [],
47
+ };
48
+ if (VERISURE_TOKEN || config.token) {
49
+ this.log.error('DEPRECATED: Property "token" in config. Please see README to get and configure "cookies".');
50
+ }
51
+ this.verisure = new verisure_1.default(this.config.email, this.config.password, this.config.cookies);
52
+ this.api.on('didFinishLaunching', () => {
53
+ this.discoverDevices().catch((error) => {
54
+ this.log.error(`Unexpected error while discovering devices: ${error.message}`);
55
+ });
56
+ });
57
+ this.api.on('shutdown', () => {
58
+ this.pollers.forEach((poller) => poller.stop());
59
+ });
60
+ }
61
+ /** Called by Homebridge once at startup for every accessory it restored
62
+ * from its cache, before `didFinishLaunching`/discovery runs. */
63
+ configureAccessory(accessory) {
64
+ this.accessories.set(accessory.UUID, accessory);
65
+ }
66
+ /** Shared per-installation overview fetcher/poller, used by both this
67
+ * class and every accessory handler. */
68
+ poller(installation) {
69
+ let poller = this.pollers.get(installation.giid);
70
+ if (!poller) {
71
+ poller = new overviewPoller_1.OverviewPoller(installation, this.log, this.config.pollInterval * 1000);
72
+ this.pollers.set(installation.giid, poller);
73
+ }
74
+ return poller;
75
+ }
76
+ async ensureAuthenticated() {
77
+ if (this.verisure.cookies.length) {
78
+ return;
79
+ }
80
+ await this.verisure.getToken();
81
+ if (!this.verisure.getCookie('vid')) {
82
+ throw new Error('MFA is enabled for this account. Please see the README, and run "npx homebridge-verisure@latest" to generate "cookies".');
83
+ }
84
+ }
85
+ async discoverDevices() {
86
+ try {
87
+ await this.ensureAuthenticated();
88
+ }
89
+ catch (error) {
90
+ if ((0, types_1.isUnauthorized)(error)) {
91
+ this.log.error('Verisure rejected the configured email/password (401). Please check your credentials, or use "cookies" instead if MFA is enabled - see the README.');
92
+ }
93
+ else {
94
+ this.log.error(error.message);
95
+ }
96
+ return;
97
+ }
98
+ let installations;
99
+ try {
100
+ const configuredAliases = this.config.installations ?? [];
101
+ installations = (await this.verisure.getInstallations())
102
+ .filter((installation) => configuredAliases.length === 0 || configuredAliases.includes(installation.config.alias));
103
+ }
104
+ catch (error) {
105
+ if ((0, types_1.isUnauthorized)(error)) {
106
+ this.log.error('Verisure rejected our credentials (401). If you use "cookies" for MFA, they\'ve likely expired - run "npx homebridge-verisure@latest" to get fresh ones.');
107
+ }
108
+ else {
109
+ this.log.error(`Unable to get installations. Please check configured credentials: ${error.message}`);
110
+ }
111
+ return;
112
+ }
113
+ if (installations.length === 0) {
114
+ this.log.error(`No installations found matching config: ${JSON.stringify(this.config.installations)}`);
115
+ return;
116
+ }
117
+ await Promise.all(installations.map((installation) => this.discoverInstallation(installation)));
118
+ this.retireUnusedPollers(installations);
119
+ }
120
+ retireUnusedPollers(installations) {
121
+ const activeGiids = new Set(installations.map((installation) => installation.giid));
122
+ for (const [giid, poller] of this.pollers) {
123
+ if (!activeGiids.has(giid)) {
124
+ poller.stop();
125
+ this.pollers.delete(giid);
126
+ }
127
+ }
128
+ }
129
+ async discoverInstallation(installation) {
130
+ const poller = this.poller(installation);
131
+ let overview;
132
+ try {
133
+ overview = await poller.getOverview();
134
+ }
135
+ catch (error) {
136
+ this.log.error(`${installation.config.alias}: Unable to fetch the device list (${error.message}). Keeping any previously discovered accessories for this installation as-is.`);
137
+ return;
138
+ }
139
+ const devices = this.buildDeviceList(installation, overview);
140
+ const seenUUIDs = new Set();
141
+ const newAccessories = [];
142
+ for (const device of devices) {
143
+ const uuid = this.api.hap.uuid.generate(`${settings_1.PLUGIN_NAME}:${installation.giid}:${device.type}:${device.deviceLabel ?? 'alarm'}`);
144
+ seenUUIDs.add(uuid);
145
+ let accessory = this.accessories.get(uuid);
146
+ const isNew = !accessory;
147
+ if (!accessory) {
148
+ accessory = new this.api.platformAccessory(device.displayName, uuid);
149
+ }
150
+ accessory.context = {
151
+ deviceType: device.type,
152
+ deviceLabel: device.deviceLabel,
153
+ installationGiid: installation.giid,
154
+ };
155
+ const handler = this.instantiateHandler(device, accessory, installation);
156
+ handler.paint(overview);
157
+ this.accessories.set(uuid, accessory);
158
+ this.handlers.set(uuid, handler);
159
+ if (isNew) {
160
+ newAccessories.push(accessory);
161
+ }
162
+ }
163
+ if (newAccessories.length > 0) {
164
+ this.log.info(`${installation.config.alias}: Registering ${newAccessories.length} new accessorie(s).`);
165
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, newAccessories);
166
+ }
167
+ const staleAccessories = [...this.accessories.entries()]
168
+ .filter(([uuid, accessory]) => accessory.context.installationGiid === installation.giid && !seenUUIDs.has(uuid))
169
+ .map(([uuid, accessory]) => {
170
+ this.accessories.delete(uuid);
171
+ this.handlers.delete(uuid);
172
+ return accessory;
173
+ });
174
+ if (staleAccessories.length > 0) {
175
+ this.log.info(`${installation.config.alias}: Removing ${staleAccessories.length} accessorie(s) no longer present on this installation.`);
176
+ this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, staleAccessories);
177
+ }
178
+ poller.start();
179
+ }
180
+ instantiateHandler(device, accessory, installation) {
181
+ switch (device.type) {
182
+ case 'alarm':
183
+ return new alarm_1.Alarm(this, accessory, installation);
184
+ case 'climateSensor':
185
+ return new climateSensor_1.ClimateSensor(this, accessory, installation, device.initial);
186
+ case 'contactSensor':
187
+ return new contactSensor_1.ContactSensor(this, accessory, installation);
188
+ case 'doorLock':
189
+ return new doorLock_1.DoorLock(this, accessory, installation);
190
+ case 'smartPlug':
191
+ return new smartPlug_1.SmartPlug(this, accessory, installation, device.initial);
192
+ default:
193
+ throw new Error(`Unknown accessory type: ${device.type}`);
194
+ }
195
+ }
196
+ isExcluded(type, deviceLabel, area) {
197
+ const excludedTypes = this.config.excludedAccessoryTypes ?? [];
198
+ if (excludedTypes.includes(type)) {
199
+ return true;
200
+ }
201
+ const excludedDevices = (this.config.excludedDevices ?? []).map((entry) => entry.trim().toLowerCase());
202
+ return excludedDevices.includes((deviceLabel ?? '').toLowerCase())
203
+ || excludedDevices.includes((area ?? '').trim().toLowerCase());
204
+ }
205
+ buildDeviceList(installation, overview) {
206
+ const devices = [];
207
+ const translate = (0, i18n_1.i18n)(installation.locale);
208
+ if (overview.armState && this.config.alarmCode && !this.isExcluded('alarm')) {
209
+ devices.push({
210
+ type: 'alarm',
211
+ displayName: `Alarm - ${installation.config.alias}`,
212
+ });
213
+ }
214
+ (overview.climates ?? []).forEach((climate) => {
215
+ const { deviceLabel, area, gui } = climate.device;
216
+ if (this.isExcluded('climateSensor', deviceLabel, area)) {
217
+ return;
218
+ }
219
+ const label = gui?.label ?? 'UNKNOWN';
220
+ const name = translate(deviceNames_1.CLIMATE_DEVICE_NAMES[label]) ?? label;
221
+ const areaName = (area ?? '').trim();
222
+ devices.push({
223
+ type: 'climateSensor',
224
+ deviceLabel,
225
+ displayName: areaName ? `${name} - ${areaName}` : name,
226
+ initial: climate,
227
+ });
228
+ });
229
+ (overview.doorWindows ?? []).forEach((doorWindow) => {
230
+ const { deviceLabel, area } = doorWindow.device;
231
+ if (this.isExcluded('contactSensor', deviceLabel, area)) {
232
+ return;
233
+ }
234
+ const areaName = (area ?? '').trim();
235
+ devices.push({
236
+ type: 'contactSensor',
237
+ deviceLabel,
238
+ displayName: areaName || 'Contact sensor',
239
+ });
240
+ });
241
+ (overview.smartplugs ?? []).forEach((smartplug) => {
242
+ const { deviceLabel, area } = smartplug.device;
243
+ if (this.isExcluded('smartPlug', deviceLabel, area)) {
244
+ return;
245
+ }
246
+ const areaName = (area ?? '').trim();
247
+ devices.push({
248
+ type: 'smartPlug',
249
+ deviceLabel,
250
+ displayName: areaName ? `SmartPlug - ${areaName}` : 'SmartPlug',
251
+ initial: smartplug,
252
+ });
253
+ });
254
+ if (this.config.doorCode) {
255
+ (overview.doorlocks ?? []).forEach((doorlock) => {
256
+ const { deviceLabel, area } = doorlock.device;
257
+ if (this.isExcluded('doorLock', deviceLabel, area)) {
258
+ return;
259
+ }
260
+ const areaName = (area ?? '').trim();
261
+ devices.push({
262
+ type: 'doorLock',
263
+ deviceLabel,
264
+ displayName: areaName ? `SmartLock - ${areaName}` : 'SmartLock',
265
+ });
266
+ });
267
+ }
268
+ return devices;
269
+ }
270
+ }
271
+ exports.VerisurePlatform = VerisurePlatform;
272
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AACA,wDAA0D;AAE1D,+CAA4C;AAE5C,+DAA4D;AAC5D,+DAA4D;AAE5D,qDAAkD;AAClD,uDAAoD;AACpD,+CAAqD;AACrD,iCAA8B;AAC9B,qDAAkD;AAClD,yCAAwD;AAExD,mCAAyC;AASzC,MAAa,gBAAgB;IAYT;IAEA;IAbF,MAAM,CAAyB;IAE9B,QAAQ,CAAW;IAEnB,WAAW,GAAG,IAAI,GAAG,EAA+C,CAAC;IAErE,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAA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AC,CAAC;QAEH,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAC9C,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC;gBAC9C,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC;oBACnD,OAAO;gBACT,CAAC;gBACD,MAAM,QAAQ,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,UAAU;oBAChB,WAAW;oBACX,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,QAAQ,EAAE,CAAC,CAAC,CAAC,WAAW;iBAChE,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAvSD,4CAuSC"}
@@ -0,0 +1,21 @@
1
+ export declare const PLATFORM_NAME = "verisure";
2
+ export declare const PLUGIN_NAME = "homebridge-verisure";
3
+ /** How long a cached Verisure overview may be reused for an ad-hoc HomeKit
4
+ * "get" request before we fetch a fresh one. Collapses bursts of near
5
+ * simultaneous reads (HomeKit often asks for several characteristics within
6
+ * the same second) into a single API call. The scheduled poll tick always
7
+ * forces a fresh fetch regardless of this value. */
8
+ export declare const OVERVIEW_CACHE_TTL_MS = 5000;
9
+ /** Same idea, for the door lock configuration query (auto-lock + audio
10
+ * volume), which is otherwise fetched independently by up to three different
11
+ * characteristics. */
12
+ export declare const DOOR_LOCK_CONFIG_CACHE_TTL_MS = 5000;
13
+ /** Upper bound on how long we'll keep polling for an arm/lock state change
14
+ * to resolve before giving up. Without a cap, a Verisure-side issue that
15
+ * never resolves a transaction would make resolveChangeResult() retry
16
+ * forever. */
17
+ export declare const CHANGE_RESULT_TIMEOUT_MS = 30000;
18
+ export declare const CHANGE_RESULT_POLL_INTERVAL_MS = 200;
19
+ /** Minimum time to wait before polling again after a rate-limit response,
20
+ * regardless of the configured pollInterval. */
21
+ export declare const RATE_LIMIT_BACKOFF_MS: number;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RATE_LIMIT_BACKOFF_MS = exports.CHANGE_RESULT_POLL_INTERVAL_MS = exports.CHANGE_RESULT_TIMEOUT_MS = exports.DOOR_LOCK_CONFIG_CACHE_TTL_MS = exports.OVERVIEW_CACHE_TTL_MS = exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
+ exports.PLATFORM_NAME = 'verisure';
5
+ exports.PLUGIN_NAME = 'homebridge-verisure';
6
+ /** How long a cached Verisure overview may be reused for an ad-hoc HomeKit
7
+ * "get" request before we fetch a fresh one. Collapses bursts of near
8
+ * simultaneous reads (HomeKit often asks for several characteristics within
9
+ * the same second) into a single API call. The scheduled poll tick always
10
+ * forces a fresh fetch regardless of this value. */
11
+ exports.OVERVIEW_CACHE_TTL_MS = 5000;
12
+ /** Same idea, for the door lock configuration query (auto-lock + audio
13
+ * volume), which is otherwise fetched independently by up to three different
14
+ * characteristics. */
15
+ exports.DOOR_LOCK_CONFIG_CACHE_TTL_MS = 5000;
16
+ /** Upper bound on how long we'll keep polling for an arm/lock state change
17
+ * to resolve before giving up. Without a cap, a Verisure-side issue that
18
+ * never resolves a transaction would make resolveChangeResult() retry
19
+ * forever. */
20
+ exports.CHANGE_RESULT_TIMEOUT_MS = 30000;
21
+ exports.CHANGE_RESULT_POLL_INTERVAL_MS = 200;
22
+ /** Minimum time to wait before polling again after a rate-limit response,
23
+ * regardless of the configured pollInterval. */
24
+ exports.RATE_LIMIT_BACKOFF_MS = 15 * 60 * 1000;
25
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,UAAU,CAAC;AAC3B,QAAA,WAAW,GAAG,qBAAqB,CAAC;AAEjD;;;;oDAIoD;AACvC,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;sBAEsB;AACT,QAAA,6BAA6B,GAAG,IAAI,CAAC;AAElD;;;cAGc;AACD,QAAA,wBAAwB,GAAG,KAAK,CAAC;AACjC,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAElD;gDACgD;AACnC,QAAA,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,117 @@
1
+ import type { PlatformConfig } from 'homebridge';
2
+ export interface VerisurePlatformConfig extends PlatformConfig {
3
+ email?: string;
4
+ password?: string;
5
+ cookies?: string[];
6
+ alarmCode?: string;
7
+ doorCode?: string;
8
+ /** @deprecated use doorCode */
9
+ doorcode?: string;
10
+ installations?: string[];
11
+ pollInterval?: number;
12
+ showAutoLockSwitch?: boolean;
13
+ showAudioSwitch?: boolean;
14
+ audioOffValue?: 'SILENCE' | 'LOW';
15
+ audioOnValue?: 'LOW' | 'HIGH';
16
+ /** Passed to Verisure's armAway/armHome mutations to bypass the "open
17
+ * door/window" guard. Without this, arming can silently fail (or reject)
18
+ * whenever a sensor isn't in its expected state - see issue #56. */
19
+ forceArm?: boolean;
20
+ /** Accessory types to never expose, e.g. ["climateSensor", "contactSensor"]. */
21
+ excludedAccessoryTypes?: AccessoryType[];
22
+ /** Device labels, or free-text area names, to never expose regardless of type. */
23
+ excludedDevices?: string[];
24
+ /** @deprecated replaced by cookies */
25
+ token?: string;
26
+ }
27
+ export type AccessoryType = 'alarm' | 'climateSensor' | 'contactSensor' | 'doorLock' | 'smartPlug';
28
+ export interface Device {
29
+ deviceLabel: string;
30
+ area?: string;
31
+ gui?: {
32
+ label?: string;
33
+ support?: string;
34
+ };
35
+ }
36
+ export interface ArmState {
37
+ type?: string;
38
+ statusType: string;
39
+ date?: string;
40
+ name?: string;
41
+ changedVia?: string;
42
+ }
43
+ export interface Climate {
44
+ device: Device;
45
+ humidityEnabled?: boolean;
46
+ humidityTimestamp?: string;
47
+ /** `null` when this device doesn't support the reading, not just absent -
48
+ * e.g. VoiceBox devices report `humidityValue: null`. */
49
+ humidityValue?: number | null;
50
+ temperatureTimestamp?: string;
51
+ temperatureValue?: number | null;
52
+ }
53
+ export interface DoorWindow {
54
+ device: Device;
55
+ type?: string;
56
+ state: string;
57
+ wired?: boolean;
58
+ reportTime?: string;
59
+ }
60
+ export interface SmartPlugDevice {
61
+ device: Device;
62
+ currentState: string;
63
+ icon?: string;
64
+ isHazardous?: boolean;
65
+ }
66
+ export interface DoorLockDevice {
67
+ device: Device;
68
+ currentLockState: string;
69
+ motorJam?: boolean;
70
+ }
71
+ export interface DoorLockConfiguration {
72
+ autoLockEnabled?: boolean;
73
+ voiceLevel?: string;
74
+ volume?: string;
75
+ /** Present instead of the above on non-Yale locks (e.g. DanaLock). */
76
+ holdBackLatchDuration?: number;
77
+ twistAssistEnabled?: boolean;
78
+ }
79
+ export interface SmartLockConfigEntry {
80
+ device: Device;
81
+ configuration: DoorLockConfiguration;
82
+ }
83
+ /** Everything a poll tick can learn about an installation. Every field is
84
+ * nullable/absent-tolerant: Verisure's GraphQL API can - and for some
85
+ * installation types (e.g. certain PreSense systems) reliably does - return
86
+ * `null` for fields this plugin doesn't use, which previously crashed the
87
+ * whole overview fetch (see issues #188, #189). */
88
+ export interface Overview {
89
+ armState?: ArmState | null;
90
+ climates?: Climate[] | null;
91
+ doorWindows?: DoorWindow[] | null;
92
+ smartplugs?: SmartPlugDevice[] | null;
93
+ doorlocks?: DoorLockDevice[] | null;
94
+ }
95
+ export interface PollResult {
96
+ result: string | null;
97
+ createTime?: string;
98
+ }
99
+ /** Duck-typed shape of errors thrown by the `verisure` transport package. */
100
+ export interface VerisureError extends Error {
101
+ errors?: Array<{
102
+ message?: string;
103
+ data?: {
104
+ errorCode?: string;
105
+ status?: number;
106
+ };
107
+ }>;
108
+ isRateLimited?: boolean;
109
+ response?: {
110
+ status?: number;
111
+ data?: unknown;
112
+ };
113
+ }
114
+ export declare const isVerisureError: (error: unknown) => error is VerisureError;
115
+ export declare const isGraphqlException: (error: unknown) => error is VerisureError;
116
+ export declare const isRateLimited: (error: unknown) => boolean;
117
+ export declare const isUnauthorized: (error: unknown) => boolean;
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUnauthorized = exports.isRateLimited = exports.isGraphqlException = exports.isVerisureError = void 0;
4
+ const isVerisureError = (error) => error instanceof Error;
5
+ exports.isVerisureError = isVerisureError;
6
+ const isGraphqlException = (error) => (0, exports.isVerisureError)(error) && error.name === 'GraphqlException';
7
+ exports.isGraphqlException = isGraphqlException;
8
+ const isRateLimited = (error) => (0, exports.isVerisureError)(error) && error.isRateLimited === true;
9
+ exports.isRateLimited = isRateLimited;
10
+ const isUnauthorized = (error) => (0, exports.isVerisureError)(error) && error.response?.status === 401;
11
+ exports.isUnauthorized = isUnauthorized;
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAsHO,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC;AAArF,QAAA,eAAe,mBAAsE;AAE3F,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAA0B,EAAE,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAA7H,QAAA,kBAAkB,sBAA2G;AAEnI,MAAM,aAAa,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;AAApG,QAAA,aAAa,iBAAuF;AAE1G,MAAM,cAAc,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC;AAAvG,QAAA,cAAc,kBAAyF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-verisure",
3
- "version": "2.0.2",
4
- "description": "Verisure plugin for homebridge: https://github.com/nfarina/homebridge",
3
+ "version": "3.0.0",
4
+ "description": "Verisure plugin for Homebridge: https://homebridge.io",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "homebridge-plugin"
@@ -14,32 +14,55 @@
14
14
  "type": "paypal",
15
15
  "url": "https://www.paypal.com/paypalme/ptz0n"
16
16
  },
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "bin": "dist/bin/verisure.js",
20
+ "files": [
21
+ "dist",
22
+ "config.schema.json"
23
+ ],
17
24
  "scripts": {
18
- "test": "eslint lib && jest --coverage",
19
- "start": "homebridge -P ."
25
+ "prepublishOnly": "npm run build",
26
+ "build": "rimraf dist && tsc && chmod +x dist/bin/verisure.js",
27
+ "watch": "tsc --watch",
28
+ "lint": "eslint src",
29
+ "test": "npm run lint && npm run build && jest --coverage",
30
+ "start": "npm run build && homebridge -U ./.homebridge -P . -D"
20
31
  },
21
- "bin": "bin/verisure",
22
32
  "bugs": {
23
33
  "url": "http://github.com/ptz0n/homebridge-verisure/issues"
24
34
  },
25
35
  "engines": {
26
- "node": ">=12",
27
- "homebridge": ">=1.0.0"
36
+ "node": "^22 || ^24 || ^26",
37
+ "homebridge": "^2.0.0"
28
38
  },
29
39
  "dependencies": {
30
40
  "enquirer": "^2.3.6",
31
- "verisure": "^5.1.2"
41
+ "verisure": "^6.0.0"
42
+ },
43
+ "overrides": {
44
+ "@homebridge/hap-nodejs": "$@homebridge/hap-nodejs"
32
45
  },
33
46
  "devDependencies": {
34
- "eslint": "^6.7.2",
35
- "eslint-config-airbnb-base": "^14.0.0",
36
- "eslint-plugin-import": "^2.8.0",
37
- "eslint-plugin-jest": "^23.1.0",
38
- "hap-nodejs": "^0.11.1",
39
- "homebridge": "^1.7.0",
40
- "jest": "^25.0.0"
47
+ "@homebridge/hap-nodejs": "^2.2.3",
48
+ "@types/jest": "^29.5.13",
49
+ "@types/node": "^22.9.0",
50
+ "@typescript-eslint/eslint-plugin": "^8.14.0",
51
+ "@typescript-eslint/parser": "^8.14.0",
52
+ "eslint": "^8.57.1",
53
+ "eslint-plugin-jest": "^28.9.0",
54
+ "homebridge": "^2.0.0",
55
+ "jest": "^29.7.0",
56
+ "rimraf": "^6.0.1",
57
+ "ts-jest": "^29.2.5",
58
+ "typescript": "^5.6.3"
41
59
  },
42
60
  "jest": {
43
- "testEnvironment": "node"
61
+ "preset": "ts-jest",
62
+ "testEnvironment": "node",
63
+ "testPathIgnorePatterns": [
64
+ "/node_modules/",
65
+ "/dist/"
66
+ ]
44
67
  }
45
68
  }