homebridge-dummy 1.3.2 → 1.4.0-beta.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/CHANGELOG.md +12 -1
  2. package/README.md +34 -2
  3. package/config.schema.json +140 -28
  4. package/dist/accessory/base.d.ts +27 -8
  5. package/dist/accessory/base.js +46 -36
  6. package/dist/accessory/base.js.map +1 -1
  7. package/dist/accessory/group.d.ts +9 -1
  8. package/dist/accessory/group.js +14 -9
  9. package/dist/accessory/group.js.map +1 -1
  10. package/dist/accessory/helpers.d.ts +3 -5
  11. package/dist/accessory/helpers.js +12 -12
  12. package/dist/accessory/helpers.js.map +1 -1
  13. package/dist/accessory/lock.d.ts +6 -6
  14. package/dist/accessory/lock.js +14 -8
  15. package/dist/accessory/lock.js.map +1 -1
  16. package/dist/accessory/onoff/lightbulb.d.ts +4 -4
  17. package/dist/accessory/onoff/lightbulb.js +3 -3
  18. package/dist/accessory/onoff/lightbulb.js.map +1 -1
  19. package/dist/accessory/onoff/onoff.d.ts +7 -7
  20. package/dist/accessory/onoff/onoff.js +25 -13
  21. package/dist/accessory/onoff/onoff.js.map +1 -1
  22. package/dist/accessory/position/garage.d.ts +3 -4
  23. package/dist/accessory/position/garage.js +3 -3
  24. package/dist/accessory/position/garage.js.map +1 -1
  25. package/dist/accessory/position/position.d.ts +6 -6
  26. package/dist/accessory/position/position.js +14 -8
  27. package/dist/accessory/position/position.js.map +1 -1
  28. package/dist/accessory/sensor.d.ts +4 -5
  29. package/dist/accessory/sensor.js +14 -15
  30. package/dist/accessory/sensor.js.map +1 -1
  31. package/dist/accessory/thermostat.d.ts +5 -6
  32. package/dist/accessory/thermostat.js +17 -17
  33. package/dist/accessory/thermostat.js.map +1 -1
  34. package/dist/homebridge/platform.d.ts +1 -1
  35. package/dist/homebridge/platform.js +29 -12
  36. package/dist/homebridge/platform.js.map +1 -1
  37. package/dist/homebridge-ui/public/index.html +1 -1
  38. package/dist/homebridge-ui/public/ui.js +1 -1
  39. package/dist/i18n/de.d.ts +20 -0
  40. package/dist/i18n/en.d.ts +20 -0
  41. package/dist/i18n/en.js +20 -0
  42. package/dist/i18n/en.js.map +1 -1
  43. package/dist/i18n/es.d.ts +20 -0
  44. package/dist/i18n/i18n.d.ts +20 -0
  45. package/dist/i18n/ru.d.ts +20 -0
  46. package/dist/i18n/template.d.ts +20 -0
  47. package/dist/model/conditions.d.ts +14 -0
  48. package/dist/model/conditions.js +99 -0
  49. package/dist/model/conditions.js.map +1 -0
  50. package/dist/model/enums.d.ts +15 -4
  51. package/dist/model/enums.js +36 -12
  52. package/dist/model/enums.js.map +1 -1
  53. package/dist/model/types.d.ts +13 -3
  54. package/dist/timeout/limiter.d.ts +2 -2
  55. package/dist/timeout/limiter.js +8 -8
  56. package/dist/timeout/limiter.js.map +1 -1
  57. package/dist/timeout/schedule.d.ts +3 -3
  58. package/dist/timeout/schedule.js +18 -18
  59. package/dist/timeout/schedule.js.map +1 -1
  60. package/dist/timeout/timeout.d.ts +6 -4
  61. package/dist/timeout/timeout.js +12 -7
  62. package/dist/timeout/timeout.js.map +1 -1
  63. package/dist/timeout/timer.d.ts +2 -3
  64. package/dist/timeout/timer.js +7 -9
  65. package/dist/timeout/timer.js.map +1 -1
  66. package/dist/tools/configMigration.js +2 -2
  67. package/dist/tools/configMigration.js.map +1 -1
  68. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to homebridge-dummy will be documented in this file.
