homebridge-easy-mqtt 1.1.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +18 -2
  3. package/config.schema.json +166 -76
  4. package/dist/accessory/{base.d.ts → abstract/base.d.ts} +6 -6
  5. package/dist/accessory/{base.js → abstract/base.js} +5 -5
  6. package/dist/accessory/abstract/base.js.map +1 -0
  7. package/dist/accessory/{statusActive.d.ts → abstract/statusActive.d.ts} +4 -5
  8. package/dist/accessory/{statusActive.js → abstract/statusActive.js} +7 -9
  9. package/dist/accessory/abstract/statusActive.js.map +1 -0
  10. package/dist/accessory/lock.d.ts +5 -6
  11. package/dist/accessory/lock.js +17 -19
  12. package/dist/accessory/lock.js.map +1 -1
  13. package/dist/accessory/{lightbulb.d.ts → onoff/lightbulb.d.ts} +6 -7
  14. package/dist/accessory/{lightbulb.js → onoff/lightbulb.js} +16 -18
  15. package/dist/accessory/onoff/lightbulb.js.map +1 -0
  16. package/dist/accessory/onoff/onoff.d.ts +14 -0
  17. package/dist/accessory/{onoff.js → onoff/onoff.js} +12 -14
  18. package/dist/accessory/onoff/onoff.js.map +1 -0
  19. package/dist/accessory/{outlet.d.ts → onoff/outlet.d.ts} +6 -7
  20. package/dist/accessory/{outlet.js → onoff/outlet.js} +12 -14
  21. package/dist/accessory/onoff/outlet.js.map +1 -0
  22. package/dist/accessory/{switch.d.ts → onoff/switch.d.ts} +4 -4
  23. package/dist/accessory/{switch.js → onoff/switch.js} +2 -2
  24. package/dist/accessory/onoff/switch.js.map +1 -0
  25. package/dist/accessory/security.d.ts +27 -0
  26. package/dist/accessory/security.js +178 -0
  27. package/dist/accessory/security.js.map +1 -0
  28. package/dist/accessory/temperatureSensor.d.ts +5 -6
  29. package/dist/accessory/temperatureSensor.js +7 -9
  30. package/dist/accessory/temperatureSensor.js.map +1 -1
  31. package/dist/homebridge/platform.js +7 -3
  32. package/dist/homebridge/platform.js.map +1 -1
  33. package/dist/homebridge-ui/public/index.html +1 -1
  34. package/dist/i18n/en.d.ts +32 -0
  35. package/dist/i18n/en.js +32 -0
  36. package/dist/i18n/en.js.map +1 -1
  37. package/dist/i18n/i18n.d.ts +32 -0
  38. package/dist/i18n/template.d.ts +32 -0
  39. package/dist/model/mqtt.js +17 -10
  40. package/dist/model/mqtt.js.map +1 -1
  41. package/dist/model/types.d.ts +14 -0
  42. package/package.json +1 -1
  43. package/dist/accessory/base.js.map +0 -1
  44. package/dist/accessory/lightbulb.js.map +0 -1
  45. package/dist/accessory/onoff.d.ts +0 -15
  46. package/dist/accessory/onoff.js.map +0 -1
  47. package/dist/accessory/outlet.js.map +0 -1
  48. package/dist/accessory/statusActive.js.map +0 -1
  49. package/dist/accessory/switch.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,12 +2,20 @@
2
2
 
3
3
  All notable changes to homebridge-dummy will be documented in this file.
4
4
 
5
- ## 1.1.0 (2025-08-20)
5
+ ## 1.2.0-beta.0 (2025-08-26)
6
6
 
7
7
  ### HELP NEEDED! (no coding experience required)
8
8
 
