homebridge-dummy 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (58) hide show
  1. package/CHANGELOG.md +6 -3
  2. package/README.md +32 -6
  3. package/config.schema.json +86 -6
  4. package/dist/accessory/base.d.ts +1 -0
  5. package/dist/accessory/base.js +14 -2
  6. package/dist/accessory/base.js.map +1 -1
  7. package/dist/accessory/helpers.js +12 -3
  8. package/dist/accessory/helpers.js.map +1 -1
  9. package/dist/accessory/lock.d.ts +1 -1
  10. package/dist/accessory/lock.js +8 -2
  11. package/dist/accessory/lock.js.map +1 -1
  12. package/dist/accessory/{lightbulb.d.ts → onoff/lightbulb.d.ts} +2 -2
  13. package/dist/accessory/{lightbulb.js → onoff/lightbulb.js} +3 -3
  14. package/dist/accessory/onoff/lightbulb.js.map +1 -0
  15. package/dist/accessory/{onoff.d.ts → onoff/onoff.d.ts} +3 -3
  16. package/dist/accessory/{onoff.js → onoff/onoff.js} +10 -4
  17. package/dist/accessory/onoff/onoff.js.map +1 -0
  18. package/dist/accessory/{outlet.d.ts → onoff/outlet.d.ts} +1 -1
  19. package/dist/accessory/{outlet.js → onoff/outlet.js} +1 -1
  20. package/dist/accessory/onoff/outlet.js.map +1 -0
  21. package/dist/accessory/{switch.d.ts → onoff/switch.d.ts} +1 -1
  22. package/dist/accessory/{switch.js → onoff/switch.js} +1 -1
  23. package/dist/accessory/onoff/switch.js.map +1 -0
  24. package/dist/accessory/position/blind.d.ts +5 -0
  25. package/dist/accessory/position/blind.js +8 -0
  26. package/dist/accessory/position/blind.js.map +1 -0
  27. package/dist/accessory/position/door.d.ts +5 -0
  28. package/dist/accessory/position/door.js +8 -0
  29. package/dist/accessory/position/door.js.map +1 -0
  30. package/dist/accessory/position/position.d.ts +15 -0
  31. package/dist/accessory/position/position.js +71 -0
  32. package/dist/accessory/position/position.js.map +1 -0
  33. package/dist/accessory/position/window.d.ts +5 -0
  34. package/dist/accessory/position/window.js +8 -0
  35. package/dist/accessory/position/window.js.map +1 -0
  36. package/dist/accessory/sensor.js +0 -1
  37. package/dist/accessory/sensor.js.map +1 -1
  38. package/dist/homebridge/platform.d.ts +4 -3
  39. package/dist/homebridge/platform.js +2 -2
  40. package/dist/homebridge/platform.js.map +1 -1
  41. package/dist/homebridge-ui/public/index.html +1 -1
  42. package/dist/homebridge-ui/public/ui.js +1 -1
  43. package/dist/i18n/en.d.ts +22 -0
  44. package/dist/i18n/en.js +22 -0
  45. package/dist/i18n/en.js.map +1 -1
  46. package/dist/i18n/i18n.d.ts +22 -0
  47. package/dist/i18n/template.d.ts +22 -0
  48. package/dist/i18n/zz.d.ts +22 -0
  49. package/dist/model/types.d.ts +17 -15
  50. package/dist/model/types.js +3 -0
  51. package/dist/model/types.js.map +1 -1
  52. package/dist/tools/configMigration.js +1 -1
  53. package/dist/tools/configMigration.js.map +1 -1
  54. package/package.json +1 -1
  55. package/dist/accessory/lightbulb.js.map +0 -1
  56. package/dist/accessory/onoff.js.map +0 -1
  57. package/dist/accessory/outlet.js.map +0 -1
  58. package/dist/accessory/switch.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ### ‼️ BREAKING v1.0 is a complete code rewrite and automations using Homebridge Dummy accessories will need to be reconfigured.
1
+ ### ‼️ BREAKING CHANGES ‼️
2
+
3
+ ### v1.0 is a complete code rewrite and automations using Homebridge Dummy accessories will need to be reconfigured.
2
4
 
3
5
  ### Full details [here](https://github.com/mpatfield/homebridge-dummy?tab=readme-ov-file#v10-migration).