4
4
 
5
- ## 1.3.2 (2025-10-24)
5
+ ## 1.4.0-beta.0 (2025-10-24)
6
6
 
7
7
  ### ‼️ WARNING ‼️ — If upgrading from v0.9.2 or earlier, [READ THIS FIRST](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#v10-migration)
8
8
 
@@ -10,6 +10,17 @@ All notable changes to homebridge-dummy will be documented in this file.
10
10
 
11
11
  I plan to remove `Thermostat` as a supported accessory type from a future version. If you use `Thermostat`, please add your use case to [this ticket](https://github.com/mpatfield/homebridge-dummy/issues/207) and I will help you find an alternative.
12
12
 
13
+ ### Added
14
+ - Trigger Conditions ([docs](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#trigger-conditions)) - Trigger an accessory based on the state changes of other Homebridge Dummy accessories
15
+ - ⚠️ Config UI for conditions is highly experimental. Please [open a ticket](https://github.com/mpatfield/homebridge-dummy/issues/new/choose) if you see any unusal behavior.
16
+ - I am curious to know if and how you are using this feature, so please drop a note in the [Discord](https://discord.com/channels/432663330281226270/1406798847279366214) channel
17
+
18
+ ### Changed
19
+ - `defaultOn` has been deprecated in favor of `defaultState` for `Lightbulb`, `Outlet`, and `Switch`
20
+ - This is backwards compatible so no manual edits are necessary
21
+
22
+ ## 1.3.2 (2025-10-24)
23
+
13
24
  ### Added
14
25
  - Support for `GarageDoorOpener`
15
26
  - Русский перевод. Спасибо, [@Silverdragon122](https://github.com/sponsors/Silverdragon122)!
package/README.md CHANGED
@@ -123,8 +123,18 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
123
123
  "units": "MILLISECONDS | SECONDS | MINUTES | HOURS",
124
124
  "period": "HOUR | DAY | WEEK | MONTH",
125
125
  },
126
+ "conditions": {
127
+ "operator": "and | or",
128
+ "operands" [
129
+ {
130
+ "accessoryId": "string",
131
+ "accessoryState": "on | off | open | closed | locked | unlocked",
132
+ }
133
+
134
+ ]
135
+ },
126
136
  "temperatureUnits": "C" | "F",
127
- "defaultOn": true | false,
137
+ "defaultState": "on" | "off",
128
138
  "defaultBrightness": 0-100,
129
139
  "defaultLockState": "locked" | "unlocked",
130
140
  "defaultPosition": "open" | "closed",
@@ -221,9 +231,31 @@ Execute arbitrary commands (e.g. curl) when the accessory changes state
221
231
  - `unlockCommand` - Arbitrary command to execute when lock mechanism is unlocked
222
232
  - `commandTemperature` - Arbitrary command to execute when temperature changes
223
233
 
234
+ ### Trigger Conditions
235
+
236
+ You can trigger an accessory whenever a set of conditions are satisfied, for example, when other Homebridge Dummy accessories turn on.
237
+
238
+ There are two logical operators to trigger the target accessory when ALL ("and") or ANY ("or") of a set of conditions are satisfied. This is set using `operator`.
239
+
240
+ You can have an arbitrarily long list of conditions and they are checked in order.
241
+
242
+ If target accessory is not setup to auto-reset with a timer, then it will immediately return to it's default setting as soon as the conditions are no longer met.
243
+
244
+ Note that due to limitations of HomeKit and Homebridge, it is only possible to check the states of other Homebridge Dummy accessories. One possible workaround is to set up duplicate accessories in Homebridge Dummy and use Automation to mirror the states.
245
+
246
+ For example, if I have a physical door lock I want to "watch", then I can setup a `LockMechanism` accessory in Homebridge Dummy and create two automations to change the state of my dummy lock whenever the physical door lock is unlocked or locked.
247
+
248
+ #### Conditions Object
249
+ - `operator` - "and" to require ALL conditions to be satisfied, and "or" ANY
250
+ - `operands` - A list of accessories to "watch" for state changes to see if conditions are satisfied
251
+
252
+ #### Operand Object
253
+ - `accessoryId` - The id of the accessory to watch for state changes
254
+ - `accessoryState` - The desired accessory state to make this condition "true"
255
+
224
256
  ### Defaults
225
257
  - `temperatureUnits` - Units to use for thermostats, either 'C' or 'F'
226
- - `defaultOn` — Initial value. Default _ON_ = true, default _OFF_ = false
258
+ - `defaultState` — Initial value, either "on" or "off"
227
259
  - `defaultBrightness` — If set, lightbulb will have additional dimmer settings with this default brightness percentage
228
260
  - `defaultLockState` - The initial value for the lock, "locked" or "unlocked"
229
261
  - `defaultPosition` — Initial position for the door/garage/window/blinds, "open" or "closed"
@@ -37,7 +37,10 @@
37
37
  "title": "${config.title.delay}",
38
38
  "minimum": 1
39
39
  },
40
- "units": { "$ref": "#/definitions/units" },
40
+ "units": {
41
+ "$ref": "#/definitions/units",
42
+ "required": true
43
+ },
41
44
  "random": {
42
45
  "type": "boolean",
43
46
  "title": "${config.title.random}",
@@ -158,13 +161,15 @@
158
161
  "type": "string",
159
162
  "title": "${config.title.units}",
160
163
  "enum": [ "SECONDS", "MINUTES", "HOURS"],
161
- "enumNames": ["${config.enumNames.seconds}", "${config.enumNames.minutes}", "${config.enumNames.hours}"]
164
+ "enumNames": ["${config.enumNames.seconds}", "${config.enumNames.minutes}", "${config.enumNames.hours}"],
165
+ "required": true
162
166
  },
163
167
  "period": {
164
168
  "type": "string",
165
169
  "title": "${config.title.period}",
166
170
  "enum": [ "HOUR", "DAY", "WEEK", "MONTH"],
167
- "enumNames": ["${config.enumNames.hour}", "${config.enumNames.day}", "${config.enumNames.week}", "${config.enumNames.month}"]
171
+ "enumNames": ["${config.enumNames.hour}", "${config.enumNames.day}", "${config.enumNames.week}", "${config.enumNames.month}"],
172
+ "required": true
168
173
  }
169
174
  },
170
175
  "allOf": [
@@ -205,6 +210,53 @@
205
210
  }
206
211
  }
207
212
  ]
213
+ },
214
+ "operand": {
215
+ "type": "object",
216
+ "properties": {
217
+ "accessoryId": {
218
+ "type": "string",
219
+ "title": "${config.title.accessory}",
220
+ "required": true
221
+ },
222
+ "accessoryState": {
223
+ "type": "string",
224
+ "title": "${config.title.accessoryState}",
225
+ "enum": [ "on", "off", "open", "closed", "locked", "unlocked" ],
226
+ "enumNames": [ "${config.enumNames.on}", "${config.enumNames.off}", "${config.enumNames.open}", "${config.enumNames.closed}", "${config.enumNames.secured}", "${config.enumNames.unsecured}" ],
227
+ "required": true
228
+ }
229
+ }
230
+ },
231
+ "conditions": {
232
+ "type": "object",
233
+ "properties": {
234
+ "operator": {
235
+ "type": "string",
236
+ "title": "${config.title.operator}",
237
+ "enum": [ "and", "or"],
238
+ "enumNames": ["${config.enumNames.operatorAnd}", "${config.enumNames.operatorOr}"]
239
+ },
240
+ "operands": {
241
+ "type": "array",
242
+ "minItems":1,
243
+ "items": { "$ref": "#/definitions/operand" }
244
+ }
245
+ },
246
+ "allOf": [
247
+ {
248
+ "if": {
249
+ "properties": {
250
+ "operator": {
251
+ }
252
+ },
253
+ "required": ["operator"]
254
+ },
255
+ "then": {
256
+ "required": ["operands"]
257
+ }
258
+ }
259
+ ]
208
260
  }