9
9
  Would you like to see Homebridge Easy MQTT in your language? Please consider [getting involved](https://github.com/mpatfield/homebridge-easy-mqtt/issues/4).
10
10
 
11
+ ### Added
12
+ - Security System accessory type
13
+
14
+ ### Changed
15
+ - Updated dev dependencies
16
+
17
+ ## 1.1.0 (2025-08-20)
18
+
11
19
  ### Added
12
20
  - Temperature Sensor accessory type
13
21
 
package/README.md CHANGED
@@ -23,7 +23,7 @@ Any issues or damage resulting from use of this plugin are not the fault of the
23
23
 
24
24
  This plugin is designed to be a simple replacement for the fantastic [homebridge-mqttthing](https://github.com/arachnetech/homebridge-mqttthing) plugin which appears as though it's [no longer](https://github.com/arachnetech/homebridge-mqttthing/commits/master/) being actively developed.
25
25
 
26
- **HomebridgeEasyMQTT** currently supports `Lightbulb`, `LockMechanism`, `Outlet`, `Switch`, and `TemperatureSensor`, but will be expanded over time as more use cases are discovered. If there is an accessory type you'd like to see supported, please feel free to [create an issue in GitHub](https://github.com/mpatfield/homebridge-easy-mqtt/issues/new/choose).
26
+ **HomebridgeEasyMQTT** currently supports `Lightbulb`, `LockMechanism`, `Outlet`, `SecuitySystem`,`Switch`, and `TemperatureSensor`, but will be expanded over time as more use cases are discovered. If there is an accessory type you'd like to see supported, please feel free to [create an issue in GitHub](https://github.com/mpatfield/homebridge-easy-mqtt/issues/new/choose).
27
27
 
28
28
  ## Configuration
29
29
 
@@ -75,7 +75,7 @@ All fields are required unless noted as "(Optional)"
75
75
  Info:
76
76
  - `id` - A unique ID to identify this accessory. Changing this value will result in a new accessory.
77
77
  - `name` - The display name for the accessory in HomeKit
78
- - `type` - The type of accessory, currently Lightbulb, LockMechanism, Outlet, Switch, and Temperature Sensor are supported
78
+ - `type` - The type of accessory, currently Lightbulb, LockMechanism, Outlet, SecuitySystem, Switch, and Temperature Sensor are supported
79
79
  - `manufacturer` - (Optional) The accessory manufacturer which will display in HomeKit device details
80
80
  - `model` - (Optional) The accessory model which will display in HomeKit device details
81
81
  - `serialNumber` - (Optional) The accessory serial number which will display in HomeKit device details
@@ -117,6 +117,13 @@ You may define topics using a JSONPath dot notation to assist the parser in find
117
117
  - `topicGetOutletInUse` - (Optional) Whether or not the outlet is currently being used
118
118
  - `topicSetOutletInUse` - (Optional) For setting whether the outlet is currently being used
119
119
 
120
+ - SecuitySystem
121
+ - `topicGetCurrentSecurityState` — The current state of the system
122
+ - `topicGetTargetSecurityState` — The target state of the system
123
+ - `topicSetTargetSecurityState` — For setting the target state of the system
124
+ - `topicGetStatusTampered` — For getting whether the system has been tampered with
125
+ - `topicGetStatusFault` — For getting whether there is a system error
126
+
120
127
  - Switch
121
128
  - `topicGetOn` - The current state of the switch, i.e. on/off
122
129
  - `topicSetOn` - For setting the state of the switch
@@ -147,6 +154,15 @@ As with Topics, you will need to populate the appropriate values based on the ty
147
154
  - `valueOutletInUse` - Currently being used, e.g. "true", or "1", or "On"
148
155
  - `valueOutletNotInUse` - Currently not being used, e.g. "false", or "0", or "Off"
149
156
 
157
+ - SecuritySystem
158
+ - `valueArmStay` — (Optional) system armed in stay mode, e.g. "SA" or "stay"
159
+ - `valueArmAway` — (Optional) system armed in away mode, e.g. "AA" or "away"
160
+ - `valueArmNight` — (Optional) system armed in night mode, e.g. "NA" or "night"
161
+ - `valueDisarm` — (Optional) system armed in away mode, e.g. "D" or "disarmed"
162
+ - `valueAlarmTriggered` — (Optional) when the alarm has been triggered, e.g. "true" or "1" or "triggered"
163
+ - `valueTampered` — (Optional) when the system has been tampered with, e.g. "true" or "1" or "tampered"
164
+ - `valueFault` — (Optional) when the system has a general fault, e.g. "true" or "1" or "fault"
165
+
150
166
  - Switch
151
167
  - `valueOn` - Turned on, e.g. "true", or "1", or "On"
152
168
  - `valueOff` - Turned off, e.g. "false", or "0", or "Off"
@@ -21,8 +21,8 @@
21
21
  "type": {
22
22
  "type": "string",
23
23
  "title": "${config.title.type}",
24
- "enum": [ "Lightbulb", "LockMechanism", "Outlet", "Switch", "TemperatureSensor"],
25
- "enumNames": ["${config.enumNames.lightbulb}", "${config.enumNames.lockMechanism}", "${config.enumNames.outlet}", "${config.enumNames.switch}", "${config.enumNames.temperatureSensor}"],
24
+ "enum": [ "Lightbulb", "LockMechanism", "Outlet", "SecuritySystem", "Switch", "TemperatureSensor"],
25
+ "enumNames": ["${config.enumNames.lightbulb}", "${config.enumNames.lockMechanism}", "${config.enumNames.outlet}", "${config.enumNames.securitySystem}", "${config.enumNames.switch}", "${config.enumNames.temperatureSensor}"],
26
26
  "required": true
27
27
  },
28
28
  "manufacturer": {
@@ -154,6 +154,26 @@
154
154
  "type": "string",
155
155
  "title": "${config.title.topicGetCurrentTemperature}"
156
156
  },
157
+ "topicGetCurrentSecurityState": {
158
+ "type": "string",
159
+ "title": "${config.title.topicGetCurrentSecurityState}"
160
+ },
161
+ "topicGetTargetSecurityState": {
162
+ "type": "string",
163
+ "title": "${config.title.topicGetTargetSecurityState}"
164
+ },
165
+ "topicSetTargetSecurityState": {
166
+ "type": "string",
167
+ "title": "${config.title.topicSetTargetSecurityState}"
168
+ },
169
+ "topicGetStatusTampered": {
170
+ "type": "string",
171
+ "title": "${config.title.topicGetStatusTampered}"
172
+ },
173
+ "topicGetStatusFault": {
174
+ "type": "string",
175
+ "title": "${config.title.topicGetStatusFault}"
176
+ },
157
177
  "valueStatusActive": {
158
178
  "type": "string",
159
179
  "title": "${config.title.valueStatusActive}",
@@ -187,6 +207,34 @@
187
207
  "type": "string",
188
208
  "title": "${config.title.valueOutletNotInUse}"
189
209
  },
210
+ "valueArmStay": {
211
+ "type": "string",
212
+ "title": "${config.title.valueArmStay}"
213
+ },
214
+ "valueArmAway": {
215
+ "type": "string",
216
+ "title": "${config.title.valueArmAway}"
217
+ },
218
+ "valueArmNight": {
219
+ "type": "string",
220
+ "title": "${config.title.valueArmNight}"
221
+ },
222
+ "valueDisarm": {
223
+ "type": "string",
224
+ "title": "${config.title.valueDisarm}"
225
+ },
226
+ "valueAlarmTriggered": {
227
+ "type": "string",
228
+ "title": "${config.title.valueAlarmTriggered}"
229
+ },
230
+ "valueTampered": {
231
+ "type": "string",
232
+ "title": "${config.title.valueTampered}"
233
+ },
234
+ "valueFault": {
235
+ "type": "string",
236
+ "title": "${config.title.valueFault}"
237
+ },
190
238
  "disableLogging": {
191
239
  "type": "boolean",
192
240
  "title": "${config.title.disableLogging}",
@@ -288,95 +336,73 @@
288
336
  {
289
337
  "type": "fieldset",
290
338
  "title": "${config.title.topics}",
339
+ "condition": {
340
+ "functionBody": "return model.accessories?.[arguments[1]]?.info?.type !== undefined;"
341
+ },
291
342
  "items": [
292
343
  {
293
- "key": "accessories[].topicGetLockCurrentState",
294
- "condition": {
295
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'LockMechanism';"
296
- }
297
- },
298
- {
299
- "key": "accessories[].topicGetLockTargetState",
300
- "condition": {
301
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'LockMechanism';"
302
- }
303
- },
304
- {
305
- "key": "accessories[].topicSetTargetState",
344
+ "type": "fieldset",
345
+ "notitle": "true",
346
+ "items": [
347
+ "accessories[].topicGetLockCurrentState",
348
+ "accessories[].topicGetLockTargetState",
349
+ "accessories[].topicSetTargetState"
350
+ ],
306
351
  "condition": {
307
352
  "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'LockMechanism';"
308
353
  }
309
354
  },
310
355
  {
311
- "key": "accessories[].topicGetOn",
312
- "condition": {
313
- "functionBody": "return ['Lightbulb', 'Outlet', 'Switch'].includes(model.accessories?.[arguments[1]]?.info?.type);"
314
- }
315
- },
316
- {
317
- "key": "accessories[].topicSetOn",
356
+ "type": "fieldset",
357
+ "notitle": "true",
358
+ "items": [
359
+ "accessories[].topicGetOn",
360
+ "accessories[].topicSetOn"
361
+ ],
318
362
  "condition": {
319
363
  "functionBody": "return ['Lightbulb', 'Outlet', 'Switch'].includes(model.accessories?.[arguments[1]]?.info?.type);"
320
364
  }
321
365
  },
322
366
  {
323
- "key": "accessories[].topicGetBrightness",
324
- "condition": {
325
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
326
- }
327
- },
328
- {
329
- "key": "accessories[].topicSetBrightness",
330
- "condition": {
331
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
332
- }
333
- },
334
- {
335
- "key": "accessories[].topicGetHue",
336
- "condition": {
337
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
338
- }
339
- },
340
- {
341
- "key": "accessories[].topicSetHue",
342
- "condition": {
343
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
344
- }
345
- },
346
- {
347
- "key": "accessories[].topicGetColorTemperature",
348
- "condition": {
349
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
350
- }
351
- },
352
- {
353
- "key": "accessories[].topicSetColorTemperature",
354
- "condition": {
355
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
356
- }
357
- },
358
- {
359
- "key": "accessories[].topicGetSaturation",
360
- "condition": {
361
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
362
- }
363
- },
364
- {
365
- "key": "accessories[].topicSetSaturation",
367
+ "type": "fieldset",
368
+ "notitle": "true",
369
+ "items": [
370
+ "accessories[].topicGetBrightness",
371
+ "accessories[].topicSetBrightness",
372
+ "accessories[].topicGetHue",
373
+ "accessories[].topicSetHue",
374
+ "accessories[].topicGetColorTemperature",
375
+ "accessories[].topicSetColorTemperature",
376
+ "accessories[].topicGetSaturation",
377
+ "accessories[].topicSetSaturation"
378
+ ],
366
379
  "condition": {
367
380
  "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Lightbulb';"
368
381
  }
369
382
  },
370
383
  {
371
- "key": "accessories[].topicGetOutletInUse",
384
+ "type": "fieldset",
385
+ "notitle": "true",
386
+ "items": [
387
+ "accessories[].topicGetOutletInUse",
388
+ "accessories[].topicSetOutletInUse"
389
+ ],
372
390
  "condition": {
373
391
  "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Outlet';"
374
392
  }
375
393
  },
376
394
  {
377
- "key": "accessories[].topicSetOutletInUse",
395
+ "type": "fieldset",
396
+ "notitle": "true",
397
+ "items": [
398
+ "accessories[].topicGetCurrentSecurityState",
399
+ "accessories[].topicGetTargetSecurityState",
400
+ "accessories[].topicSetTargetSecurityState",
401
+ "accessories[].topicGetStatusTampered",
402
+ "accessories[].topicGetStatusFault"
403
+ ],
378
404
  "condition": {
379
- "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'Outlet';"
405
+ "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'SecuritySystem';"
380
406
  }
381
407
  },
382
408
  {
@@ -404,6 +430,9 @@
404
430
  {
405
431
  "type": "fieldset",
406
432
  "title": "${config.title.values}",
433
+ "condition": {
434
+ "functionBody": "return model.accessories?.[arguments[1]]?.info?.type !== undefined;"
435
+ },
407
436
  "items": [
408
437
  {
409
438
  "type": "div",
@@ -415,15 +444,15 @@
415
444
  "items": [
416
445
  {
417
446
  "key": "accessories[].valueLockStateSecured",
418
- "flex": "1 1 0"
447
+ "flex": "0 0 25%"
419
448
  },
420
449
  {
421
450
  "key": "accessories[].valueLockStateUnsecured",
422
- "flex": "1 1 0"
451
+ "flex": "0 0 25%"
423
452
  },
424
453
  {
425
454
  "key": "accessories[].valueLockStateJammed",
426
- "flex": "1 1 0"
455
+ "flex": "0 0 25%"
427
456
  }
428
457
  ]
429
458
  },
@@ -437,11 +466,11 @@
437
466
  "items": [
438
467
  {
439
468
  "key": "accessories[].valueOn",
440
- "flex": "1 1 0"
469
+ "flex": "0 0 25%"
441
470
  },
442
471
  {
443
472
  "key": "accessories[].valueOff",
444
- "flex": "1 1 0"
473
+ "flex": "0 0 25%"
445
474
  }
446
475
  ]
447
476
  },
@@ -455,15 +484,76 @@
455
484
  "items": [
456
485
  {
457
486
  "key": "accessories[].valueOutletInUse",
458
- "flex": "1 1 0"
487
+ "flex": "0 0 25%"
459
488
  },
460
489
  {
461
490
  "key": "accessories[].valueOutletNotInUse",
462
- "flex": "1 1 0"
491
+ "flex": "0 0 25%"
492
+ }
493
+ ]
494
+ },
495
+ {
496
+ "type": "fieldset",
497
+ "notitle": true,
498
+ "condition": {
499
+ "functionBody": "return model.accessories?.[arguments[1]]?.info?.type === 'SecuritySystem';"
500
+ },
501
+ "items": [
502
+ {
503
+ "type": "div",
504
+ "displayFlex": true,
505
+ "flex-direction": "row",
506
+ "items": [
507
+ {
508
+ "key": "accessories[].valueArmStay",
509
+ "flex": "0 0 25%"
510
+ },
511
+ {
512
+ "key": "accessories[].valueArmAway",
513
+ "flex": "0 0 25%"
514
+ },
515
+ {
516
+ "key": "accessories[].valueArmNight",
517
+ "flex": "0 0 25%"
518
+ },
519
+ {
520
+ "key": "accessories[].valueDisarm",
521
+ "flex": "0 0 25%"
522
+ }
523
+ ]
524
+ },
525
+ {
526
+ "type": "div",
527
+ "displayFlex": true,
528
+ "flex-direction": "row",
529
+ "items": [
530
+ {
531
+ "key": "accessories[].valueAlarmTriggered",
532
+ "flex": "0 0 25%"
533
+ },
534
+ {
535
+ "key": "accessories[].valueTampered",
536
+ "flex": "0 0 25%"
537
+ },
538
+ {
539
+ "key": "accessories[].valueFault",
540
+ "flex": "0 0 25%"
541
+ }
542
+ ]
463
543
  }
464
544
  ]
465
545
  },
466
- "accessories[].valueStatusActive"
546
+ {
547
+ "type": "div",
548
+ "displayFlex": true,
549
+ "flex-direction": "row",
550
+ "items": [
551
+ {
552
+ "key": "accessories[].valueStatusActive",
553
+ "flex": "0 0 50%"
554
+ }
555
+ ]
556
+ }
467
557
  ]
468
558
  }
469
559
  ]
@@ -1,20 +1,20 @@
1
1
  import { PlatformAccessory } from 'homebridge';
2
- import { AccessoryConfig, CharacteristicType, ServiceType } from '../model/types.js';
3
- import { Log } from '../tools/log.js';
4
- import { Primitive } from '../tools/primitive.js';
2
+ import { AccessoryConfig, CharacteristicType, ServiceType } from '../../model/types.js';
3
+ import { Log } from '../../tools/log.js';
4
+ import { Primitive } from '../../tools/primitive.js';
5
5
  export type TopicHandler = {
6
6
  topic: string;
7
7
  handler: ((topic: string, value: Primitive) => Promise<void>);
8
8
  };
9
9
  export declare function makeHandler(topic: string, handler: (topic: string, value: Primitive) => Promise<void>): TopicHandler;
10
- export declare abstract class MQTTAccessory {
10
+ export declare abstract class MQTTAccessory<C extends AccessoryConfig> {
11
11
  protected readonly Service: ServiceType;
12
12
  protected readonly Characteristic: CharacteristicType;
13
13
  protected readonly accessory: PlatformAccessory;
14
- protected readonly config: AccessoryConfig;
14
+ protected readonly config: C;
15
15
  protected readonly log: Log;
16
16
  private readonly mqttClient;
17
- constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: AccessoryConfig, log: Log, caller: string);
17
+ constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, caller: string);
18
18
  private onMQTTConnect;
19
19
  protected abstract get topicHandlers(): TopicHandler[];
20
20
  protected get name(): string;
@@ -1,7 +1,7 @@
1
- import { PLATFORM_NAME } from '../homebridge/settings.js';
2
- import { MQTT } from '../model/mqtt.js';
3
- import getVersion from '../tools/version.js';
4
- import { assert } from '../tools/validation.js';
1
+ import { PLATFORM_NAME } from '../../homebridge/settings.js';
2
+ import { MQTT } from '../../model/mqtt.js';
3
+ import getVersion from '../../tools/version.js';
4
+ import { assert } from '../../tools/validation.js';
5
5
  export function makeHandler(topic, handler) {
6
6
  return { topic, handler };
7
7
  }
@@ -53,7 +53,7 @@ export class MQTTAccessory {
53
53
  if (this.config.disableLogging) {
54
54
  return;
55
55
  }
56
- this.log.always(message, ...parameters);
56
+ this.log.always(message, this.name, ...parameters);
57
57
  }
58
58
  }
59
59
  //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/accessory/abstract/base.ts"],"names":[],"mappings":"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"}
@@ -1,12 +1,11 @@
1
1
  import { PlatformAccessory, Service } from 'homebridge';
2
2
  import { MQTTAccessory, TopicHandler } from './base.js';
3
- import { CharacteristicType, StatusActiveConfig, ServiceType } from '../model/types.js';
4
- import { Log } from '../tools/log.js';
5
- export declare abstract class StatusActiveAccessory extends MQTTAccessory {
6
- private readonly statusActiveConfig;
3
+ import { CharacteristicType, StatusActiveConfig, ServiceType } from '../../model/types.js';
4
+ import { Log } from '../../tools/log.js';
5
+ export declare abstract class StatusActiveAccessory<C extends StatusActiveConfig = StatusActiveConfig> extends MQTTAccessory<C> {
7
6
  protected readonly accessoryService: Service;
8
7
  private statusActive;
9
- constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, statusActiveConfig: StatusActiveConfig, log: Log, className: string);
8
+ constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: C, log: Log, className: string);
10
9
  protected abstract getAccessoryService(): Service;
11
10
  protected get topicHandlers(): TopicHandler[];
12
11
  private onStatusActiveUpdate;
@@ -1,34 +1,32 @@
1
1
  import { makeHandler, MQTTAccessory } from './base.js';
2
- import { strings } from '../i18n/i18n.js';
3
- import { toPrimitive } from '../tools/primitive.js';
2
+ import { strings } from '../../i18n/i18n.js';
3
+ import { toPrimitive } from '../../tools/primitive.js';
4
4
  export class StatusActiveAccessory extends MQTTAccessory {
5
- statusActiveConfig;
6
5
  accessoryService;
7
6
  statusActive = true;
8
- constructor(Service, Characteristic, accessory, statusActiveConfig, log, className) {
9
- super(Service, Characteristic, accessory, statusActiveConfig, log, className);
10
- this.statusActiveConfig = statusActiveConfig;
7
+ constructor(Service, Characteristic, accessory, config, log, className) {
8
+ super(Service, Characteristic, accessory, config, log, className);
11
9
  this.accessoryService = this.getAccessoryService();
12
10
  this.accessoryService.getCharacteristic(Characteristic.StatusActive)
13
11
  .onGet(this.getStatusActive.bind(this));
14
12
  }
15
13
  get topicHandlers() {
16
14
  return [
17
- ...(this.statusActiveConfig.topicGetStatusActive ? [makeHandler(this.statusActiveConfig.topicGetStatusActive, this.onStatusActiveUpdate.bind(this))] : []),
15
+ ...(this.config.topicGetStatusActive ? [makeHandler(this.config.topicGetStatusActive, this.onStatusActiveUpdate.bind(this))] : []),
18
16
  ];
19
17
  }
20
18
  async onStatusActiveUpdate(topic, value) {
21
19
  if (!this.assert('valueStatusActive')) {
22
20
  return;
23
21
  }
24
- const statusActive = value === toPrimitive(this.statusActiveConfig.valueStatusActive);
22
+ const statusActive = value === toPrimitive(this.config.valueStatusActive);
25
23
  if (statusActive === this.statusActive) {
26
24
  return;
27
25
  }
28
26
  this.statusActive = statusActive;
29
27
  this.accessoryService.updateCharacteristic(this.Characteristic.StatusActive, this.statusActive);
30
28
  if (this.statusActive) {
31
- this.logIfDesired(strings.accessory.statusActive, this.name);
29
+ this.logIfDesired(strings.accessory.statusActive);
32
30
  }
33
31
  else {
34
32
  this.log.warning(strings.accessory.statusInactive, this.name);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusActive.js","sourceRoot":"","sources":["../../../src/accessory/abstract/statusActive.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAgB,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,OAAO,EAAa,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,OAAgB,qBAAyE,SAAQ,aAAgB;IAClG,gBAAgB,CAAU;IAErC,YAAY,GAAwB,IAAI,CAAC;IAEjD,YACE,OAAoB,EACpB,cAAkC,EAClC,SAA4B,EAC5B,MAAS,EACT,GAAQ,EACR,SAAiB;QAEjB,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAElE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEnD,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,cAAc,CAAC,YAAY,CAAC;aACjE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAID,IAAc,aAAa;QACzB,OAAO;YACL,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,EAAE,CAAC;SAClI,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,oBAAoB,CAAC,KAAa,EAAE,KAAgB;QAEhE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACtC,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,KAAK,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC1E,IAAI,YAAY,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAEhG,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,eAAe;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF"}
@@ -1,15 +1,14 @@
1
1
  import { PlatformAccessory, Service } from 'homebridge';
2
- import { TopicHandler } from './base.js';
3
- import { StatusActiveAccessory } from './statusActive.js';
2
+ import { TopicHandler } from './abstract/base.js';
3
+ import { StatusActiveAccessory } from './abstract/statusActive.js';
4
4
  import { CharacteristicType, LockMechanismConfig, ServiceType } from '../model/types.js';
5
5
  import { Log } from '../tools/log.js';
6
- export declare class LockMechanismAccessory extends StatusActiveAccessory {
7
- private readonly lockMechanismConfig;
6
+ export declare class LockMechanismAccessory extends StatusActiveAccessory<LockMechanismConfig> {
8
7
  private currentState;
9
8
  private targetState;
10
- constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, lockMechanismConfig: LockMechanismConfig, log: Log);
9
+ constructor(Service: ServiceType, Characteristic: CharacteristicType, accessory: PlatformAccessory, config: LockMechanismConfig, log: Log);
11
10
  protected getAccessoryService(): Service;
12
- protected get topicHandlers(): TopicHandler[];
11
+ get topicHandlers(): TopicHandler[];
13
12
  private getCurrentState;
14
13
  private getTargetState;
15
14
  private onCurrentStateUpdate;