homebridge-dummy 1.1.0-alpha.0 → 1.1.0-beta.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/CHANGELOG.md CHANGED
@@ -1,27 +1,30 @@
1
- <!-- ⚠️ Plugin has a new owner/maintainer and will undergo significant cleanup and modernization in the near term. If you experience issues you can always downgrade to the last stable version v0.9.0
2
-
3
- Please report any issues you encounter here: https://github.com/mpatfield/homebridge-dummy/issues -->
1
+ # Change Log
4
2
 
5
- # ‼️ WARNING ‼️
3
+ All notable changes to homebridge-dummy will be documented in this file.
6
4
 
7
- ### If upgrading from v0.9.2 or earlier, automations and scenes using Homebridge Dummy accessories will need to be reconfigured. Please downgrade to v0.9.2 or earlier now if you want to keep your existing setup.
5
+ ## 1.1.0-beta.1 (2025-07-29)
8
6
 
9
- ### After updating, you will need to open Homebridge Dummy plugin settings to run the accessory migration helper.
7
+ ### ‼️ WARNING Read this if upgrading from v0.9.2 or earlier…
10
8
 
11
- ### Full details [here](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#v10-migration).
9
+ Automations and scenes using Homebridge Dummy accessories will need to be reconfigured. After upgrading, you must **RESTART HOMEBRIDGE SERVICE & UI** (not just *RESTART HOMEBRIDGE*). After restarting, open the Homebridge Dummy plugin settings to run the accessory migration helper. Full details [here](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#v10-migration).
12
10
 
13
- # Change Log
11
+ ---
14
12
 
15
- All notable changes to homebridge-dummy will be documented in this file.
13
+ ### Added
14
+ - Groups (Beta) - Items sharing the same group name will be collected together in the Home app UI
15
+ - ⚠️ Adding/removing/changing the group name for an accessory will require you to reconfigure any HomeKit scenes or automations
16
+ - Auto-Trigger feature to invoke accessory at a specified interval or times
16
17
 
17
- ## 1.1.0-alpha.0 (2025-07-16)
18
+ ### Changed
19
+ - Reorganized plugin config UI and renamed "Timer" to "Auto-Reset"
18
20
 
19
- ### Added
21
+ ### Fixed
22
+ - Timers over 1 hour were logging incorrectly ([#143](https://github.com/mpatfield/homebridge-dummy/issues/143))
20
23
 
21
- - (Beta) Groups - Items sharing the same group name will be collected together in the Home app UI
22
- - ⚠️ Be aware that adding/removing/changing the group name will require you to reconfigure any HomeKit scenes or automations
24
+ ## 1.0.0 (2025-07-23)
23
25
 
24
- ## 1.0.0-beta.0 (2025-07-14)
26
+ ### Changed
27
+ - Complete code re-write to use [Platform Plugin](https://developers.homebridge.io/#/api/platform-plugins) instead of [Accessory Plugin](https://developers.homebridge.io/#/api/accessory-plugins)
25
28
 
26
29
  ### Added
27
30
  - Drastically improved config UI
@@ -30,9 +33,6 @@ All notable changes to homebridge-dummy will be documented in this file.
30
33
  - Sensor support (CO2, CO, Contact, Leak, Motion, Occupancy, and Smoke)
31
34
  - Execute arbitraty commands when accessory state changes
32
35
 
33
- ### Changed
34
- - Complete code re-write to use [Platform Plugin](https://developers.homebridge.io/#/api/platform-plugins) instead of [Accessory Plugin](https://developers.homebridge.io/#/api/accessory-plugins)
35
-
36
36
  ## 0.9.2 (2025-06-26)
37
37
 
38
38
  ### Fixed
package/README.md CHANGED
@@ -24,7 +24,7 @@ Any issues or damage resulting from use of this plugin are not the fault of the
24
24
 
25
25
  ### tl;dr
26
26
 
27
- ‼️ There are significant code changes between v0.9 and v1.0 which means you will need to reconfigure HomeKit automations after upgrading. Homebridge Dummy will try to migrate old accessories in Homebridge so you don't need to recreate everything.
27
+ ‼️ There are significant code changes between v0.9 and v1.0 which means you will need to reconfigure HomeKit automations after upgrading. Homebridge Dummy will try to help migrate old accessories.
28
28
 
29
29
  ### Why?
30
30
 
@@ -32,16 +32,18 @@ The original HomebridgeDummy was written almost 10 years ago and uses the now de
32
32
 
33
33
  While this still works okay for now, migrating the code to use [Platform Plugins](https://developers.homebridge.io/#/api/platform-plugins) will future-proof Homebridge Dummy and allow for more modern and robust design patterns.
34
34
 
35
- v1.0 doesn't include any new features but will make it much easier to improve and extend this plugin going forward.
35
+ The architecture used in v1.0 will make it much easier to improve and extend this plugin going forward and already includes several new features.
36
36
 
37
37
  ### Drawbacks
38
38
 
39
39
  Unfortunately, there is no built-in way to migrate existing accessory plugins to platform plugins. This means that all accessories will be considered "new" by HomeKit, so any existing automations or room setups will be lost.
40
40
 
41
- However, Homebridge Dummy will try to migrate the accessory configurations to the new system to prevent you having to set them all up again in Homebridge.
41
+ However, Homebridge Dummy will try to help migrate the accessory configurations to the new system to prevent you having to set them all up again in Homebridge.
42
42
 
43
43
  ### Migration Flow
44
44
 
45
+ ⚠️ Please make sure to restart both Homebridge Service AND Homebridge UI after upgrading to v1.0 or you will experience issues with Homebridge Dummy configuration.
46
+
45
47
  Once you have installed v1.0, click on the icon to configure the Homebridge Dummy plugin in the Homebridge UI and it will walk you through the necessary questionnaire.
46
48
 
47
49
  Alternatively, you can add the following to "platforms" in your config.json
@@ -56,15 +58,15 @@ Alternatively, you can add the following to "platforms" in your config.json
56
58
 
57
59
  You will need to restart Homebridge after completing the flow for changes to take effect.
58
60
 
59
- ⚠️ If you are using child bridges with v0.9, you will need to restart Homebridge _twice_ for migrated accessories to show up correctly.
61
+ ⚠️ If you are using child bridges with v0.9, you may need to restart Homebridge _twice_ for migrated accessories to show up correctly.
60
62
 
61
63
  You may safely ignore any "No plugin was found…" errors you see in the Homebridge logs. These should go away after a few Homebridge restarts.
62
64
 
63
65
  ### Problems?
64
66
 
65
- This is a highly experimental flow and may not work as intended. If you see "Sorry, something went wrong with the accessory migration" or encounter other issues, please [create an issue](https://github.com/mpatfield/homebridge-dummy/issues/new?template=new-issue.md).
67
+ This is an experimental flow and may not work as intended. If you see "Sorry, something went wrong with the accessory migration" or encounter other issues, please [create an issue](https://github.com/mpatfield/homebridge-dummy/issues/new?template=new-issue.md).
66
68
 
67
- The first thing the flow does is create a backup called `config.json.bak` in your Homebridge directory. If all else fails, you can replace your `config.json` with the backup and downgrade to Homebridge Dummy v0.9 to restore everything back to normal.
69
+ The first thing the flow does is create a backup called `config.json.bak` in your Homebridge directory. If all else fails, you can replace your `config.json` with the backup and downgrade to Homebridge Dummy v0.9 to restore your previous accessories.
68
70
 
69
71
  ## About
70
72
 
@@ -90,6 +92,13 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
90
92
  "units": "SECONDS | MINUTES | HOURS",
91
93
  "random": true | false
92
94
  },
95
+ "trigger": {
96
+ "type": "INTERVAL" | "CRON",
97
+ "interval": number,
98
+ "units": "SECONDS | MINUTES | HOURS",
99
+ "random": true | false,
100
+ "cron": "string"
101
+ },
93
102
  "sensor": "CarbonDioxideSensor | CarbonMonoxideSensor | ContactSensor | LeakSensor | MotionSensor | OccupancySensor | SmokeSensor",
94
103
  "defaultOn": true | false,
95
104
  "defaultBrightness": 0-100,
@@ -116,12 +125,19 @@ All fields are optional unless noted with an asterisk (*)
116
125
  - `type`* - The type of accessory: `Door`, `Lightbulb`, `LockMechanism`, `Outlet`, `Switch`, `Window`, or `WindowCovering`
117
126
 
118
127
  - `groupName` - (Beta) Items sharing the same group name will be collected together in the Home app UI
119
- - ⚠️ Be aware that adding/removing/changing the group name will require you to reconfigure any HomeKit scenes or automations
128
+ - ⚠️ Adding/removing/changing the group name will require you to reconfigure any HomeKit scenes or automations
120
129
 
121
130
  - `timer.delay` — If defined, the switch will automatically toggle after this many seconds/minutes/hours
122
131
  - `timer.units` — The units to use for delay above (`SECONDS`, `MINUTES`, or `HOURS`). *Required if delay is set.
123
132
  - `timer.random` — If true, the delay will be randomized with a maximum value of `timer.delay`
124
133
 
134
+ - `trigger.type` — Automatically set the accessory to it's non-default value
135
+ - `trigger.interval` — Trigger the accessory after this many seconds/minutes/hours. *Required if `trigger.type` = `INTERVAL`
136
+ - `trigger.units` — The units to use for the interval (`SECONDS`, `MINUTES`, or `HOURS`) *Required if `trigger.type` = `INTERVAL`
137
+ - `trigger.random` — If true, the interval will be randomized with a maximum value of `trigger.interval`
138
+ - `trigger.cron` — The cron string for triggering the accessory. *Required if `trigger.type` = `CRON`
139
+ - See [crontab.guru](http://crontab.guru) for help
140
+
125
141
  - `sensor` - Optionally attach a sensor that mirrors the state of the parent accessory
126
142
  - Only works with `Lightbulb`, `Outlet`, and `Switch`
127
143
  - Valid values are `CarbonDioxideSensor`, `CarbonMonoxideSensor`, `ContactSensor`, `LeakSensor`, `MotionSensor`, `OccupancySensor`, or `SmokeSensor`
@@ -140,7 +156,7 @@ All fields are optional unless noted with an asterisk (*)
140
156
  - `lockCommand` - Arbitraty command to execute when lock mechanism is locked
141
157
  - `unlockCommand` - Arbitraty command to execute when lock mechanism is unlocked
142
158
 
143
- - `resetOnRestart` _ If true, all values return to defaults when Homebridge restarts. Ignored when timer is defined.
159
+ - `resetOnRestart` _ If true, accessory will return to default state when Homebridge restarts
144
160
 
145
161
  - `disableLogging` — If true, state changes will not be logged
146
162
 
@@ -175,7 +191,7 @@ All fields are optional unless noted with an asterisk (*)
175
191
  "delay": 5,
176
192
  "units": "SECONDS"
177
193
  },
178
- "defaultOn: true
194
+ "defaultOn": true
179
195
  }
180
196
  ```
181
197
 
@@ -271,10 +287,29 @@ All fields are optional unless noted with an asterisk (*)
271
287
  }
272
288
  ```
273
289
 
290
+ ### Hourly Trigger Switch
291
+ ```json
292
+ {
293
+ "name": "Hourly",
294
+ "type": "Switch",
295
+ "timer": {
296
+ "delay": 1,
297
+ "units": "SECONDS"
298
+ },
299
+ "trigger": {
300
+ "type": "INTERVAL",
301
+ "interval": 1,
302
+ "units": "HOURS"
303
+ }
304
+ }
305
+ ```
306
+
274
307
  ## Credits
275
308
 
276
- Special thanks to [@nfarina](https://github.com/nfarina) for creating the original version of this plugin and maintaining it for almost 10 (!!!) years
309
+ Special thanks to [@nfarina](https://github.com/sponsors/nfarina) for creating the original version of this plugin and maintaining it for almost 10 (!!!) years
277
310
 
278
311
  [Keryan Belahcene](https://www.instagram.com/keryan.me) for creating the [Flume](https://github.com/homebridge-plugins/homebridge-flume) banner image which was adapted for use with this plugin
279
312
 
313
+ Auto-Trigger feature inspired by [Homebridge Schedule](https://github.com/kbrashears5/typescript-homebridge-schedule) by [@kbrashears5](https://github.com/sponsors/kbrashears5)
314
+
280
315
  And to the amazing creators/contributors of [Homebridge](https://homebridge.io) who made this plugin possible!
@@ -27,6 +27,40 @@
27
27
  "description": "${config.description.random}"
28
28
  }
29
29
  }
30
+ },
31
+ "trigger": {
32
+ "type": "object",
33
+ "properties": {
34
+ "type": {
35
+ "type": "string",
36
+ "title": "${config.title.type}",
37
+ "enum": [ "INTERVAL", "CRON"],
38
+ "enumNames": ["${config.enumNames.interval}", "${config.enumNames.cron}"]
39
+ },
40
+ "interval": {
41
+ "type": "integer",
42
+ "title": "${config.title.interval}",
43
+ "minimum": 1
44
+ },
45
+ "units": {
46
+ "type": "string",
47
+ "title": "${config.title.units}",
48
+ "enum": [ "SECONDS", "MINUTES", "HOURS"],
49
+ "enumNames": ["${config.enumNames.seconds}", "${config.enumNames.minutes}", "${config.enumNames.hours}"]
50
+ },
51
+ "random": {
52
+ "type": "boolean",
53
+ "title": "${config.title.random}",
54
+ "description": "${config.description.random}"
55
+ },
56
+ "cron": {
57
+ "type": "string",
58
+ "title": "${config.title.cron}",
59
+ "description": "${config.description.cron}",
60
+ "placeholder": "* * * * * *",
61
+ "minimum": 1
62
+ }
63
+ }
30
64
  }
31
65
  },
32
66
  "properties": {
@@ -58,6 +92,7 @@
58
92
  "title": "${config.title.groupName}"
59
93
  },
60
94
  "timer": { "$ref": "#/definitions/timer" },
95
+ "trigger": { "$ref": "#/definitions/trigger" },
61
96
  "sensor": {
62
97
  "type": "string",
63
98
  "title": "${config.title.sensor}",
@@ -157,74 +192,7 @@
157
192
  },
158
193
  {
159
194
  "type": "fieldset",
160
- "title": "${config.title.timer}",
161
- "description": "${config.description.timer}",
162
- "condition": {
163
- "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
164
- },
165
- "items": [
166
- {
167
- "type": "div",
168
- "displayFlex": true,
169
- "flex-direction": "row",
170
- "items": [
171
- {
172
- "key": "accessories[].timer.delay",
173
- "flex": "1 1 0"
174
- },
175
- {
176
- "key": "accessories[].timer.units",
177
- "flex": "1 1 0"
178
- }
179
- ]
180
- },
181
- {
182
- "key": "accessories[].timer.random",
183
- "condition": {
184
- "functionBody": "return model.accessories?.[arguments[1]]?.timer?.delay !== undefined;"
185
- }
186
- }
187
- ]
188
- },
189
- {
190
- "type": "fieldset",
191
- "title": "${config.title.commands}",
192
- "description": "${config.description.commands}",
193
- "condition": {
194
- "functionBody": "return ['Lightbulb','Outlet','Switch'].includes(model.accessories?.[arguments[1]]?.type);"
195
- },
196
- "items": [
197
- "accessories[].commandOn",
198
- "accessories[].commandOff"
199
- ]
200
- },
201
- {
202
- "type": "fieldset",
203
- "title": "${config.title.commands}",
204
- "description": "${config.description.commands}",
205
- "condition": {
206
- "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
207
- },
208
- "items": [
209
- "accessories[].commandLock",
210
- "accessories[].commandUnlock"
211
- ]
212
- },
213
- {
214
- "type": "fieldset",
215
- "title": "${config.title.commands}",
216
- "description": "${config.description.commands}",
217
- "condition": {
218
- "functionBody": "return ['Door', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
219
- },
220
- "items": [
221
- "accessories[].commandOpen",
222
- "accessories[].commandClose"
223
- ]
224
- },
225
- {
226
- "type": "fieldset",
227
- "title": "${config.title.options}",
195
+ "notitle": true,
228
196
  "condition": {
229
197
  "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
230
198
  },
@@ -297,10 +265,122 @@
297
265
  "condition": {
298
266
  "functionBody": "return model.accessories?.[arguments[1]]?.timer?.delay === undefined;"
299
267
  }
300
- }
268
+ }
301
269
  ]
302
270
  }
303
271
  ]
272
+ },
273
+ {
274
+ "type": "fieldset",
275
+ "title": "${config.title.trigger}",
276
+ "description": "${config.description.trigger}",
277
+ "condition": {
278
+ "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
279
+ },
280
+ "items": [
281
+ {
282
+ "type": "div",
283
+ "displayFlex": true,
284
+ "flex-direction": "row",
285
+ "items": [
286
+ {
287
+ "key": "accessories[].trigger.type",
288
+ "flex": "1 1 0"
289
+ },
290
+ {
291
+ "key": "accessories[].trigger.interval",
292
+ "flex": "1 1 0",
293
+ "condition": {
294
+ "functionBody": "return model.accessories?.[arguments[1]]?.trigger?.type === 'INTERVAL';"
295
+ }
296
+ },
297
+ {
298
+ "key": "accessories[].trigger.units",
299
+ "flex": "1 1 0",
300
+ "condition": {
301
+ "functionBody": "return model.accessories?.[arguments[1]]?.trigger?.type === 'INTERVAL';"
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "key": "accessories[].trigger.cron",
308
+ "condition": {
309
+ "functionBody": "return model.accessories?.[arguments[1]]?.trigger?.type === 'CRON';"
310
+ }
311
+ },
312
+ {
313
+ "key": "accessories[].trigger.random",
314
+ "condition": {
315
+ "functionBody": "return model.accessories?.[arguments[1]]?.trigger?.type === 'INTERVAL';"
316
+ }
317
+ }
318
+ ]
319
+ },
320
+ {
321
+ "type": "fieldset",
322
+ "title": "${config.title.timer}",
323
+ "description": "${config.description.timer}",
324
+ "condition": {
325
+ "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
326
+ },
327
+ "items": [
328
+ {
329
+ "type": "div",
330
+ "displayFlex": true,
331
+ "flex-direction": "row",
332
+ "items": [
333
+ {
334
+ "key": "accessories[].timer.delay",
335
+ "flex": "1 1 0"
336
+ },
337
+ {
338
+ "key": "accessories[].timer.units",
339
+ "flex": "1 1 0"
340
+ },
341
+ {
342
+ "flex": "1 1 0"
343
+ }
344
+ ]
345
+ },
346
+ "accessories[].timer.random"
347
+ ]
348
+ },
349
+ {
350
+ "type": "fieldset",
351
+ "title": "${config.title.commands}",
352
+ "description": "${config.description.commands}",
353
+ "condition": {
354
+ "functionBody": "return ['Lightbulb','Outlet','Switch'].includes(model.accessories?.[arguments[1]]?.type);"
355
+ },
356
+ "items": [
357
+ "accessories[].commandOn",
358
+ "accessories[].commandOff"
359
+ ]
360
+ },
361
+ {
362
+ "type": "fieldset",
363
+ "title": "${config.title.commands}",
364
+ "description": "${config.description.commands}",
365
+ "condition": {
366
+ "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
367
+ },
368
+ "items": [
369
+ "accessories[].commandLock",
370
+ "accessories[].commandUnlock"
371
+ ]
372
+ },
373
+ {
374
+ "type": "fieldset",
375
+ "title": "${config.title.commands}",
376
+ "description": "${config.description.commands}",
377
+ "condition": {
378
+ "functionBody": "return ['Door', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
379
+ },
380
+ "items": [
381
+ "accessories[].commandOpen",
382
+ "accessories[].commandClose"
383
+ ]
304
384
  }
305
385
  ]
306
386
  }
@@ -13,14 +13,15 @@ export declare abstract class DummyAccessory<C extends DummyConfig> {
13
13
  private readonly timer;
14
14
  constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, persistPath: string, isGrouped: boolean);
15
15
  protected abstract getAccessoryType(): AccessoryType;
16
+ protected abstract trigger(): Promise<void>;
17
+ protected abstract reset(): Promise<void>;
16
18
  get subtype(): string | undefined;
17
19
  teardown(): void;
18
20
  protected get identifier(): string;
19
21
  protected get isStateful(): boolean;
20
22
  protected get defaultStateStorageKey(): string;
21
- protected startTimer(callback: () => Promise<void>): void;
23
+ protected startTimer(): void;
22
24
  protected cancelTimer(): void;
23
25
  protected executeCommand(command: string): void;
24
- protected assert(...keys: (keyof C)[]): boolean;
25
26
  protected logIfDesired(message: string, ...parameters: string[]): void;
26
27
  }
@@ -3,8 +3,8 @@ import { PLATFORM_NAME, PLUGIN_ALIAS } from '../homebridge/settings.js';
3
3
  import { strings } from '../i18n/i18n.js';
4
4
  import { STORAGE_KEY_SUFFIX_DEFAULT_STATE } from '../tools/storage.js';
5
5
  import { Timer } from '../model/timer.js';
6
- import { assert } from '../tools/validation.js';
7
6
  import getVersion from '../tools/version.js';
7
+ import { Trigger } from '../model/trigger.js';
8
8
  export class DummyAccessory {
9
9
  Service;
10
10
  Characteristic;
@@ -16,7 +16,7 @@ export class DummyAccessory {
16
16
  return config.id ?? `${PLATFORM_NAME}:${config.type}:${config.name.replace(/\s+/g, '')}`;
17
17
  }
18
18
  accessoryService;
19
- timer;
19
+ timer = undefined;
20
20
  constructor(Service, Characteristic, accessory, config, log, persistPath, isGrouped) {
21
21
  this.Service = Service;
22
22
  this.Characteristic = Characteristic;
@@ -24,7 +24,12 @@ export class DummyAccessory {
24
24
  this.config = config;
25
25
  this.log = log;
26
26
  this.persistPath = persistPath;
27
- this.timer = new Timer(config.name, config.disableLogging ? undefined : log);
27
+ if (config.timer) {
28
+ this.timer = Timer.new(config.timer, config.name, log, config.disableLogging === true);
29
+ }
30
+ if (config.trigger) {
31
+ new Trigger(config.trigger, config.name, log, config.disableLogging === true, this.trigger.bind(this));
32
+ }
28
33
  const serviceInstance = Service[this.getAccessoryType()];
29
34
  if (isGrouped) {
30
35
  let accessoryService = accessory.getServiceById(serviceInstance, this.identifier);
@@ -48,7 +53,7 @@ export class DummyAccessory {
48
53
  return this.accessoryService.subtype;
49
54
  }
50
55
  teardown() {
51
- this.timer.teardown();
56
+ this.timer?.teardown();
52
57
  }
53
58
  get identifier() {
54
59
  return DummyAccessory.identifier(this.config);
@@ -59,17 +64,11 @@ export class DummyAccessory {
59
64
  get defaultStateStorageKey() {
60
65
  return `${this.identifier}:${STORAGE_KEY_SUFFIX_DEFAULT_STATE}`;
61
66
  }
62
- startTimer(callback) {
63
- if (!this.config.timer?.delay) {
64
- return;
65
- }
66
- if (!assert(this.log, this.config.name, this.config.timer, 'units')) {
67
- return;
68
- }
69
- this.timer.start(this.config.timer, callback);
67
+ startTimer() {
68
+ this.timer?.start(this.reset.bind(this));
70
69
  }
71
70
  cancelTimer() {
72
- this.timer.cancel();
71
+ this.timer?.cancel();
73
72
  }
74
73
  executeCommand(command) {
75
74
  exec(command, (_error, stdout, stderr) => {
@@ -81,9 +80,6 @@ export class DummyAccessory {
81
80
  }
82
81
  });
83
82
  }
84
- assert(...keys) {
85
- return assert(this.log, this.config.name, this.config, ...keys);
86
- }
87
83
  logIfDesired(message, ...parameters) {
88
84
  if (this.config.disableLogging) {
89
85
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/accessory/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK1C,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAgB,cAAc;IAWb;IACA;IACA;IACA;IACA;IACA;IAdd,MAAM,CAAC,UAAU,CAAC,MAAmB;QAC1C,OAAO,MAAM,CAAC,EAAE,IAAI,GAAG,aAAa,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAC,EAAE,CAAC,EAAE,CAAC;IAC1F,CAAC;IAEkB,gBAAgB,CAAU;IAE5B,KAAK,CAAQ;IAE9B,YACqB,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAS,EACT,GAAQ,EACR,WAAmB,EACtC,SAAkB;QANC,YAAO,GAAP,OAAO,CAAa;QACpB,mBAAc,GAAd,cAAc,CAAoB;QAClC,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAG;QACT,QAAG,GAAH,GAAG,CAAK;QACR,gBAAW,GAAX,WAAW,CAAQ;QAItC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,IAA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AAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAES,WAAW;QACnB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IACvB,CAAC;IAES,cAAc,CAAC,OAAe;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACvC,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAClG,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACxG,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAES,YAAY,CAAC,OAAe,EAAE,GAAG,UAAoB;QAE7D,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -10,6 +10,7 @@ export declare class LockAccessory extends DummyAccessory<LockConfig> {
10
10
  private get defaultLockState();
11
11
  protected getState(): Promise<CharacteristicValue>;
12
12
  protected setState(value: CharacteristicValue): Promise<void>;
13
- private flip;
13
+ trigger(): Promise<void>;
14
+ reset(): Promise<void>;
14
15
  protected logLockState(value: CharacteristicValue): void;
15
16
  }
@@ -47,7 +47,7 @@ export class LockAccessory extends DummyAccessory {
47
47
  }
48
48
  else {
49
49
  if (this.state !== this.defaultLockState) {
50
- this.startTimer(this.flip.bind(this));
50
+ this.startTimer();
51
51
  }
52
52
  else {
53
53
  this.cancelTimer();
@@ -56,10 +56,17 @@ export class LockAccessory extends DummyAccessory {
56
56
  this.accessoryService.updateCharacteristic(this.Characteristic.LockTargetState, this.state);
57
57
  this.accessoryService.updateCharacteristic(this.Characteristic.LockCurrentState, this.state);
58
58
  }
59
- async flip() {
60
- const opposite = this.state === this.Characteristic.LockTargetState.SECURED ?
61
- this.Characteristic.LockTargetState.UNSECURED : this.Characteristic.LockTargetState.SECURED;
62
- await this.setState(opposite);
59
+ async trigger() {
60
+ if (this.state === this.defaultLockState) {
61
+ const opposite = this.state === this.Characteristic.LockTargetState.SECURED ?
62
+ this.Characteristic.LockTargetState.UNSECURED : this.Characteristic.LockTargetState.SECURED;
63
+ await this.setState(opposite);
64
+ }
65
+ }
66
+ async reset() {
67
+ if (this.state !== this.defaultLockState) {
68
+ await this.setState(this.defaultLockState);
69
+ }
63
70
  }
64
71
  logLockState(value) {
65
72
  const message = value === this.Characteristic.LockTargetState.SECURED ?
@@ -1 +1 @@
1
- {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/accessory/lock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAsB,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAGjH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,OAAO,aAAc,SAAQ,cAA0B;IAEnD,KAAK,CAAsB;IAEnC,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAkB,EAClB,GAAQ,EACR,WAAmB,EACnB,SAAkB;QAElB,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAA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QAC5F,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/F,CAAC;IAEQ,KAAK,CAAC,OAAO;QACpB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;gBAC3E,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;YAC9F,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAEQ,KAAK,CAAC,KAAK;QAClB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAES,YAAY,CAAC,KAA0B;QAC/C,MAAM,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YACrE,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;QACpE,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -10,6 +10,7 @@ export declare abstract class OnOffAccessory<C extends OnOffConfig = OnOffConfig
10
10
  private get defaultOn();
11
11
  protected getOn(): Promise<CharacteristicValue>;
12
12
  protected setOn(value: CharacteristicValue): Promise<void>;
13
- private flip;
13
+ trigger(): Promise<void>;
14
+ reset(): Promise<void>;
14
15
  protected logOnState(value: CharacteristicValue): void;
15
16
  }
@@ -42,7 +42,7 @@ export class OnOffAccessory extends DummyAccessory {
42
42
  }
43
43
  else {
44
44
  if (this.on !== this.defaultOn) {
45
- this.startTimer(this.flip.bind(this));
45
+ this.startTimer();
46
46
  }
47
47
  else {
48
48
  this.cancelTimer();
@@ -53,8 +53,15 @@ export class OnOffAccessory extends DummyAccessory {
53
53
  }
54
54
  this.accessoryService.updateCharacteristic(this.Characteristic.On, this.on);
55
55
  }
56
- async flip() {
57
- await this.setOn(!this.on);
56
+ async trigger() {
57
+ if (this.on === this.defaultOn) {
58
+ await this.setOn(!this.on);
59
+ }
60
+ }
61
+ async reset() {
62
+ if (this.on !== this.defaultOn) {
63
+ await this.setOn(this.defaultOn);
64
+ }
58
65
  }
59
66
  logOnState(value) {
60
67
  this.logIfDesired(value ? strings.accessory.onOff.stateOn : strings.accessory.onOff.stateOff, this.config.name);