4
6
 
@@ -10,13 +12,14 @@ All notable changes to homebridge-dummy will be documented in this file.
10
12
 
11
13
  Please report any issues you encounter here: https://github.com/mpatfield/homebridge-dummy/issues
12
14
 
13
- ## 1.0.0-alpha.5 (2025-07-03)
15
+ ## 1.0.0-alpha.8 (2025-07-03)
14
16
 
15
17
  ### Added
16
18
  - Drastically improved config UI
17
19
  - resetOnRestart option for stateful accessories to return to defaults on Homebridge restart
18
- - Support for Outlet and Lock Mechanism
20
+ - Support for Door, Outlet, and Lock Mechanism, Window, and Window Covering
19
21
  - Sensor support (CO2, CO, Contact, Leak, Motion, Occupancy, and Smoke)
22
+ - Execute arbitraty commands when accessory state changes
20
23
 
21
24
  ### Changed
22
25
  - 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)
package/README.md CHANGED
@@ -84,16 +84,21 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
84
84
  {
85
85
  "id": "string",
86
86
  "name": "string",
87
- "type": "Lightbulb | LockMechanism | Outlet | Switch",
87
+ "type": "Door | Lightbulb | LockMechanism | Outlet | Switch | Window | WindoCovering",
88
88
  "timer": {
89
89
  "delay": number,
90
90
  "units": "SECONDS | MINUTES | HOURS",
91
91
  "random": true | false
92
92
  },
93
+ "sensor": "CarbonDioxideSensor | CarbonMonoxideSensor | ContactSensor | LeakSensor | MotionSensor | OccupancySensor | SmokeSensor",
93
94
  "defaultOnOff": 1 | 0,
94
95
  "defaultBrightness": 0-100,
95
96
  "defaultLockState": 0 | 1,
96
- "sensor": "CarbonDioxideSensor | CarbonMonoxideSensor | ContactSensor | LeakSensor | MotionSensor | OccupancySensor | SmokeSensor",
97
+ "defaultPosition": 0 | 100,
98
+ "onCommand": "string",
99
+ "offCommand": "string",
100
+ "lockCommand": "string",
101
+ "unlockCommand": "string",
97
102
  "resetOnRestart": true | false,
98
103
  "disableLogging": true | false
99
104
  }
@@ -108,21 +113,29 @@ All fields are optional unless noted with an asterisk (*)
108
113
  - `id`* - A unique identifier for the accessory. Changing this value will create a new accessory.
109
114
 
110
115
  - `name`* - The display name for the accessory in HomeKit
111
- - `type`* - The type of accessory, currently `Lightbulb`, `LockMechanism`, `Outlet`, and `Switch` are supported
116
+ - `type`* - The type of accessory: `Door`, `Lightbulb`, `LockMechanism`, `Outlet`, `Switch`, `Window`, or `WindowCovering`
112
117
 
113
118
  - `timer.delay` — If defined, the switch will automatically toggle after this many seconds/minutes/hours
114
119
  - `timer.units` — The units to use for delay above (`SECONDS`, `MINUTES`, or `HOURS`). *Required if delay is set.
115
120
  - `timer.random` — If true, the delay will be randomized with a maximum value of `timer.delay`
116
121
 
122
+ - `sensor` - Optionally attach a sensor that mirrors the state of the parent accessory
123
+ - Only works with `Lightbulb`, `Outlet`, and `Switch`
124
+ - Valid values are `CarbonDioxideSensor`, `CarbonMonoxideSensor`, `ContactSensor`, `LeakSensor`, `MotionSensor`, `OccupancySensor`, or `SmokeSensor`
125
+
117
126
  - `defaultOnOff` — Initial value. Default _ON_ = 1, default _OFF_ = 0
118
127
 
119
128
  - `defaultBrightness` — If set, lightbulb will have additional dimmer settings with this default brightness percentage
120
129
 
121
130
  - `defaultLockState` - The initial value for the lock. UNSECURED (Unlocked) = 0, SECURED (Locked) = 1
122
131
 