209
261
  },
210
262
  "properties": {
@@ -239,6 +291,7 @@
239
291
  "timer": { "$ref": "#/definitions/timer" },
240
292
  "schedule": { "$ref": "#/definitions/schedule" },
241
293
  "limiter": { "$ref": "#/definitions/limiter" },
294
+ "conditions": { "$ref": "#/definitions/conditions" },
242
295
  "temperatureUnits": {
243
296
  "type": "string",
244
297
  "title": "${config.title.units}",
@@ -251,10 +304,10 @@
251
304
  "minimum": 0,
252
305
  "maximum": 100
253
306
  },
254
- "defaultOn": {
255
- "type": "number",
307
+ "defaultState": {
308
+ "type": "string",
256
309
  "title": "${config.title.defaultState}",
257
- "enum": [1, 0],
310
+ "enum": ["on", "off"],
258
311
  "enumNames": ["${config.enumNames.on}", "${config.enumNames.off}"]
259
312
  },
260
313
  "defaultLockState": {
@@ -348,15 +401,15 @@
348
401
  "items": [
349
402
  {
350
403
  "key": "accessories[].name",
351
- "flex": "1 1 33%"
404
+ "flex": "0 0 33%"
352
405
  },
353
406
  {
354
407
  "key": "accessories[].type",
355
- "flex": "1 1 33%"
408
+ "flex": "0 0 33%"
356
409
  },
357
410
  {
358
411
  "key": "accessories[].groupName",
359
- "flex": "1 1 33%"
412
+ "flex": "0 0 33%"
360
413
  }
361
414
  ]
362
415
  },
@@ -364,7 +417,7 @@
364
417
  "type": "fieldset",
365
418
  "notitle": true,
366
419
  "condition": {
367
- "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
420
+ "functionBody": "return model.accessories?.[arguments[1]]?.type;"
368
421
  },
369
422
  "items": [
370
423
  {
@@ -376,7 +429,7 @@
376
429
  },
377
430
  "items": [
378
431
  {
379
- "key": "accessories[].defaultOn",
432
+ "key": "accessories[].defaultState",
380
433
  "flex": "0 0 33%"
381
434
  },
382
435
  {
@@ -479,7 +532,7 @@
479
532
  "title": "${config.title.schedule}",
480
533
  "description": "${config.description.schedule}",
481
534
  "condition": {
482
- "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type !== undefined && type !== 'Thermostat';"
535
+ "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && type !== 'Thermostat';"
483
536
  },
484
537
  "items": [
485
538
  {
@@ -489,18 +542,18 @@
489
542
  "items": [
490
543
  {
491
544
  "key": "accessories[].schedule.type",
492
- "flex": "1 1 33%"
545
+ "flex": "0 0 33%"
493
546
  },
494
547
  {
495
548
  "key": "accessories[].schedule.interval",
496
- "flex": "1 1 33%",
549
+ "flex": "0 0 33%",
497
550
  "condition": {
498
551
  "functionBody": "return model.accessories?.[arguments[1]]?.schedule?.type === 'INTERVAL';"
499
552
  }
500
553
  },
501
554
  {
502
555
  "key": "accessories[].schedule.units",
503
- "flex": "1 1 33%",
556
+ "flex": "0 0 33%",
504
557
  "condition": {
505
558
  "functionBody": "return model.accessories?.[arguments[1]]?.schedule?.type === 'INTERVAL';"
506
559
  }
@@ -517,11 +570,11 @@
517
570
  "items": [
518
571
  {
519
572
  "key": "accessories[].schedule.cron",
520
- "flex": "1 1 33%"
573
+ "flex": "0 0 33%"
521
574
  },
522
575
  {
523
576
  "key": "accessories[].schedule.cronCustom",
524
- "flex": "1 1 67%",
577
+ "flex": "0 0 67%",
525
578
  "condition": {
526
579
  "functionBody": "return model.accessories?.[arguments[1]]?.schedule?.cron === 'CRON_CUSTOM';"
527
580
  }
@@ -531,7 +584,7 @@
531
584
  {
532
585
  "key": "accessories[].schedule.random",
533
586
  "condition": {
534
- "functionBody": "const schedule = model.accessories?.[arguments[1]]?.schedule; return schedule?.type === 'INTERVAL' && schedule?.interval !== undefined;"
587
+ "functionBody": "const schedule = model.accessories?.[arguments[1]]?.schedule; return schedule?.type === 'INTERVAL' && schedule?.interval;"
535
588
  }
536
589
  }
537
590
  ]
@@ -541,7 +594,7 @@
541
594
  "title": "${config.title.timer}",
542
595
  "description": "${config.description.timer}",
543
596
  "condition": {
544
- "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type !== undefined && type !== 'Thermostat';"
597
+ "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && type !== 'Thermostat';"
545
598
  },
546
599
  "items": [
547
600
  {
@@ -551,11 +604,14 @@
551
604
  "items": [
552
605
  {
553
606
  "key": "accessories[].timer.delay",
554
- "flex": "1 1 33%"
607
+ "flex": "0 0 33%"
555
608
  },
556
609
  {
557
610
  "key": "accessories[].timer.units",
558
- "flex": "1 1 33%"
611
+ "flex": "0 0 33%",
612
+ "condition": {
613
+ "functionBody": "return model.accessories?.[arguments[1]]?.timer?.delay;"
614
+ }
559
615
  }
560
616
  ]
561
617
  },
@@ -563,14 +619,14 @@
563
619
  "type": "fieldset",
564
620
  "notitle": true,
565
621
  "condition": {
566
- "functionBody": "return model.accessories?.[arguments[1]]?.timer?.delay !== undefined;"
622
+ "functionBody": "return model.accessories?.[arguments[1]]?.timer?.delay;"
567
623
  },
568
624
  "items": [
569
625
  "accessories[].timer.random",
570
626
  {
571
627
  "key": "accessories[].sensor.timerControlled",
572
628
  "condition": {
573
- "functionBody": "return model.accessories?.[arguments[1]]?.sensor?.type !== undefined;"
629
+ "functionBody": "return model.accessories?.[arguments[1]]?.sensor?.type;"
574
630
  }
575
631
  }
576
632
  ]
@@ -582,7 +638,7 @@
582
638
  "title": "${config.title.limiter}",
583
639
  "description": "${config.description.limiter}",
584
640
  "condition": {
585
- "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type !== undefined && type !== 'Thermostat';"
641
+ "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return type && type !== 'Thermostat';"
586
642
  },
587
643
  "items": [
588
644
  {
@@ -592,15 +648,71 @@
592
648
  "items": [
593
649
  {
594
650
  "key": "accessories[].limiter.limit",
595
- "flex": "1 1 33%"
651
+ "flex": "0 0 33%"
596
652
  },
597
653
  {
598
654
  "key": "accessories[].limiter.units",
599
- "flex": "1 1 33%"
655
+ "flex": "0 0 33%",
656
+ "condition": {
657
+ "functionBody": "return model.accessories?.[arguments[1]]?.limiter?.limit;"
658
+ }
600
659
  },
601
660
  {
602
661
  "key": "accessories[].limiter.period",
603
- "flex": "1 1 33%"
662
+ "flex": "0 0 33%",
663
+ "condition": {
664
+ "functionBody": "return model.accessories?.[arguments[1]]?.limiter?.limit;"
665
+ }
666
+ }
667
+ ]
668
+ }
669
+ ]
670
+ },
671
+ {
672
+ "type": "fieldset",
673
+ "title": "${config.title.conditions}",
674
+ "description": "${config.description.conditions}",
675
+ "condition": {
676
+ "functionBody": "const type = model.accessories?.[arguments[1]]?.type; return model.accessories?.length > 1 && type && type !== 'Thermostat'"
677
+ },
678
+ "items": [
679
+ {
680
+ "type": "div",
681
+ "displayFlex": true,
682
+ "flex-direction": "row",
683
+ "items": [
684
+ {
685
+ "key": "accessories[].conditions.operator",
686
+ "flex": "0 0 67%"
687
+ }
688
+ ]
689
+ },
690
+ {
691
+ "type": "array",
692
+ "title": "${config.title.condition}",
693
+ "notitle": true,
694
+ "condition": {
695
+ "functionBody": "return model.accessories?.[arguments[1]]?.conditions?.operator;"
696
+ },
697
+ "key": "accessories[].conditions.operands",
698
+ "items": [
699
+ {
700
+ "type": "div",
701
+ "displayFlex": true,
702
+ "flex-direction": "row",
703
+ "items": [
704
+ {
705
+ "key": "accessories[].conditions.operands[].accessoryId",
706
+ "flex": "0 0 50%"
707
+ },
708
+ {
709
+ "key": "accessories[].conditions.operands[].accessoryState",
710
+ "flex": "0 0 50%",
711
+ "condition": {
712
+ "functionBody": "return model.accessories?.[arguments[1][0]]?.conditions?.operands?.[arguments[1][1]]?.accessoryId;"
713
+ }
714
+ }
715
+ ]
604
716
  }
605
717
  ]
606
718
  }
@@ -611,7 +723,7 @@
611
723
  "title": "${config.title.commands}",
612
724
  "description": "${config.description.commands}",
613
725
  "condition": {
614
- "functionBody": "return model.accessories?.[arguments[1]]?.type !== undefined;"
726
+ "functionBody": "return model.accessories?.[arguments[1]]?.type;"
615
727
  },
616
728
  "items": [
617
729
  {
@@ -1,15 +1,30 @@
1
1
  import { PlatformAccessory, Service } from 'homebridge';
2
2
  import { SensorAccessory } from './sensor.js';
3
- import { AccessoryType } from '../model/enums.js';
3
+ import { ConditionManager } from '../model/conditions.js';
4
+ import { AccessoryState, AccessoryType } from '../model/enums.js';
4
5
  import { CharacteristicType, DummyConfig, ServiceType } from '../model/types.js';
5
6
  import { Webhook } from '../model/webhook.js';
6
7
  import { Log } from '../tools/log.js';
8
+ export type DummyAccessoryDependency<C extends DummyConfig> = {
9
+ Service: ServiceType;
10
+ Characteristic: CharacteristicType;
11
+ platformAccessory: PlatformAccessory;
12
+ config: C;
13
+ conditionManager: ConditionManager;
14
+ log: Log;
15
+ isGrouped: boolean;
16
+ };
17
+ export type DummyAddonDependency = {
18
+ Service: ServiceType;
19
+ Characteristic: CharacteristicType;
20
+ platformAccessory: PlatformAccessory;
21
+ identifier: string;
22
+ caller: string;
23
+ log: Log;
24
+ disableLogging: boolean;
25
+ };
7
26
  export declare abstract class DummyAccessory<C extends DummyConfig> {
8
- protected readonly Service: ServiceType;
9
- protected readonly Characteristic: CharacteristicType;
10
- protected readonly accessory: PlatformAccessory;
11
- protected readonly config: C;
12
- protected readonly log: Log;
27
+ private readonly dependency;
13
28
  protected sensor?: SensorAccessory;
14
29
  static identifier(config: DummyConfig): string;
15
30
  protected readonly accessoryService: Service;
@@ -17,20 +32,24 @@ export declare abstract class DummyAccessory<C extends DummyConfig> {
17
32
  private readonly _timer?;
18
33
  private readonly _limiter?;
19
34
  private readonly execAsync;
20
- constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, isGrouped: boolean);
35
+ constructor(dependency: DummyAccessoryDependency<C>);
21
36
  protected abstract getAccessoryType(): AccessoryType;
22
- protected abstract schedule(): Promise<void>;
37
+ protected abstract trigger(): Promise<void>;
23
38
  protected abstract reset(): Promise<void>;
24
39
  get subtype(): string | undefined;
25
40
  teardown(): void;
26
41
  abstract webhooks(): Webhook[];
42
+ protected get config(): C;
27
43
  protected get identifier(): string;
28
44
  protected get name(): string;
45
+ protected get log(): Log;
46
+ protected get Characteristic(): CharacteristicType;
29
47
  protected get isStateful(): boolean;
30
48
  protected get defaultStateStorageKey(): string;
31
49
  protected startTimer(): void;
32
50
  protected cancelTimer(): void;
33
51
  protected executeCommand(command: string): Promise<void>;
34
52
  private isExecException;
53
+ protected onStateChange(state: AccessoryState): Promise<void>;
35
54
  protected logIfDesired(message: string, ...parameters: (string | number)[]): void;
36
55
  }
@@ -9,11 +9,7 @@ import { Schedule } from '../timeout/schedule.js';
9
9
  import { Timer } from '../timeout/timer.js';
10
10
  import getVersion from '../tools/version.js';
11
11
  export class DummyAccessory {
12
- Service;
13
- Characteristic;
14
- accessory;
15
- config;
16
- log;
12
+ dependency;
17
13
  sensor;
18
14
  static identifier(config) {
19
15
  return config.id ?? `${PLATFORM_NAME}:${config.type}:${config.name.replace(/\s+/g, '')}`;
@@ -23,44 +19,46 @@ export class DummyAccessory {
23
19
  _timer;
24
20
  _limiter;
25
21
  execAsync = promisify(exec);
26
- constructor(Service, Characteristic, accessory, config, log, isGrouped) {
27
- this.Service = Service;
28
- this.Characteristic = Characteristic;
29
- this.accessory = accessory;
30
- this.config = config;
31
- this.log = log;
32
- this.sensor = SensorAccessory.new(Service, Characteristic, accessory, this.name, log, this.config.disableLogging === true, config.sensor);
33
- if (config.timer) {
34
- this._timer = Timer.new(config.timer, this.identifier, config.name, log, config.disableLogging === true);
35
- }
36
- if (config.schedule) {
37
- this._schedule = Schedule.new(config.schedule, config.name, log, config.disableLogging === true, this.schedule.bind(this));
38
- }
39
- if (config.limiter) {
40
- this._limiter = Limiter.new(config.limiter, config.name, log, config.disableLogging === true);
41
- }
42
- const serviceInstance = Service[this.getAccessoryType()];
43
- if (isGrouped) {
44
- let accessoryService = accessory.getServiceById(serviceInstance, this.identifier);
22
+ constructor(dependency) {
23
+ this.dependency = dependency;
24
+ const name = dependency.config.name;
25
+ const disableLogging = dependency.config.disableLogging === true;
26
+ const addonDependency = {
27
+ Service: dependency.Service,
28
+ Characteristic: dependency.Characteristic,
29
+ platformAccessory: dependency.platformAccessory,
30
+ identifier: this.identifier,
31
+ caller: name,
32
+ log: dependency.log,
33
+ disableLogging: disableLogging,
34
+ };
35
+ this.sensor = SensorAccessory.new(addonDependency, dependency.config.sensor);
36
+ this._timer = Timer.new(addonDependency, dependency.config.timer);
37
+ this._schedule = Schedule.new(addonDependency, dependency.config.schedule, this.trigger.bind(this));
38
+ this._limiter = Limiter.new(addonDependency, dependency.config.limiter);
39
+ dependency.conditionManager.register(name, this.identifier, dependency.config.conditions, this.trigger.bind(this), this._timer ? undefined : this.reset.bind(this), disableLogging);
40
+ const serviceInstance = dependency.Service[this.getAccessoryType()];
41
+ if (dependency.isGrouped) {
42
+ let accessoryService = dependency.platformAccessory.getServiceById(serviceInstance, this.identifier);
45
43
  if (!accessoryService) {
46
- accessoryService = accessory.addService(serviceInstance, config.name, this.identifier);
47
- accessoryService.setCharacteristic(Characteristic.ConfiguredName, config.name);
44
+ accessoryService = dependency.platformAccessory.addService(serviceInstance, name, this.identifier);
45
+ accessoryService.setCharacteristic(dependency.Characteristic.ConfiguredName, name);
48
46
  }
49
47
  this.accessoryService = accessoryService;
50
48
  return;
51
49
  }
52
- accessory.getService(Service.AccessoryInformation)
53
- .setCharacteristic(Characteristic.Name, config.name)
54
- .setCharacteristic(Characteristic.ConfiguredName, config.name)
55
- .setCharacteristic(Characteristic.Manufacturer, PLUGIN_ALIAS)
56
- .setCharacteristic(Characteristic.Model, config.type)
57
- .setCharacteristic(Characteristic.SerialNumber, this.identifier)
58
- .setCharacteristic(Characteristic.FirmwareRevision, getVersion());
59
- this.accessoryService = accessory.getService(serviceInstance) || accessory.addService(serviceInstance);
50
+ dependency.platformAccessory.getService(dependency.Service.AccessoryInformation)
51
+ .setCharacteristic(dependency.Characteristic.Name, name)
52
+ .setCharacteristic(dependency.Characteristic.ConfiguredName, name)
53
+ .setCharacteristic(dependency.Characteristic.Manufacturer, PLUGIN_ALIAS)
54
+ .setCharacteristic(dependency.Characteristic.Model, dependency.config.type)
55
+ .setCharacteristic(dependency.Characteristic.SerialNumber, this.identifier)
56
+ .setCharacteristic(dependency.Characteristic.FirmwareRevision, getVersion());
57
+ this.accessoryService = dependency.platformAccessory.getService(serviceInstance) || dependency.platformAccessory.addService(serviceInstance);
60
58
  for (const type of Object.values(AccessoryType)) {
61
- const existingService = accessory.getService(Service[type]);
59
+ const existingService = dependency.platformAccessory.getService(dependency.Service[type]);
62
60
  if (existingService && type !== this.getAccessoryType()) {
63
- accessory.removeService(existingService);
61
+ dependency.platformAccessory.removeService(existingService);
64
62
  }
65
63
  }
66
64
  }
@@ -72,12 +70,21 @@ export class DummyAccessory {
72
70
  this._schedule?.teardown();
73
71
  this._limiter?.teardown();
74
72
  }
73
+ get config() {
74
+ return this.dependency.config;
75
+ }
75
76
  get identifier() {
76
77
  return DummyAccessory.identifier(this.config);
77
78
  }
78
79
  get name() {
79
80
  return this.config.name;
80
81
  }
82
+ get log() {
83
+ return this.dependency.log;
84
+ }
85
+ get Characteristic() {
86
+ return this.dependency.Characteristic;
87
+ }
81
88
  get isStateful() {
82
89
  return this._schedule === undefined && !this.config.resetOnRestart;
83
90
  }
@@ -128,6 +135,9 @@ export class DummyAccessory {
128
135
  'stderr' in err &&
129
136
  typeof err.stderr === 'string';
130
137
  }
138
+ async onStateChange(state) {
139
+ await this.dependency.conditionManager.onStateChange(this.identifier, state);
140
+ }
131
141
  logIfDesired(message, ...parameters) {
132
142
  if (this.config.disableLogging) {
133
143
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/accessory/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,mB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AAC,OAAO,CAAC,QAAQ,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACtH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,GAAY;QAClC,OAAO,GAAG,YAAY,KAAK;YACzB,MAAM,IAAI,GAAG;YACb,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;YAC5B,QAAQ,IAAI,GAAG;YACf,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;YAC9B,QAAQ,IAAI,GAAG;YACf,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC;IACnC,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAAqB;QACjD,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC/E,CAAC;IAES,YAAY,CAAC,OAAe,EAAE,GAAG,UAA+B;QAExE,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC;IACrD,CAAC;CACF"}
@@ -1,10 +1,18 @@
1
1
  import { PlatformAccessory } from 'homebridge';
2
+ import { ConditionManager } from '../model/conditions.js';
2
3
  import { CharacteristicType, GroupConfig, ServiceType } from '../model/types.js';
3
4
  import { WebhookManager } from '../model/webhook.js';
4
5
  import { Log } from '../tools/log.js';
6
+ export type GroupAccessoryDependency = {
7
+ Service: ServiceType;
8
+ Characteristic: CharacteristicType;
9
+ platformAccessory: PlatformAccessory;
10
+ conditionManager: ConditionManager;
11
+ log: Log;
12
+ };
5
13
  export declare class GroupAccessory {
6
14
  static identifier(groupName: string): string;
7
15
  private readonly accessories;
8
- constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: GroupConfig, log: Log, webhookManager: WebhookManager);
16
+ constructor(dependency: GroupAccessoryDependency, config: GroupConfig, webhookManager: WebhookManager);
9
17
  teardown(): void;
10
18
  }