homebridge-dummy 1.1.1-beta.0 → 1.2.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.
- package/CHANGELOG.md +2 -1
- package/README.md +27 -133
- package/config.schema.json +12 -1
- package/dist/accessory/base.d.ts +3 -0
- package/dist/accessory/base.js +7 -4
- package/dist/accessory/base.js.map +1 -1
- package/dist/accessory/group.d.ts +2 -7
- package/dist/accessory/group.js +5 -14
- package/dist/accessory/group.js.map +1 -1
- package/dist/accessory/lock.d.ts +4 -1
- package/dist/accessory/lock.js +14 -4
- package/dist/accessory/lock.js.map +1 -1
- package/dist/accessory/onoff/lightbulb.d.ts +4 -2
- package/dist/accessory/onoff/lightbulb.js +15 -9
- package/dist/accessory/onoff/lightbulb.js.map +1 -1
- package/dist/accessory/onoff/onoff.d.ts +3 -1
- package/dist/accessory/onoff/onoff.js +13 -7
- package/dist/accessory/onoff/onoff.js.map +1 -1
- package/dist/accessory/onoff/outlet.d.ts +1 -1
- package/dist/accessory/onoff/outlet.js.map +1 -1
- package/dist/accessory/onoff/switch.d.ts +1 -1
- package/dist/accessory/onoff/switch.js.map +1 -1
- package/dist/accessory/position/blind.d.ts +1 -1
- package/dist/accessory/position/blind.js.map +1 -1
- package/dist/accessory/position/door.d.ts +1 -1
- package/dist/accessory/position/door.js.map +1 -1
- package/dist/accessory/position/position.d.ts +3 -0
- package/dist/accessory/position/position.js +14 -3
- package/dist/accessory/position/position.js.map +1 -1
- package/dist/accessory/position/window.d.ts +1 -1
- package/dist/accessory/position/window.js.map +1 -1
- package/dist/accessory/thermostat.d.ts +6 -1
- package/dist/accessory/thermostat.js +33 -21
- package/dist/accessory/thermostat.js.map +1 -1
- package/dist/homebridge/platform.d.ts +1 -0
- package/dist/homebridge/platform.js +10 -3
- package/dist/homebridge/platform.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +1 -1
- package/dist/homebridge-ui/public/ui.js +1 -1
- package/dist/i18n/en.d.ts +14 -0
- package/dist/i18n/en.js +19 -5
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/i18n.d.ts +14 -0
- package/dist/i18n/template.d.ts +14 -0
- package/dist/i18n/zz.d.ts +14 -0
- package/dist/model/enums.d.ts +8 -0
- package/dist/model/enums.js +9 -0
- package/dist/model/enums.js.map +1 -1
- package/dist/model/types.d.ts +2 -0
- package/dist/model/webhook.d.ts +27 -0
- package/dist/model/webhook.js +161 -0
- package/dist/model/webhook.js.map +1 -0
- package/dist/tools/log.d.ts +6 -2
- package/dist/tools/log.js +28 -1
- package/dist/tools/log.js.map +1 -1
- package/dist/tools/validation.d.ts +0 -2
- package/dist/tools/validation.js +0 -7
- package/dist/tools/validation.js.map +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to homebridge-dummy will be documented in this file.
|
|
4
4
|
|
|
5
|
-
## 1.
|
|
5
|
+
## 1.2.0-beta.0 (2025-09-24)
|
|
6
6
|
|
|
7
7
|
### ‼️ WARNING — Read this if upgrading from v0.9.2 or earlier…
|
|
8
8
|
|
|
9
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).
|
|
10
10
|
|
|
11
11
|
### Changed
|
|
12
|
+
- Support for webhooks ([documentation](https://github.com/mpatfield/homebridge-dummy#webhooks))
|
|
12
13
|
- Better field validation in config UI (Thank you, [@justjam2013](https://github.com/sponsors/justjam2013) for teaching me this!)
|
|
13
14
|
- `schedule.cron` now expects an `@` preset or `CRON_CUSTOM` with `schedule.cronCustom` defined.
|
|
14
15
|
- This is backwards compatible so no manual edits are necessary
|
package/README.md
CHANGED
|
@@ -119,6 +119,7 @@ Using the Homebridge Config UI is the easiest way to set up this plugin. However
|
|
|
119
119
|
"commandOpen": "string",
|
|
120
120
|
"commandClose": "string",
|
|
121
121
|
"commandTemperature": "string",
|
|
122
|
+
"enableWebook": true | false
|
|
122
123
|
"resetOnRestart": true | false,
|
|
123
124
|
"disableLogging": true | false
|
|
124
125
|
}
|
|
@@ -156,6 +157,8 @@ All fields are optional unless noted with an asterisk (*)
|
|
|
156
157
|
|
|
157
158
|
- `temperatureUnits` - Units to use for thermostats, either 'C' or 'F'
|
|
158
159
|
|
|
160
|
+
- `enableWebook` - Turn on webhooks for this accessory. See [Webhooks](https://github.com/mpatfield/homebridge-dummy#webhooks) section below for details.
|
|
161
|
+
|
|
159
162
|
- `defaultOn` — Initial value. Default _ON_ = true, default _OFF_ = false
|
|
160
163
|
|
|
161
164
|
- `defaultBrightness` — If set, lightbulb will have additional dimmer settings with this default brightness percentage
|
|
@@ -180,158 +183,49 @@ All fields are optional unless noted with an asterisk (*)
|
|
|
180
183
|
|
|
181
184
|
- `disableLogging` — If true, state changes will not be logged
|
|
182
185
|
|
|
183
|
-
##
|
|
186
|
+
## Webhooks
|
|
184
187
|
|
|
185
|
-
|
|
186
|
-
```json
|
|
187
|
-
{
|
|
188
|
-
"name": "Stateful",
|
|
189
|
-
"type": "Switch"
|
|
190
|
-
}
|
|
191
|
-
```
|
|
188
|
+
You can optionally enable webhooks on an accessory by choosing `Enable Webhooks` in the config UI or setting `enableWebhooks` to `true` in the JSON config.
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
```json
|
|
195
|
-
{
|
|
196
|
-
"name": "Timer",
|
|
197
|
-
"type": "Switch",
|
|
198
|
-
"timer": {
|
|
199
|
-
"delay": 10,
|
|
200
|
-
"units": "SECONDS"
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
190
|
+
If at least one accessory has webhooks enabled, then Homebridge Dummy will start a webhook server on startup on port `63743`, e.g. `http://localhost:63743/`
|
|
204
191
|
|
|
205
|
-
|
|
206
|
-
```json
|
|
207
|
-
{
|
|
208
|
-
"name": "Default On",
|
|
209
|
-
"type": "Switch",
|
|
210
|
-
"timer": {
|
|
211
|
-
"delay": 5,
|
|
212
|
-
"units": "SECONDS"
|
|
213
|
-
},
|
|
214
|
-
"defaultOn": true
|
|
215
|
-
}
|
|
216
|
-
```
|
|
192
|
+
Incoming requests must be valid JSON and include the id of the accessory, the desired command, and the value to set.
|
|
217
193
|
|
|
218
|
-
|
|
219
|
-
```json
|
|
220
|
-
{
|
|
221
|
-
"name": "Lightbulb",
|
|
222
|
-
"type": "Lightbulb",
|
|
223
|
-
"timer": {
|
|
224
|
-
"delay": 5,
|
|
225
|
-
"units": "SECONDS"
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
```
|
|
194
|
+
For example, to turn a switch on the JSON request should look like this:
|
|
229
195
|
|
|
230
|
-
### Stateful Dimmer Lightbulb
|
|
231
196
|
```json
|
|
232
197
|
{
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"
|
|
198
|
+
"id": "17a62a7b",
|
|
199
|
+
"command": "On",
|
|
200
|
+
"value": true
|
|
236
201
|
}
|
|
237
202
|
```
|
|
238
203
|
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"name": "Random",
|
|
243
|
-
"type": "Switch",
|
|
244
|
-
"timer": {
|
|
245
|
-
"delay": 2,
|
|
246
|
-
"units": "MINUTES",
|
|
247
|
-
"random": true
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
```
|
|
204
|
+
Here's how you would call it from the command line.
|
|
251
205
|
|
|
252
|
-
### Lock
|
|
253
|
-
```json
|
|
254
|
-
{
|
|
255
|
-
"name": "Lock",
|
|
256
|
-
"type": "LockMechanism",
|
|
257
|
-
"timer": {
|
|
258
|
-
"delay": 10,
|
|
259
|
-
"units": "MINUTES"
|
|
260
|
-
},
|
|
261
|
-
"defaultLockState": "locked"
|
|
262
|
-
}
|
|
263
206
|
```
|
|
264
|
-
|
|
265
|
-
### Motion Sensor Switch
|
|
266
|
-
```json
|
|
267
|
-
{
|
|
268
|
-
"name": "Motion Switch",
|
|
269
|
-
"type": "Switch",
|
|
270
|
-
"timer": {
|
|
271
|
-
"delay": 3,
|
|
272
|
-
"units": "MINUTES"
|
|
273
|
-
},
|
|
274
|
-
"sensor": "MotionSensor"
|
|
275
|
-
}
|
|
207
|
+
curl -X POST http://localhost:63743/ -H "Content-Type: application/json" -d '{"id": "17a62a7b", "command": "On", "value": true}
|
|
276
208
|
```
|
|
277
209
|
|
|
278
|
-
|
|
279
|
-
```json
|
|
280
|
-
{
|
|
281
|
-
"name": "Door",
|
|
282
|
-
"type": "Door",
|
|
283
|
-
"timer": {
|
|
284
|
-
"delay": 20,
|
|
285
|
-
"units": "SECONDS"
|
|
286
|
-
},
|
|
287
|
-
"defaultPosition": "closed"
|
|
288
|
-
}
|
|
289
|
-
```
|
|
210
|
+
The accessory `id` can be found in the plugin JSON config.
|
|
290
211
|
|
|
291
|
-
|
|
292
|
-
```json
|
|
293
|
-
{
|
|
294
|
-
"name": "Outlet 1",
|
|
295
|
-
"type": "Outlet",
|
|
296
|
-
"groupName": "Powerstrip"
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
"name": "Outlet 2",
|
|
300
|
-
"type": "Outlet",
|
|
301
|
-
"groupName": "Powerstrip"
|
|
302
|
-
}
|
|
303
|
-
{
|
|
304
|
-
"name": "Outlet 3",
|
|
305
|
-
"type": "Outlet",
|
|
306
|
-
"groupName": "Powerstrip"
|
|
307
|
-
}
|
|
308
|
-
```
|
|
212
|
+
Here are the possible values for `command` and their respective valid `value`
|
|
309
213
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
},
|
|
319
|
-
"schedule": {
|
|
320
|
-
"type": "INTERVAL",
|
|
321
|
-
"interval": 1,
|
|
322
|
-
"units": "HOURS"
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
```
|
|
214
|
+
- `Brightness` - number from 0-100
|
|
215
|
+
- `LockTargetState` - 0 (UNSECURED) or 1 (SECURED)
|
|
216
|
+
- `On` - true or false
|
|
217
|
+
- `TargetHeatingCoolingState` - 0 (OFF), 1 (HEAT), 2 (COOL), 3 (AUTO)
|
|
218
|
+
- `TargetPosition` - number from 0-100
|
|
219
|
+
- `TargetTemperature` - number between 10°C and 38°C
|
|
220
|
+
|
|
221
|
+
For `TargetTemperature` you may optionally supply a `unit` (either 'F' or 'C') to allow you to pass in Fahrenheit or Celsius units.
|
|
326
222
|
|
|
327
|
-
### Thermostat
|
|
328
223
|
```json
|
|
329
224
|
{
|
|
330
|
-
"
|
|
331
|
-
"
|
|
332
|
-
"
|
|
333
|
-
"
|
|
334
|
-
"defaultTemperature": 78
|
|
225
|
+
"id": "18a35b6c",
|
|
226
|
+
"command": "TargetTemperature",
|
|
227
|
+
"value": 72,
|
|
228
|
+
"unit": "F"
|
|
335
229
|
}
|
|
336
230
|
```
|
|
337
231
|
|
package/config.schema.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"schema": {
|
|
8
8
|
"type": "object",
|
|
9
9
|
"definitions": {
|
|
10
|
-
|
|
10
|
+
"units": {
|
|
11
11
|
"type": "string",
|
|
12
12
|
"title": "${config.title.units}",
|
|
13
13
|
"enum": [ "MILLISECONDS", "SECONDS", "MINUTES", "HOURS"],
|
|
@@ -248,12 +248,19 @@
|
|
|
248
248
|
"type": "boolean",
|
|
249
249
|
"title": "${config.title.resetOnRestart}"
|
|
250
250
|
},
|
|
251
|
+
"enableWebook": {
|
|
252
|
+
"type": "boolean",
|
|
253
|
+
"title": "${config.title.enableWebook}"
|
|
254
|
+
},
|
|
251
255
|
"disableLogging": {
|
|
252
256
|
"type": "boolean",
|
|
253
257
|
"title": "${config.title.disableLogging}"
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
260
|
}
|
|
261
|
+
},
|
|
262
|
+
"verbose": {
|
|
263
|
+
"type": "boolean"
|
|
257
264
|
}
|
|
258
265
|
}
|
|
259
266
|
},
|
|
@@ -382,6 +389,10 @@
|
|
|
382
389
|
"displayFlex": true,
|
|
383
390
|
"flex-direction": "row",
|
|
384
391
|
"items": [
|
|
392
|
+
{
|
|
393
|
+
"key": "accessories[].enableWebook",
|
|
394
|
+
"flex": "0 1 33%"
|
|
395
|
+
},
|
|
385
396
|
{
|
|
386
397
|
"key": "accessories[].disableLogging",
|
|
387
398
|
"flex": "0 1 33%"
|
package/dist/accessory/base.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PlatformAccessory, Service } from 'homebridge';
|
|
|
2
2
|
import { SensorAccessory } from './sensor.js';
|
|
3
3
|
import { AccessoryType } from '../model/enums.js';
|
|
4
4
|
import { CharacteristicType, DummyConfig, ServiceType } from '../model/types.js';
|
|
5
|
+
import { Webhook } from '../model/webhook.js';
|
|
5
6
|
import { Log } from '../tools/log.js';
|
|
6
7
|
export declare abstract class DummyAccessory<C extends DummyConfig> {
|
|
7
8
|
protected readonly Service: ServiceType;
|
|
@@ -21,7 +22,9 @@ export declare abstract class DummyAccessory<C extends DummyConfig> {
|
|
|
21
22
|
protected abstract reset(): Promise<void>;
|
|
22
23
|
get subtype(): string | undefined;
|
|
23
24
|
teardown(): void;
|
|
25
|
+
abstract webhooks(): Webhook[];
|
|
24
26
|
protected get identifier(): string;
|
|
27
|
+
protected get name(): string;
|
|
25
28
|
protected get isStateful(): boolean;
|
|
26
29
|
protected get defaultStateStorageKey(): string;
|
|
27
30
|
protected startTimer(): void;
|
package/dist/accessory/base.js
CHANGED
|
@@ -28,7 +28,7 @@ export class DummyAccessory {
|
|
|
28
28
|
this.config = config;
|
|
29
29
|
this.log = log;
|
|
30
30
|
this.persistPath = persistPath;
|
|
31
|
-
this.sensor = SensorAccessory.new(Service, Characteristic, accessory, this.
|
|
31
|
+
this.sensor = SensorAccessory.new(Service, Characteristic, accessory, this.name, log, this.config.disableLogging === true, config.sensor);
|
|
32
32
|
if (config.timer) {
|
|
33
33
|
this._timer = Timer.new(config.timer, config.name, log, config.disableLogging === true);
|
|
34
34
|
}
|
|
@@ -70,6 +70,9 @@ export class DummyAccessory {
|
|
|
70
70
|
get identifier() {
|
|
71
71
|
return DummyAccessory.identifier(this.config);
|
|
72
72
|
}
|
|
73
|
+
get name() {
|
|
74
|
+
return this.config.name;
|
|
75
|
+
}
|
|
73
76
|
get isStateful() {
|
|
74
77
|
return this._timer === undefined && this._schedule === undefined && !this.config.resetOnRestart;
|
|
75
78
|
}
|
|
@@ -85,10 +88,10 @@ export class DummyAccessory {
|
|
|
85
88
|
executeCommand(command) {
|
|
86
89
|
exec(command, (_error, stdout, stderr) => {
|
|
87
90
|
if (stderr) {
|
|
88
|
-
this.log.error(`${strings.accessory.command.error}: %s\n%s`, this.
|
|
91
|
+
this.log.error(`${strings.accessory.command.error}: %s\n%s`, this.name, command, stderr);
|
|
89
92
|
}
|
|
90
93
|
else {
|
|
91
|
-
this.logIfDesired(`${strings.accessory.command.executed}: %s\n%s`, this.
|
|
94
|
+
this.logIfDesired(`${strings.accessory.command.executed}: %s\n%s`, this.name, command, stdout);
|
|
92
95
|
}
|
|
93
96
|
});
|
|
94
97
|
}
|
|
@@ -96,7 +99,7 @@ export class DummyAccessory {
|
|
|
96
99
|
if (this.config.disableLogging) {
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
|
-
this.log.always(message, ...parameters);
|
|
102
|
+
this.log.always(message, this.name, ...parameters);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
//# sourceMappingURL=base.js.map
|
|
@@ -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,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AG,UAAU,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { PlatformAccessory } from 'homebridge';
|
|
2
2
|
import { CharacteristicType, GroupConfig, ServiceType } from '../model/types.js';
|
|
3
|
+
import { WebhookManager } from '../model/webhook.js';
|
|
3
4
|
import { Log } from '../tools/log.js';
|
|
4
5
|
export declare class GroupAccessory {
|
|
5
|
-
protected readonly Service: ServiceType;
|
|
6
|
-
protected readonly Characteristic: CharacteristicType;
|
|
7
|
-
protected readonly accessory: PlatformAccessory;
|
|
8
|
-
protected readonly config: GroupConfig;
|
|
9
|
-
protected readonly log: Log;
|
|
10
|
-
protected readonly persistPath: string;
|
|
11
6
|
static identifier(groupName: string): string;
|
|
12
7
|
private readonly accessories;
|
|
13
|
-
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: GroupConfig, log: Log, persistPath: string);
|
|
8
|
+
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: GroupConfig, log: Log, persistPath: string, webhookManager: WebhookManager);
|
|
14
9
|
teardown(): void;
|
|
15
10
|
}
|
package/dist/accessory/group.js
CHANGED
|
@@ -2,23 +2,11 @@ import { createDummyAccessory } from './helpers.js';
|
|
|
2
2
|
import { PLATFORM_NAME, PLUGIN_ALIAS } from '../homebridge/settings.js';
|
|
3
3
|
import getVersion from '../tools/version.js';
|
|
4
4
|
export class GroupAccessory {
|
|
5
|
-
Service;
|
|
6
|
-
Characteristic;
|
|
7
|
-
accessory;
|
|
8
|
-
config;
|
|
9
|
-
log;
|
|
10
|
-
persistPath;
|
|
11
5
|
static identifier(groupName) {
|
|
12
6
|
return `${PLATFORM_NAME}:Group:${groupName.replace(/\s+/g, '')})}`;
|
|
13
7
|
}
|
|
14
8
|
accessories = [];
|
|
15
|
-
constructor(Service, Characteristic, accessory, config, log, persistPath) {
|
|
16
|
-
this.Service = Service;
|
|
17
|
-
this.Characteristic = Characteristic;
|
|
18
|
-
this.accessory = accessory;
|
|
19
|
-
this.config = config;
|
|
20
|
-
this.log = log;
|
|
21
|
-
this.persistPath = persistPath;
|
|
9
|
+
constructor(Service, Characteristic, accessory, config, log, persistPath, webhookManager) {
|
|
22
10
|
accessory.getService(Service.AccessoryInformation)
|
|
23
11
|
.setCharacteristic(Characteristic.Manufacturer, PLUGIN_ALIAS)
|
|
24
12
|
.setCharacteristic(Characteristic.Model, GroupAccessory.name)
|
|
@@ -26,10 +14,13 @@ export class GroupAccessory {
|
|
|
26
14
|
.setCharacteristic(Characteristic.FirmwareRevision, getVersion());
|
|
27
15
|
const keepSubtypes = new Set();
|
|
28
16
|
for (const dummyConfig of config.accessories) {
|
|
29
|
-
const dummyAccessory = createDummyAccessory(
|
|
17
|
+
const dummyAccessory = createDummyAccessory(Service, Characteristic, accessory, dummyConfig, log, persistPath, true);
|
|
30
18
|
if (!dummyAccessory) {
|
|
31
19
|
continue;
|
|
32
20
|
}
|
|
21
|
+
if (dummyConfig.enableWebook) {
|
|
22
|
+
webhookManager.registerAccessory(dummyAccessory);
|
|
23
|
+
}
|
|
33
24
|
keepSubtypes.add(dummyAccessory.subtype);
|
|
34
25
|
this.accessories.push(dummyAccessory);
|
|
35
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/accessory/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/accessory/group.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,OAAO,cAAc;IAElB,MAAM,CAAC,UAAU,CAAC,SAAiB;QACxC,OAAO,GAAG,aAAa,UAA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AAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1D,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAEM,QAAQ;QACb,IAAI,CAAC,WAAW,CAAC,OAAO,CAAE,SAAS,CAAC,EAAE;YACpC,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/accessory/lock.d.ts
CHANGED
|
@@ -2,16 +2,19 @@ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
|
2
2
|
import { DummyAccessory } from './base.js';
|
|
3
3
|
import { AccessoryType } from '../model/enums.js';
|
|
4
4
|
import { CharacteristicType, LockConfig, ServiceType } from '../model/types.js';
|
|
5
|
+
import { Webhook } from '../model/webhook.js';
|
|
5
6
|
import { Log } from '../tools/log.js';
|
|
6
7
|
export declare class LockAccessory extends DummyAccessory<LockConfig> {
|
|
7
8
|
private state;
|
|
8
9
|
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LockConfig, log: Log, persistPath: string, isGrouped: boolean);
|
|
9
10
|
private initializeState;
|
|
10
|
-
|
|
11
|
+
getAccessoryType(): AccessoryType;
|
|
12
|
+
webhooks(): Webhook[];
|
|
11
13
|
private get defaultLockState();
|
|
12
14
|
protected getState(): Promise<CharacteristicValue>;
|
|
13
15
|
protected setState(value: CharacteristicValue): Promise<void>;
|
|
14
16
|
schedule(): Promise<void>;
|
|
15
17
|
reset(): Promise<void>;
|
|
18
|
+
private logTemplateForCV;
|
|
16
19
|
protected logLockState(value: CharacteristicValue): void;
|
|
17
20
|
}
|
package/dist/accessory/lock.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DummyAccessory } from './base.js';
|
|
2
2
|
import { strings } from '../i18n/i18n.js';
|
|
3
|
-
import { AccessoryType, DefaultLockState } from '../model/enums.js';
|
|
3
|
+
import { AccessoryType, DefaultLockState, WebhookCommand } from '../model/enums.js';
|
|
4
|
+
import { Webhook } from '../model/webhook.js';
|
|
4
5
|
import { storageGet, storageSet } from '../tools/storage.js';
|
|
5
6
|
export class LockAccessory extends DummyAccessory {
|
|
6
7
|
state;
|
|
@@ -24,6 +25,14 @@ export class LockAccessory extends DummyAccessory {
|
|
|
24
25
|
getAccessoryType() {
|
|
25
26
|
return AccessoryType.LockMechanism;
|
|
26
27
|
}
|
|
28
|
+
webhooks() {
|
|
29
|
+
return [
|
|
30
|
+
new Webhook(this.identifier, WebhookCommand.LockTargetState, (value) => {
|
|
31
|
+
this.setState(value);
|
|
32
|
+
return this.logTemplateForCV(value).replace('%s', this.name);
|
|
33
|
+
}),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
27
36
|
get defaultLockState() {
|
|
28
37
|
return this.config.defaultLockState === DefaultLockState.UNLOCKED ?
|
|
29
38
|
this.Characteristic.LockTargetState.UNSECURED : this.Characteristic.LockTargetState.SECURED;
|
|
@@ -79,10 +88,11 @@ export class LockAccessory extends DummyAccessory {
|
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
}
|
|
91
|
+
logTemplateForCV(value) {
|
|
92
|
+
return value === this.Characteristic.LockTargetState.SECURED ? strings.accessory.lock.secured : strings.accessory.lock.unsecured;
|
|
93
|
+
}
|
|
82
94
|
logLockState(value) {
|
|
83
|
-
|
|
84
|
-
strings.accessory.lock.secured : strings.accessory.lock.unsecured;
|
|
85
|
-
this.logIfDesired(message, this.config.name);
|
|
95
|
+
this.logIfDesired(this.logTemplateForCV(value));
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
//# sourceMappingURL=lock.js.map
|
|
@@ -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,OA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D,CAAC;CACF"}
|
|
@@ -2,15 +2,17 @@ import { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
|
2
2
|
import { OnOffAccessory } from './onoff.js';
|
|
3
3
|
import { AccessoryType } from '../../model/enums.js';
|
|
4
4
|
import { CharacteristicType, LightbulbConfig, ServiceType } from '../../model/types.js';
|
|
5
|
+
import { Webhook } from '../../model/webhook.js';
|
|
5
6
|
import { Log } from '../../tools/log.js';
|
|
6
7
|
export declare class LightbulbAccessory extends OnOffAccessory<LightbulbConfig> {
|
|
7
8
|
private brightness;
|
|
8
9
|
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LightbulbConfig, log: Log, persistPath: string, isGrouped: boolean);
|
|
9
10
|
private get isDimmer();
|
|
10
11
|
private get defaultBrightnessStorageKey();
|
|
11
|
-
|
|
12
|
+
getAccessoryType(): AccessoryType;
|
|
13
|
+
webhooks(): Webhook[];
|
|
12
14
|
private initializeBrightness;
|
|
13
|
-
|
|
15
|
+
logMessageForOnState(value: CharacteristicValue): string;
|
|
14
16
|
private getBrightness;
|
|
15
17
|
private setBrightness;
|
|
16
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OnOffAccessory } from './onoff.js';
|
|
2
2
|
import { strings } from '../../i18n/i18n.js';
|
|
3
|
-
import { AccessoryType } from '../../model/enums.js';
|
|
3
|
+
import { AccessoryType, WebhookCommand } from '../../model/enums.js';
|
|
4
|
+
import { Webhook } from '../../model/webhook.js';
|
|
4
5
|
import { STORAGE_KEY_SUFFIX_DEFAULT_BRIGHTNESS, storageGet, storageSet } from '../../tools/storage.js';
|
|
5
|
-
import { assertType } from '../../tools/validation.js';
|
|
6
6
|
const NO_BRIGHTNESS = -1;
|
|
7
7
|
export class LightbulbAccessory extends OnOffAccessory {
|
|
8
8
|
brightness;
|
|
@@ -25,33 +25,39 @@ export class LightbulbAccessory extends OnOffAccessory {
|
|
|
25
25
|
getAccessoryType() {
|
|
26
26
|
return AccessoryType.Lightbulb;
|
|
27
27
|
}
|
|
28
|
+
webhooks() {
|
|
29
|
+
return [
|
|
30
|
+
...super.webhooks(),
|
|
31
|
+
new Webhook(this.identifier, WebhookCommand.Brightness, (value) => {
|
|
32
|
+
this.setBrightness(value);
|
|
33
|
+
return strings.accessory.lightbulb.brightness.replace('%s', this.name).replace('%d', value.toString());
|
|
34
|
+
}),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
28
37
|
async initializeBrightness() {
|
|
29
38
|
if (this.isStateful) {
|
|
30
39
|
this.brightness = await storageGet(this.persistPath, this.defaultBrightnessStorageKey) ?? this.brightness;
|
|
31
40
|
}
|
|
32
41
|
this.accessoryService.updateCharacteristic(this.Characteristic.Brightness, this.brightness);
|
|
33
42
|
}
|
|
34
|
-
|
|
43
|
+
logMessageForOnState(value) {
|
|
35
44
|
if (this.isDimmer && value) {
|
|
36
|
-
|
|
45
|
+
return strings.accessory.lightbulb.stateOn.replace('%d', this.brightness.toLocaleString());
|
|
37
46
|
}
|
|
38
47
|
else {
|
|
39
|
-
super.
|
|
48
|
+
return super.logMessageForOnState(value);
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
async getBrightness() {
|
|
43
52
|
return this.brightness;
|
|
44
53
|
}
|
|
45
54
|
async setBrightness(value) {
|
|
46
|
-
if (!assertType(this.log, this.config.name, value, 'number')) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
55
|
this.startTimer();
|
|
50
56
|
if (this.brightness === value) {
|
|
51
57
|
return;
|
|
52
58
|
}
|
|
53
59
|
this.brightness = value;
|
|
54
|
-
this.logIfDesired(strings.accessory.lightbulb.brightness, this.
|
|
60
|
+
this.logIfDesired(strings.accessory.lightbulb.brightness, this.brightness.toString());
|
|
55
61
|
if (this.isStateful) {
|
|
56
62
|
await storageSet(this.persistPath, this.defaultBrightnessStorageKey, this.brightness);
|
|
57
63
|
}
|
|
@@ -1 +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,EAAE,MAAM,sBAAsB,CAAC;
|
|
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,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,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,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAE/E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,IAAI,aAAa,CAAC;QAEjE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAElB,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;iBACpE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACpC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,C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AC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QAC7F,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,KAA0B;QAEpD,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,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,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEtF,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,15 +1,17 @@
|
|
|
1
1
|
import { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
2
|
import { DummyAccessory } from '../base.js';
|
|
3
3
|
import { CharacteristicType, OnOffConfig, ServiceType } from '../../model/types.js';
|
|
4
|
+
import { Webhook } from '../../model/webhook.js';
|
|
4
5
|
import { Log } from '../../tools/log.js';
|
|
5
6
|
export declare abstract class OnOffAccessory<C extends OnOffConfig = OnOffConfig> extends DummyAccessory<C> {
|
|
6
7
|
private on;
|
|
7
8
|
constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, persistPath: string, isGrouped: boolean);
|
|
9
|
+
webhooks(): Webhook[];
|
|
8
10
|
private initializeOn;
|
|
9
11
|
private get defaultOn();
|
|
10
12
|
private getOn;
|
|
11
13
|
private setOn;
|
|
12
14
|
schedule(): Promise<void>;
|
|
13
15
|
reset(): Promise<void>;
|
|
14
|
-
protected
|
|
16
|
+
protected logMessageForOnState(value: CharacteristicValue): string;
|
|
15
17
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DummyAccessory } from '../base.js';
|
|
2
2
|
import { strings } from '../../i18n/i18n.js';
|
|
3
|
+
import { Webhook } from '../../model/webhook.js';
|
|
3
4
|
import { storageGet, storageSet } from '../../tools/storage.js';
|
|
4
|
-
import {
|
|
5
|
+
import { WebhookCommand } from '../../model/enums.js';
|
|
5
6
|
export class OnOffAccessory extends DummyAccessory {
|
|
6
7
|
on;
|
|
7
8
|
constructor(Service, Characteristic, accessory, config, log, persistPath, isGrouped) {
|
|
@@ -12,6 +13,14 @@ export class OnOffAccessory extends DummyAccessory {
|
|
|
12
13
|
.onSet(this.setOn.bind(this));
|
|
13
14
|
this.initializeOn();
|
|
14
15
|
}
|
|
16
|
+
webhooks() {
|
|
17
|
+
return [
|
|
18
|
+
new Webhook(this.identifier, WebhookCommand.On, (value) => {
|
|
19
|
+
this.setOn(value);
|
|
20
|
+
return this.logMessageForOnState(value).replace('%s', this.name);
|
|
21
|
+
}),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
15
24
|
async initializeOn() {
|
|
16
25
|
if (this.isStateful) {
|
|
17
26
|
this.on = await storageGet(this.persistPath, this.defaultStateStorageKey) ?? this.on;
|
|
@@ -25,11 +34,8 @@ export class OnOffAccessory extends DummyAccessory {
|
|
|
25
34
|
return this.on;
|
|
26
35
|
}
|
|
27
36
|
async setOn(value) {
|
|
28
|
-
if (!assertType(this.log, this.config.name, value, 'boolean')) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
37
|
if (this.on !== value) {
|
|
32
|
-
this.
|
|
38
|
+
this.logIfDesired(this.logMessageForOnState(value));
|
|
33
39
|
if (this.config.commandOn && value) {
|
|
34
40
|
this.executeCommand(this.config.commandOn);
|
|
35
41
|
}
|
|
@@ -72,8 +78,8 @@ export class OnOffAccessory extends DummyAccessory {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
logMessageForOnState(value) {
|
|
82
|
+
return value ? strings.accessory.onOff.stateOn : strings.accessory.onOff.stateOff;
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
//# sourceMappingURL=onoff.js.map
|