123
- - `sensor` - Optionally attach a sensor that mirrors the state of the parent accessory
124
- - Only works with `Lightbulb`, `Outlet`, and `Switch`
125
- - Valid values are `CarbonDioxideSensor`, `CarbonMonoxideSensor`, `ContactSensor`, `LeakSensor`, `MotionSensor`, `OccupancySensor`, or `SmokeSensor`
132
+ - `defaultPosition` Initial position for the door/window/blinds, closed = 0, open = 100
133
+
134
+ - `onCommand` - Arbitraty command to execute when lightbulb/outlet/switch turns on
135
+ - `offCommand` - Arbitraty command to execute when lightbulb/outlet/switch turns off
136
+
137
+ - `lockCommand` - Arbitraty command to execute when lock mechanism is locked
138
+ - `unlockCommand` - Arbitraty command to execute when lock mechanism is unlocked
126
139
 
127
140
  - `resetOnRestart` _ If true, all values return to defaults when Homebridge restarts. Ignored when timer is defined.
128
141
 
@@ -223,6 +236,19 @@ All fields are optional unless noted with an asterisk (*)
223
236
  }
224
237
  ```
225
238
 
239
+ ### Door
240
+ ```json
241
+ {
242
+ "name": "Door",
243
+ "type": "Door",
244
+ "timer": {
245
+ "delay": 20,
246
+ "units": "SECONDS"
247
+ },
248
+ "defaultPosition": 0
249
+ }
250
+ ```
251
+
226
252
  ## Credits
227
253
 
228
254
  Special thanks to [@nfarina](https://github.com/nfarina) for creating the original version of this plugin and maintaining it for almost 10 (!!!) years
@@ -50,10 +50,16 @@
50
50
  "type": {
51
51
  "type": "string",
52
52
  "title": "${config.title.type}",
53
- "enum": ["Lightbulb", "LockMechanism", "Outlet", "Switch"],
54
- "enumNames": ["${config.enumNames.lightbulb}", "${config.enumNames.lockMechanism}", "${config.enumNames.outlet}", "${config.enumNames.switch}"]
53
+ "enum": ["Door", "Lightbulb", "LockMechanism", "Outlet", "Switch", "Window", "WindowCovering"],
54
+ "enumNames": ["${config.enumNames.door}", "${config.enumNames.lightbulb}", "${config.enumNames.lockMechanism}", "${config.enumNames.outlet}", "${config.enumNames.switch}", "${config.enumNames.window}", "${config.enumNames.windowCovering}"]
55
55
  },
56
56
  "timer": { "$ref": "#/definitions/timer" },
57
+ "sensor": {
58
+ "type": "string",
59
+ "title": "${config.title.sensor}",
60
+ "enum": ["CarbonDioxideSensor", "CarbonMonoxideSensor", "ContactSensor", "LeakSensor", "MotionSensor", "OccupancySensor", "SmokeSensor"],
61
+ "enumNames": ["${config.enumNames.carbonDioxideSensor}", "${config.enumNames.carbonMonoxideSensor}", "${config.enumNames.contactSensor}", "${config.enumNames.leakSensor}", "${config.enumNames.motionSensor}", "${config.enumNames.occupancySensor}", "${config.enumNames.smokeSensor}"]
62
+ },
57
63
  "defaultBrightness": {
58
64
  "type": "number",
59
65
  "minimum": 0,
@@ -72,11 +78,35 @@
72
78
  "enum": [1, 0],
73
79
  "enumNames": ["${config.enumNames.secured}", "${config.enumNames.unsecured}"]
74
80
  },
75
- "sensor": {
81
+ "defaultPosition": {
82
+ "type": "number",
83
+ "title": "${config.title.defaultPosition}",
84
+ "enum": [100, 0],
85
+ "enumNames": ["${config.enumNames.open}", "${config.enumNames.closed}"]
86
+ },
87
+ "commandOn": {
76
88
  "type": "string",
77
- "title": "${config.title.sensor}",
78
- "enum": ["CarbonDioxideSensor", "CarbonMonoxideSensor", "ContactSensor", "LeakSensor", "MotionSensor", "OccupancySensor", "SmokeSensor"],
79
- "enumNames": ["${config.enumNames.carbonDioxideSensor}", "${config.enumNames.carbonMonoxideSensor}", "${config.enumNames.contactSensor}", "${config.enumNames.leakSensor}", "${config.enumNames.motionSensor}", "${config.enumNames.occupancySensor}", "${config.enumNames.smokeSensor}"]
89
+ "title": "${config.title.commandOn}"
90
+ },
91
+ "commandOff": {
92
+ "type": "string",
93
+ "title": "${config.title.commandOff}"
94
+ },
95
+ "commandLock": {
96
+ "type": "string",
97
+ "title": "${config.title.commandLock}"
98
+ },
99
+ "commandUnlock": {
100
+ "type": "string",
101
+ "title": "${config.title.commandUnlock}"
102
+ },
103
+ "commandOpen": {
104
+ "type": "string",
105
+ "title": "${config.title.commandOpen}"
106
+ },
107
+ "commandClose": {
108
+ "type": "string",
109
+ "title": "${config.title.commandClose}"
80
110
  },
81
111
  "resetOnRestart": {
82
112
  "type": "boolean",
@@ -148,6 +178,42 @@
148
178
  }
149
179
  ]
150
180
  },
181
+ {
182
+ "type": "fieldset",
183
+ "title": "${config.title.commands}",
184
+ "description": "${config.description.commands}",
185
+ "condition": {
186
+ "functionBody": "return ['Lightbulb','Outlet','Switch'].includes(model.accessories?.[arguments[1]]?.type);"
187
+ },
188
+ "items": [
189
+ "accessories[].commandOn",
190
+ "accessories[].commandOff"
191
+ ]
192
+ },
193
+ {
194
+ "type": "fieldset",
195
+ "title": "${config.title.commands}",
196
+ "description": "${config.description.commands}",
197
+ "condition": {
198
+ "functionBody": "return ['LockMechanism'].includes(model.accessories?.[arguments[1]]?.type);"
199
+ },
200
+ "items": [
201
+ "accessories[].commandLock",
202
+ "accessories[].commandUnlock"
203
+ ]
204
+ },
205
+ {
206
+ "type": "fieldset",
207
+ "title": "${config.title.commands}",
208
+ "description": "${config.description.commands}",
209
+ "condition": {
210
+ "functionBody": "return ['Door', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
211
+ },
212
+ "items": [
213
+ "accessories[].commandOpen",
214
+ "accessories[].commandClose"
215
+ ]
216
+ },
151
217
  {
152
218
  "type": "fieldset",
153
219
  "title": "${config.title.options}",
@@ -193,6 +259,20 @@
193
259
  "flex": "0 0 25%"
194
260
  }
195
261
  ]
262
+ },
263
+ {
264
+ "type": "div",
265
+ "displayFlex": true,
266
+ "flex-direction": "row",
267
+ "condition": {
268
+ "functionBody": "return ['Door', 'Window', 'WindowCovering'].includes(model.accessories?.[arguments[1]]?.type);"
269
+ },
270
+ "items": [
271
+ {
272
+ "key": "accessories[].defaultPosition",
273
+ "flex": "0 0 25%"
274
+ }
275
+ ]
196
276
  },
197
277
  {
198
278
  "type": "div",
@@ -19,6 +19,7 @@ export declare abstract class DummyAccessory<C extends DummyConfig> {
19
19
  protected get defaultStateStorageKey(): string;
20
20
  protected startTimer(callback: () => Promise<void>): void;
21
21
  protected cancelTimer(): void;
22
+ protected executeCommand(command: string): void;
22
23
  protected assert(...keys: (keyof C)[]): boolean;
23
24
  protected logIfDesired(message: string, ...parameters: string[]): void;
24
25
  }
@@ -1,8 +1,10 @@
1
+ import { exec } from 'child_process';
1
2
  import { PLATFORM_NAME, PLUGIN_ALIAS } from '../homebridge/settings.js';
2
- import getVersion from '../tools/version.js';
3
+ import { strings } from '../i18n/i18n.js';
4
+ import { STORAGE_KEY_SUFFIX_DEFAULT_STATE } from '../tools/storage.js';
3
5
  import { Timer } from '../model/timer.js';
4
6
  import { assert } from '../tools/validation.js';
5
- import { STORAGE_KEY_SUFFIX_DEFAULT_STATE } from '../tools/storage.js';
7
+ import getVersion from '../tools/version.js';
6
8
  export class DummyAccessory {
7
9
  Service;
8
10
  Characteristic;
@@ -63,6 +65,16 @@ export class DummyAccessory {
63
65
  cancelTimer() {
64
66
  this.timer.cancel();
65
67
  }
68
+ executeCommand(command) {
69
+ exec(command, (_error, stdout, stderr) => {
70
+ if (stderr) {
71
+ this.log.error(`${strings.accessory.command.error}: %s\n%s`, this.config.name, command, stderr);
72
+ }
73
+ else {
74
+ this.logIfDesired(`${strings.accessory.command.executed}: %s\n%s`, this.config.name, command, stdout);
75
+ }
76
+ });
77
+ }
66
78
  assert(...keys) {
67
79
  return assert(this.log, this.config.name, this.config, ...keys);
68
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/accessory/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKxE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAEvE,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,IAAI,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC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2
+ import { DoorAccessory } from './position/door.js';
3
+ import { LightbulbAccessory } from './onoff/lightbulb.js';
2
4
  import { LockAccessory } from './lock.js';
3
- import { OutletAccessory } from './outlet.js';
4
- import { SwitchAccessory } from './switch.js';
5
+ import { OutletAccessory } from './onoff/outlet.js';
6
+ import { SwitchAccessory } from './onoff/switch.js';
7
+ import { WindowAccessory } from './position/window.js';
5
8
  import { strings } from '../i18n/i18n.js';
6
9
  import * as Types from '../model/types.js';
7
10
  export function createAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped = false) {
8
11
  switch (config.type) {
12
+ case Types.AccessoryType.Door:
13
+ return new DoorAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
9
14
  case Types.AccessoryType.Lightbulb:
10
15
  return new LightbulbAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
11
16
  case Types.AccessoryType.LockMechanism:
@@ -14,6 +19,10 @@ export function createAccessory(Service, Characteristic, accessory, config, log,
14
19
  return new OutletAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
15
20
  case Types.AccessoryType.Switch:
16
21
  return new SwitchAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
22
+ case Types.AccessoryType.Window:
23
+ return new WindowAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
24
+ case Types.AccessoryType.WindowCovering:
25
+ return new BlindAccessory(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
17
26
  default:
18
27
  log.error(strings.startup.unsupportedType, `'${config.type}'`);
19
28
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/accessory/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;A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aAAa,CAAC,MAAM;YAC7B,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACtG,KAAK,KAAK,CAAC,aAAa,CAAC,MAAM;YAC7B,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACtG,KAAK,KAAK,CAAC,aAAa,CAAC,cAAc;YACrC,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QACrG;YACE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -11,5 +11,5 @@ export declare class LockAccessory extends DummyAccessory<LockConfig> {
11
11
  protected getState(): Promise<CharacteristicValue>;
12
12
  protected setState(value: CharacteristicValue): Promise<void>;
13
13
  private flip;
14
- protected logLockStateState(value: CharacteristicValue): void;
14
+ protected logLockState(value: CharacteristicValue): void;
15
15
  }
@@ -32,7 +32,13 @@ export class LockAccessory extends DummyAccessory {
32
32
  }
33
33
  async setState(value) {
34
34
  if (this.state !== value) {
35
- this.logLockStateState(value);
35
+ this.logLockState(value);
36
+ if (this.config.commandLock && value === this.Characteristic.LockTargetState.SECURED) {
37
+ this.executeCommand(this.config.commandLock);
38
+ }
39
+ else if (this.config.commandUnlock && value === this.Characteristic.LockTargetState.UNSECURED) {
40
+ this.executeCommand(this.config.commandUnlock);
41
+ }
36
42
  }
37
43
  this.state = value;
38
44
  if (this.isStateful) {
@@ -54,7 +60,7 @@ export class LockAccessory extends DummyAccessory {
54
60
  this.Characteristic.LockTargetState.UNSECURED : this.Characteristic.LockTargetState.SECURED;
55
61
  await this.setState(opposite);
56
62
  }
57
- logLockStateState(value) {
63
+ logLockState(value) {
58
64
  const message = value === this.Characteristic.LockTargetState.SECURED ?
59
65
  strings.accessory.lock.secured : strings.accessory.lock.unsecured;
60
66
  this.logIfDesired(message, this.config.name);
@@ -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,EAA+C,MAAM,mBAAmB,CAAC;AAG/F,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,SAAS,CAAC,CAAC;QAE/E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;QAE/B,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,cAAc,CAAC,eAAe,CAAC;aACpE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC/B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,cAAc,CAAC,gBAAgB,CAAC;aACrE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEnC,IAAI,CAAC,eAAe,EAAE,CA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AK,IAAI,CAAC,YAAY,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5F,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/F,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YAC3E,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;QAC9F,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC,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"}
@@ -1,7 +1,7 @@
1
1
  import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
2
  import { OnOffAccessory } from './onoff.js';
3
- import { AccessoryType, CharacteristicType, LightbulbConfig, ServiceType } from '../model/types.js';
4
- import { Log } from '../tools/log.js';
3
+ import { AccessoryType, CharacteristicType, LightbulbConfig, ServiceType } from '../../model/types.js';
4
+ import { Log } from '../../tools/log.js';
5
5
  export declare class LightbulbAccessory extends OnOffAccessory<LightbulbConfig> {
6
6
  private brightness;
7
7
  constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LightbulbConfig, log: Log, persistPath: string, isGrouped: boolean);
@@ -1,7 +1,7 @@
1
1
  import { OnOffAccessory } from './onoff.js';
2
- import { strings } from '../i18n/i18n.js';
3
- import { AccessoryType } from '../model/types.js';
4
- import { STORAGE_KEY_SUFFIX_DEFAULT_BRIGHTNESS, storageGet, storageSet } from '../tools/storage.js';
2
+ import { strings } from '../../i18n/i18n.js';
3
+ import { AccessoryType } from '../../model/types.js';
4
+ import { STORAGE_KEY_SUFFIX_DEFAULT_BRIGHTNESS, storageGet, storageSet } from '../../tools/storage.js';
5
5
  const NO_BRIGHTNESS = -1;
6
6
  export class LightbulbAccessory extends OnOffAccessory {
7
7
  brightness;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightbulb.js","sourceRoot":"","sources":["../../../src/accessory/onoff/lightbulb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAoD,MAAM,sBAAsB,CAAC;AAGvG,OAAO,EAAE,qCAAqC,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEvG,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC;AAEzB,MAAM,OAAO,kBAAmB,SAAQ,cAA+B;IAE7D,UAAU,CAAsB;IAExC,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAuB,EACvB,GAAQ,EACR,WAAmB,EACnB,SAAkB;QAElB,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,S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AC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QAC7G,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAA0B;QAEtD,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAExB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEzG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9F,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
- import { DummyAccessory } from './base.js';
3
- import { CharacteristicType, OnOffConfig, ServiceType } from '../model/types.js';
4
- import { Log } from '../tools/log.js';
2
+ import { DummyAccessory } from '../base.js';
3
+ import { CharacteristicType, OnOffConfig, ServiceType } from '../../model/types.js';
4
+ import { Log } from '../../tools/log.js';
5
5
  export declare abstract class OnOffAccessory<C extends OnOffConfig = OnOffConfig> extends DummyAccessory<C> {
6
6
  private on;
7
7
  private sensor?;
@@ -1,7 +1,7 @@
1
- import { DummyAccessory } from './base.js';
2
- import { SensorAccessory } from './sensor.js';
3
- import { strings } from '../i18n/i18n.js';
4
- import { storageGet, storageSet } from '../tools/storage.js';
1
+ import { DummyAccessory } from '../base.js';
2
+ import { SensorAccessory } from '../sensor.js';
3
+ import { strings } from '../../i18n/i18n.js';
4
+ import { storageGet, storageSet } from '../../tools/storage.js';
5
5
  export class OnOffAccessory extends DummyAccessory {
6
6
  on;
7
7
  sensor;
@@ -29,6 +29,12 @@ export class OnOffAccessory extends DummyAccessory {
29
29
  async setOn(value) {
30
30
  if (this.on !== value) {
31
31
  this.logOnState(value);
32
+ if (this.config.commandOn && value) {
33
+ this.executeCommand(this.config.commandOn);
34
+ }
35
+ else if (this.config.commandOff && !value) {
36
+ this.executeCommand(this.config.commandOff);
37
+ }
32
38
  }
33
39
  this.on = value;
34
40
  if (this.isStateful) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onoff.js","sourceRoot":"","sources":["../../../src/accessory/onoff/onoff.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,OAAgB,cAAoD,SAAQ,cAAiB;IAEzF,EAAE,CAAsB;IAExB,MAAM,CAAmB;IAEjC,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAS,EACT,GAAQ,EACR,WAAmB,EACnB,SAAkB;QAElB,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAE/E,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QAE5B,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO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CAAC,IAAI,CAAC,CAAC;IAClH,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { OnOffAccessory } from './onoff.js';
2
- import { OutletConfig, AccessoryType } from '../model/types.js';
2
+ import { OutletConfig, AccessoryType } from '../../model/types.js';
3
3
  export declare class OutletAccessory extends OnOffAccessory<OutletConfig> {
4
4
  protected getAccessoryType(): AccessoryType;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { OnOffAccessory } from './onoff.js';
2
- import { AccessoryType } from '../model/types.js';
2
+ import { AccessoryType } from '../../model/types.js';
3
3
  export class OutletAccessory extends OnOffAccessory {
4
4
  getAccessoryType() {
5
5
  return AccessoryType.Outlet;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlet.js","sourceRoot":"","sources":["../../../src/accessory/onoff/outlet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAgB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,OAAO,eAAgB,SAAQ,cAA4B;IAErD,gBAAgB;QACxB,OAAO,aAAa,CAAC,MAAM,CAAC;IAC9B,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { OnOffAccessory } from './onoff.js';
2
- import { AccessoryType, SwitchConfig } from '../model/types.js';
2
+ import { AccessoryType, SwitchConfig } from '../../model/types.js';
3
3
  export declare class SwitchAccessory extends OnOffAccessory<SwitchConfig> {
4
4
  protected getAccessoryType(): AccessoryType;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { OnOffAccessory } from './onoff.js';
2
- import { AccessoryType } from '../model/types.js';
2
+ import { AccessoryType } from '../../model/types.js';
3
3
  export class SwitchAccessory extends OnOffAccessory {
4
4
  getAccessoryType() {
5
5
  return AccessoryType.Switch;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/accessory/onoff/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AAEnE,MAAM,OAAO,eAAgB,SAAQ,cAA4B;IAErD,gBAAgB;QACxB,OAAO,aAAa,CAAC,MAAM,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import { PositionAccessory } from './position.js';
2
+ import { AccessoryType, BlindConfig } from '../../model/types.js';
3
+ export declare class BlindAccessory extends PositionAccessory<BlindConfig> {
4
+ protected getAccessoryType(): AccessoryType;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { PositionAccessory } from './position.js';
2
+ import { AccessoryType } from '../../model/types.js';
3
+ export class BlindAccessory extends PositionAccessory {
4
+ getAccessoryType() {
5
+ return AccessoryType.WindowCovering;
6
+ }
7
+ }
8
+ //# sourceMappingURL=blind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blind.js","sourceRoot":"","sources":["../../../src/accessory/position/blind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,aAAa,EAAe,MAAM,sBAAsB,CAAC;AAElE,MAAM,OAAO,cAAe,SAAQ,iBAA8B;IAEtD,gBAAgB;QACxB,OAAO,aAAa,CAAC,cAAc,CAAC;IACtC,CAAC;CAEF"}
@@ -0,0 +1,5 @@
1
+ import { PositionAccessory } from './position.js';
2
+ import { AccessoryType, DoorConfig } from '../../model/types.js';
3
+ export declare class DoorAccessory extends PositionAccessory<DoorConfig> {
4
+ protected getAccessoryType(): AccessoryType;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { PositionAccessory } from './position.js';
2
+ import { AccessoryType } from '../../model/types.js';
3
+ export class DoorAccessory extends PositionAccessory {
4
+ getAccessoryType() {
5
+ return AccessoryType.Door;
6
+ }
7
+ }
8
+ //# sourceMappingURL=door.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"door.js","sourceRoot":"","sources":["../../../src/accessory/position/door.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,aAAa,EAAc,MAAM,sBAAsB,CAAC;AAEjE,MAAM,OAAO,aAAc,SAAQ,iBAA6B;IAEpD,gBAAgB;QACxB,OAAO,aAAa,CAAC,IAAI,CAAC;IAC5B,CAAC;CAEF"}
@@ -0,0 +1,15 @@
1
+ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
2
+ import { DummyAccessory } from '../base.js';
3
+ import { CharacteristicType, PositionConfig, ServiceType } from '../../model/types.js';
4
+ import { Log } from '../../tools/log.js';
5
+ export declare abstract class PositionAccessory<C extends PositionConfig = PositionConfig> extends DummyAccessory<PositionConfig> {
6
+ private position;
7
+ constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, persistPath: string, isGrouped: boolean);
8
+ private initializePosition;
9
+ private get defaultPosition();
10
+ protected getState(): Promise<CharacteristicValue>;
11
+ protected getPosition(): Promise<CharacteristicValue>;
12
+ protected setPosition(value: CharacteristicValue): Promise<void>;
13
+ private flip;
14
+ protected logPosition(value: CharacteristicValue): void;
15
+ }
@@ -0,0 +1,71 @@
1
+ import { DummyAccessory } from '../base.js';
2
+ import { strings } from '../../i18n/i18n.js';
3
+ import { storageGet, storageSet } from '../../tools/storage.js';
4
+ const POSITION_OPEN = 100;
5
+ const POSITION_CLOSED = 0;
6
+ export class PositionAccessory extends DummyAccessory {
7
+ position;
8
+ constructor(Service, Characteristic, accessory, config, log, persistPath, isGrouped) {
9
+ super(Service, Characteristic, accessory, config, log, persistPath, isGrouped);
10
+ this.position = this.defaultPosition;
11
+ this.accessoryService.getCharacteristic(Characteristic.PositionState)
12
+ .onGet(this.getState.bind(this));
13
+ this.accessoryService.getCharacteristic(Characteristic.TargetPosition)
14
+ .onGet(this.getPosition.bind(this))
15
+ .onSet(this.setPosition.bind(this));
16
+ this.accessoryService.getCharacteristic(Characteristic.CurrentPosition)
17
+ .onGet(this.getPosition.bind(this));
18
+ this.initializePosition();
19
+ }
20
+ async initializePosition() {
21
+ if (this.isStateful) {
22
+ this.position = await storageGet(this.persistPath, this.defaultStateStorageKey) ?? this.position;
23
+ }
24
+ this.accessoryService.updateCharacteristic(this.Characteristic.TargetPosition, this.position);
25
+ this.accessoryService.updateCharacteristic(this.Characteristic.CurrentPosition, this.position);
26
+ }
27
+ get defaultPosition() {
28
+ return this.config.defaultPosition === undefined ? POSITION_CLOSED : this.config.defaultPosition;
29
+ }
30
+ async getState() {
31
+ return this.Characteristic.PositionState.STOPPED;
32
+ }
33
+ async getPosition() {
34
+ return this.position;
35
+ }
36
+ async setPosition(value) {
37
+ const targetPosition = value === POSITION_CLOSED ? POSITION_CLOSED : POSITION_OPEN;
38
+ if (this.position !== targetPosition) {
39
+ this.logPosition(targetPosition);
40
+ if (this.config.commandOpen && targetPosition !== POSITION_CLOSED) {
41
+ this.executeCommand(this.config.commandOpen);
42
+ }
43
+ else if (this.config.commandClose && targetPosition === POSITION_CLOSED) {
44
+ this.executeCommand(this.config.commandClose);
45
+ }
46
+ }
47
+ this.position = targetPosition;
48
+ if (this.isStateful) {
49
+ await storageSet(this.persistPath, this.defaultStateStorageKey, this.position);
50
+ }
51
+ else {
52
+ if (this.position !== this.defaultPosition) {
53
+ this.startTimer(this.flip.bind(this));
54
+ }
55
+ else {
56
+ this.cancelTimer();
57
+ }
58
+ }
59
+ this.accessoryService.updateCharacteristic(this.Characteristic.TargetPosition, this.position);
60
+ this.accessoryService.updateCharacteristic(this.Characteristic.CurrentPosition, this.position);
61
+ }
62
+ async flip() {
63
+ const opposite = this.position === POSITION_CLOSED ? POSITION_OPEN : POSITION_CLOSED;
64
+ await this.setPosition(opposite);
65
+ }
66
+ logPosition(value) {
67
+ const message = value === POSITION_CLOSED ? strings.accessory.position.closed : strings.accessory.position.open;
68
+ this.logIfDesired(message, this.config.name);
69
+ }
70
+ }
71
+ //# sourceMappingURL=position.js.map