homebridge-securitysystem 12.0.0 → 13.0.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/.github/workflows/bump-version.yml +1 -1
- package/.gitignore +127 -0
- package/AGENTS.md +7 -7
- package/CHANGELOG.md +30 -0
- package/config.schema.json +1 -145
- package/package.json +1 -1
- package/src/constants/default-constant.ts +0 -3
- package/src/constants/switch-uuid-constant.ts +0 -2
- package/src/handlers/sensor-handler.ts +0 -22
- package/src/handlers/state-handler.ts +0 -17
- package/src/handlers/trip-handler.ts +0 -3
- package/src/homekit/homekit-registrar.ts +1 -6
- package/src/homekit/service-factory.ts +0 -11
- package/src/interfaces/options-interface.ts +0 -19
- package/src/interfaces/service-registry-interface.ts +0 -4
- package/src/interfaces/system-state-interface.ts +0 -2
- package/src/security-system.ts +2 -14
- package/src/services/configuration-service.ts +0 -33
- package/src/services/event-bus-service.ts +1 -1
- package/src/tests/conditions.test.ts +0 -1
- package/src/tests/mqtt-service.test.ts +0 -1
- package/src/tests/server-service.test.ts +0 -1
- package/src/tests/state-handler.test.ts +14 -65
- package/src/tests/switch-handler.test.ts +2 -6
- package/src/tests/trip-handler.test.ts +7 -11
- package/src/timers/timer-manager.ts +0 -17
- package/src/types/mode-type.ts +1 -1
- package/dist/conditions/already-triggered-condition.d.ts +0 -10
- package/dist/conditions/already-triggered-condition.js +0 -22
- package/dist/conditions/already-triggered-condition.js.map +0 -1
- package/dist/conditions/arming-in-progress-condition.d.ts +0 -10
- package/dist/conditions/arming-in-progress-condition.js +0 -21
- package/dist/conditions/arming-in-progress-condition.js.map +0 -1
- package/dist/conditions/arming-lock-condition.d.ts +0 -13
- package/dist/conditions/arming-lock-condition.js +0 -50
- package/dist/conditions/arming-lock-condition.js.map +0 -1
- package/dist/conditions/condition.d.ts +0 -22
- package/dist/conditions/condition.js +0 -19
- package/dist/conditions/condition.js.map +0 -1
- package/dist/conditions/double-knock-condition.d.ts +0 -24
- package/dist/conditions/double-knock-condition.js +0 -73
- package/dist/conditions/double-knock-condition.js.map +0 -1
- package/dist/conditions/not-armed-condition.d.ts +0 -10
- package/dist/conditions/not-armed-condition.js +0 -26
- package/dist/conditions/not-armed-condition.js.map +0 -1
- package/dist/conditions/trigger-already-running-condition.d.ts +0 -10
- package/dist/conditions/trigger-already-running-condition.js +0 -21
- package/dist/conditions/trigger-already-running-condition.js.map +0 -1
- package/dist/constants/default-constant.d.ts +0 -27
- package/dist/constants/default-constant.js +0 -30
- package/dist/constants/default-constant.js.map +0 -1
- package/dist/constants/homekit-constant.d.ts +0 -4
- package/dist/constants/homekit-constant.js +0 -5
- package/dist/constants/homekit-constant.js.map +0 -1
- package/dist/constants/switch-uuid-constant.d.ts +0 -23
- package/dist/constants/switch-uuid-constant.js +0 -24
- package/dist/constants/switch-uuid-constant.js.map +0 -1
- package/dist/handlers/sensor-handler.d.ts +0 -20
- package/dist/handlers/sensor-handler.js +0 -66
- package/dist/handlers/sensor-handler.js.map +0 -1
- package/dist/handlers/state-handler.d.ts +0 -52
- package/dist/handlers/state-handler.js +0 -213
- package/dist/handlers/state-handler.js.map +0 -1
- package/dist/handlers/switch-handler.d.ts +0 -35
- package/dist/handlers/switch-handler.js +0 -134
- package/dist/handlers/switch-handler.js.map +0 -1
- package/dist/handlers/trip-handler.d.ts +0 -51
- package/dist/handlers/trip-handler.js +0 -198
- package/dist/handlers/trip-handler.js.map +0 -1
- package/dist/homekit/homekit-registrar.d.ts +0 -19
- package/dist/homekit/homekit-registrar.js +0 -156
- package/dist/homekit/homekit-registrar.js.map +0 -1
- package/dist/homekit/service-factory.d.ts +0 -9
- package/dist/homekit/service-factory.js +0 -124
- package/dist/homekit/service-factory.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js.map +0 -1
- package/dist/interfaces/condition-context-interface.d.ts +0 -16
- package/dist/interfaces/condition-context-interface.js +0 -2
- package/dist/interfaces/condition-context-interface.js.map +0 -1
- package/dist/interfaces/hap-types-interface.d.ts +0 -9
- package/dist/interfaces/hap-types-interface.js +0 -2
- package/dist/interfaces/hap-types-interface.js.map +0 -1
- package/dist/interfaces/mqtt-status-payload-interface.d.ts +0 -6
- package/dist/interfaces/mqtt-status-payload-interface.js +0 -2
- package/dist/interfaces/mqtt-status-payload-interface.js.map +0 -1
- package/dist/interfaces/options-interface.d.ts +0 -103
- package/dist/interfaces/options-interface.js +0 -2
- package/dist/interfaces/options-interface.js.map +0 -1
- package/dist/interfaces/persisted-state-interface.d.ts +0 -6
- package/dist/interfaces/persisted-state-interface.js +0 -2
- package/dist/interfaces/persisted-state-interface.js.map +0 -1
- package/dist/interfaces/service-registry-interface.d.ts +0 -33
- package/dist/interfaces/service-registry-interface.js +0 -2
- package/dist/interfaces/service-registry-interface.js.map +0 -1
- package/dist/interfaces/system-state-interface.d.ts +0 -15
- package/dist/interfaces/system-state-interface.js +0 -2
- package/dist/interfaces/system-state-interface.js.map +0 -1
- package/dist/schemas/arming-lock-schema.d.ts +0 -10
- package/dist/schemas/arming-lock-schema.js +0 -12
- package/dist/schemas/arming-lock-schema.js.map +0 -1
- package/dist/schemas/error-schema.d.ts +0 -4
- package/dist/schemas/error-schema.js +0 -7
- package/dist/schemas/error-schema.js.map +0 -1
- package/dist/schemas/mode-request-schema.d.ts +0 -10
- package/dist/schemas/mode-request-schema.js +0 -18
- package/dist/schemas/mode-request-schema.js.map +0 -1
- package/dist/schemas/status-response-schema.d.ts +0 -7
- package/dist/schemas/status-response-schema.js +0 -10
- package/dist/schemas/status-response-schema.js.map +0 -1
- package/dist/schemas/trip-mode-request-schema.d.ts +0 -9
- package/dist/schemas/trip-mode-request-schema.js +0 -24
- package/dist/schemas/trip-mode-request-schema.js.map +0 -1
- package/dist/security-system.d.ts +0 -22
- package/dist/security-system.js +0 -154
- package/dist/security-system.js.map +0 -1
- package/dist/services/audio-service.d.ts +0 -21
- package/dist/services/audio-service.js +0 -113
- package/dist/services/audio-service.js.map +0 -1
- package/dist/services/command-service.d.ts +0 -16
- package/dist/services/command-service.js +0 -65
- package/dist/services/command-service.js.map +0 -1
- package/dist/services/configuration-service.d.ts +0 -25
- package/dist/services/configuration-service.js +0 -218
- package/dist/services/configuration-service.js.map +0 -1
- package/dist/services/event-bus-service.d.ts +0 -12
- package/dist/services/event-bus-service.js +0 -17
- package/dist/services/event-bus-service.js.map +0 -1
- package/dist/services/mqtt-service.d.ts +0 -16
- package/dist/services/mqtt-service.js +0 -97
- package/dist/services/mqtt-service.js.map +0 -1
- package/dist/services/server-service.d.ts +0 -28
- package/dist/services/server-service.js +0 -275
- package/dist/services/server-service.js.map +0 -1
- package/dist/services/storage-service.d.ts +0 -14
- package/dist/services/storage-service.js +0 -70
- package/dist/services/storage-service.js.map +0 -1
- package/dist/services/webhook-service.d.ts +0 -16
- package/dist/services/webhook-service.js +0 -68
- package/dist/services/webhook-service.js.map +0 -1
- package/dist/tests/conditions.test.d.ts +0 -1
- package/dist/tests/conditions.test.js +0 -148
- package/dist/tests/conditions.test.js.map +0 -1
- package/dist/tests/mqtt-service.test.d.ts +0 -1
- package/dist/tests/mqtt-service.test.js +0 -167
- package/dist/tests/mqtt-service.test.js.map +0 -1
- package/dist/tests/server-service.test.d.ts +0 -1
- package/dist/tests/server-service.test.js +0 -187
- package/dist/tests/server-service.test.js.map +0 -1
- package/dist/tests/state-handler.test.d.ts +0 -1
- package/dist/tests/state-handler.test.js +0 -273
- package/dist/tests/state-handler.test.js.map +0 -1
- package/dist/tests/switch-handler.test.d.ts +0 -1
- package/dist/tests/switch-handler.test.js +0 -267
- package/dist/tests/switch-handler.test.js.map +0 -1
- package/dist/tests/trip-handler.test.d.ts +0 -1
- package/dist/tests/trip-handler.test.js +0 -289
- package/dist/tests/trip-handler.test.js.map +0 -1
- package/dist/timers/timer-manager.d.ts +0 -34
- package/dist/timers/timer-manager.js +0 -132
- package/dist/timers/timer-manager.js.map +0 -1
- package/dist/types/event-payload-map-type.d.ts +0 -14
- package/dist/types/event-payload-map-type.js +0 -2
- package/dist/types/event-payload-map-type.js.map +0 -1
- package/dist/types/event-type.d.ts +0 -38
- package/dist/types/event-type.js +0 -17
- package/dist/types/event-type.js.map +0 -1
- package/dist/types/mode-type.d.ts +0 -4
- package/dist/types/mode-type.js +0 -2
- package/dist/types/mode-type.js.map +0 -1
- package/dist/types/origin-type.d.ts +0 -9
- package/dist/types/origin-type.js +0 -11
- package/dist/types/origin-type.js.map +0 -1
- package/dist/types/security-state-type.d.ts +0 -11
- package/dist/types/security-state-type.js +0 -13
- package/dist/types/security-state-type.js.map +0 -1
- package/dist/types/service-result-type.d.ts +0 -4
- package/dist/types/service-result-type.js +0 -2
- package/dist/types/service-result-type.js.map +0 -1
- package/dist/utils/arming-util.d.ts +0 -19
- package/dist/utils/arming-util.js +0 -24
- package/dist/utils/arming-util.js.map +0 -1
- package/dist/utils/state-util.d.ts +0 -8
- package/dist/utils/state-util.js +0 -29
- package/dist/utils/state-util.js.map +0 -1
- package/sounds/README +0 -22
- package/sounds/de-DE/current-away.mp3 +0 -0
- package/sounds/de-DE/current-home.mp3 +0 -0
- package/sounds/de-DE/current-night.mp3 +0 -0
- package/sounds/de-DE/current-off.mp3 +0 -0
- package/sounds/de-DE/current-triggered.mp3 +0 -0
- package/sounds/de-DE/current-warning.mp3 +0 -0
- package/sounds/de-DE/target-away.mp3 +0 -0
- package/sounds/de-DE/target-home.mp3 +0 -0
- package/sounds/de-DE/target-night.mp3 +0 -0
- package/sounds/en-US/current-away.mp3 +0 -0
- package/sounds/en-US/current-home.mp3 +0 -0
- package/sounds/en-US/current-night.mp3 +0 -0
- package/sounds/en-US/current-off.mp3 +0 -0
- package/sounds/en-US/current-triggered.mp3 +0 -0
- package/sounds/en-US/current-warning.mp3 +0 -0
- package/sounds/en-US/target-away.mp3 +0 -0
- package/sounds/en-US/target-home.mp3 +0 -0
- package/sounds/en-US/target-night.mp3 +0 -0
- package/src/services/audio-service.ts +0 -133
package/src/security-system.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { ServiceRegistry } from './interfaces/service-registry-interface.js
|
|
|
10
10
|
import { EventBusService } from './services/event-bus-service.js';
|
|
11
11
|
import { EventType } from './types/event-type.js';
|
|
12
12
|
import { StorageService } from './services/storage-service.js';
|
|
13
|
-
import { AudioService } from './services/audio-service.js';
|
|
14
13
|
import { WebhookService } from './services/webhook-service.js';
|
|
15
14
|
import { CommandService } from './services/command-service.js';
|
|
16
15
|
import { MqttService } from './services/mqtt-service.js';
|
|
@@ -35,7 +34,6 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
35
34
|
private readonly switchHandler: SwitchHandler;
|
|
36
35
|
private readonly sensorHandler: SensorHandler;
|
|
37
36
|
private readonly storageService: StorageService;
|
|
38
|
-
private readonly audioService: AudioService;
|
|
39
37
|
|
|
40
38
|
constructor(
|
|
41
39
|
private readonly log: Logging,
|
|
@@ -64,20 +62,17 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
64
62
|
// Services.
|
|
65
63
|
this.bus = new EventBusService();
|
|
66
64
|
this.storageService = new StorageService(log, this.options, api.user.storagePath());
|
|
67
|
-
this.audioService = new AudioService(log, this.options, this.state, () =>
|
|
68
|
-
Boolean(this.svcs.audioSwitchService.getCharacteristic(Char.On).value),
|
|
69
|
-
);
|
|
70
65
|
const timerManager = new TimerManager(log);
|
|
71
66
|
|
|
72
67
|
// Handlers — construction order matters: sensorHandler first (leaf), then stateHandler,
|
|
73
68
|
// then switchHandler (depends on stateHandler), then tripHandler.
|
|
74
69
|
this.sensorHandler = new SensorHandler(this.svcs, Char, log);
|
|
75
70
|
this.stateHandler = new StateHandler(
|
|
76
|
-
this.svcs, this.state, this.options, Char, log, this.bus, this.storageService,
|
|
71
|
+
this.svcs, this.state, this.options, Char, log, this.bus, this.storageService, timerManager, this.sensorHandler,
|
|
77
72
|
);
|
|
78
73
|
this.switchHandler = new SwitchHandler(this.svcs, this.state, this.options, Char, log, timerManager, this.stateHandler);
|
|
79
74
|
this.tripHandler = new TripHandler(
|
|
80
|
-
this.svcs, this.state, this.options, Char, log, this.bus, this.
|
|
75
|
+
this.svcs, this.state, this.options, Char, log, this.bus, this.sensorHandler, timerManager,
|
|
81
76
|
);
|
|
82
77
|
|
|
83
78
|
// Wire bus listeners for cross-handler coordination (no more circular constructor deps).
|
|
@@ -95,7 +90,6 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
95
90
|
});
|
|
96
91
|
|
|
97
92
|
// Attach side-effect listeners.
|
|
98
|
-
this.audioService.attachToBus(this.bus);
|
|
99
93
|
const webhookSvc = new WebhookService(log, this.options, this.state);
|
|
100
94
|
const commandSvc = new CommandService(log, this.options, this.state);
|
|
101
95
|
webhookSvc.attachToBus(this.bus);
|
|
@@ -130,10 +124,6 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
130
124
|
syncModeSwitches();
|
|
131
125
|
}
|
|
132
126
|
|
|
133
|
-
if (this.options.audioPath) {
|
|
134
|
-
this.audioService.setup();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
127
|
if (this.options.serverPort !== null) {
|
|
138
128
|
new ServerService(log, this.options, this.state, this.stateHandler, this.tripHandler, this.switchHandler).start();
|
|
139
129
|
}
|
|
@@ -160,7 +150,6 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
160
150
|
isKnocked: false,
|
|
161
151
|
serverAuthenticationAttempts: 0,
|
|
162
152
|
pausedCurrentState: null,
|
|
163
|
-
audioProcess: null,
|
|
164
153
|
};
|
|
165
154
|
}
|
|
166
155
|
|
|
@@ -178,7 +167,6 @@ export class SecuritySystem implements AccessoryPlugin {
|
|
|
178
167
|
this.stateHandler.logMode('Default', this.state.defaultState);
|
|
179
168
|
this.log.info(`Arm delay (${this.options.armSeconds}s)`);
|
|
180
169
|
this.log.info(`Trigger delay (${this.options.triggerSeconds}s)`);
|
|
181
|
-
this.log.info(`Audio (${this.options.audio ? 'Enabled' : 'Disabled'})`);
|
|
182
170
|
if (this.options.proxyMode) {
|
|
183
171
|
this.log.info('Proxy mode (Enabled)');
|
|
184
172
|
}
|
|
@@ -18,7 +18,6 @@ export class ConfigurationService {
|
|
|
18
18
|
this.options = this.parse(raw);
|
|
19
19
|
this.validate(this.options);
|
|
20
20
|
this.normalize(this.options);
|
|
21
|
-
this.warnDeprecations(this.options);
|
|
22
21
|
log.info('Options', JSON.stringify(this.options));
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -63,8 +62,6 @@ export class ConfigurationService {
|
|
|
63
62
|
siren_switch: 'trip_switch',
|
|
64
63
|
siren_override_switch: 'trip_override_switch',
|
|
65
64
|
siren_mode_switches: 'trip_mode_switches',
|
|
66
|
-
siren_sensor: 'triggered_sensor',
|
|
67
|
-
siren_sensor_seconds: 'triggered_sensor_seconds',
|
|
68
65
|
};
|
|
69
66
|
|
|
70
67
|
for (const [oldKey, newKey] of Object.entries(renames)) {
|
|
@@ -101,7 +98,6 @@ export class ConfigurationService {
|
|
|
101
98
|
modeOffSwitchName: this.str(raw, 'mode_off_switch_name') ?? DEFAULTS.MODE_OFF_SWITCH_NAME,
|
|
102
99
|
modeAwayExtendedSwitchName: this.str(raw, 'mode_away_extended_switch_name') ?? DEFAULTS.MODE_AWAY_EXTENDED_SWITCH_NAME,
|
|
103
100
|
modePauseSwitchName: this.str(raw, 'mode_pause_switch_name') ?? DEFAULTS.MODE_PAUSE_SWITCH_NAME,
|
|
104
|
-
audioSwitchName: this.str(raw, 'audio_switch_name') ?? DEFAULTS.AUDIO_SWITCH_NAME,
|
|
105
101
|
|
|
106
102
|
// Behaviour toggles
|
|
107
103
|
overrideOff: this.bool(raw, 'override_off', false),
|
|
@@ -131,8 +127,6 @@ export class ConfigurationService {
|
|
|
131
127
|
armingMotionSensor: this.bool(raw, 'arming_sensor', false),
|
|
132
128
|
trippedMotionSensor: this.bool(raw, 'tripped_sensor', false),
|
|
133
129
|
trippedMotionSensorSeconds: this.num(raw, 'tripped_sensor_seconds') ?? DEFAULTS.TRIPPED_SENSOR_SECONDS,
|
|
134
|
-
triggeredMotionSensor: this.bool(raw, 'triggered_sensor', false),
|
|
135
|
-
triggeredMotionSensorSeconds: this.num(raw, 'triggered_sensor_seconds') ?? DEFAULTS.TRIGGERED_SENSOR_SECONDS,
|
|
136
130
|
resetSensor: this.bool(raw, 'reset_sensor', false),
|
|
137
131
|
|
|
138
132
|
// Mode switches
|
|
@@ -151,17 +145,6 @@ export class ConfigurationService {
|
|
|
151
145
|
awayDoubleKnockSeconds: this.num(raw, 'away_double_knock_seconds'),
|
|
152
146
|
nightDoubleKnockSeconds: this.num(raw, 'night_double_knock_seconds'),
|
|
153
147
|
|
|
154
|
-
// Audio
|
|
155
|
-
audio: this.bool(raw, 'audio', false),
|
|
156
|
-
audioPath: this.str(raw, 'audio_path'),
|
|
157
|
-
audioLanguage: this.str(raw, 'audio_language') ?? DEFAULTS.AUDIO_LANGUAGE,
|
|
158
|
-
audioVolume: this.num(raw, 'audio_volume'),
|
|
159
|
-
audioArmingLooped: this.bool(raw, 'audio_arming_looped', false),
|
|
160
|
-
audioAlertLooped: this.bool(raw, 'audio_alert_looped', false),
|
|
161
|
-
audioExtraVariables: Array.isArray(raw.audio_extra_variables)
|
|
162
|
-
? (raw.audio_extra_variables as { key: string; value: string }[])
|
|
163
|
-
: [],
|
|
164
|
-
|
|
165
148
|
// Custom trip mode switches
|
|
166
149
|
tripHomeSwitches: Array.isArray(raw.trip_home_switches)
|
|
167
150
|
? (raw.trip_home_switches as { label: string }[])
|
|
@@ -172,7 +155,6 @@ export class ConfigurationService {
|
|
|
172
155
|
tripNightSwitches: Array.isArray(raw.trip_night_switches)
|
|
173
156
|
? (raw.trip_night_switches as { label: string }[])
|
|
174
157
|
: [],
|
|
175
|
-
audioSwitch: this.bool(raw, 'audio_switch', false),
|
|
176
158
|
|
|
177
159
|
// Server
|
|
178
160
|
serverPort: this.num(raw, 'server_port'),
|
|
@@ -229,21 +211,6 @@ export class ConfigurationService {
|
|
|
229
211
|
}
|
|
230
212
|
}
|
|
231
213
|
|
|
232
|
-
// ── Post-parse deprecation warnings ─────────────────────────────────────────
|
|
233
|
-
|
|
234
|
-
private warnDeprecations(opts: SecuritySystemOptions): void {
|
|
235
|
-
const audioConfigured = opts.audio || opts.audioPath !== null || opts.audioSwitch ||
|
|
236
|
-
opts.audioVolume !== null || opts.audioArmingLooped || opts.audioAlertLooped ||
|
|
237
|
-
opts.audioExtraVariables.length > 0;
|
|
238
|
-
if (audioConfigured) {
|
|
239
|
-
this.log.warn('Config: audio playback is deprecated, use command hooks (command_current_*) to play audio instead.');
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (opts.triggeredMotionSensor) {
|
|
243
|
-
this.log.warn('Config: the triggered sensor is deprecated, Apple already provides emergency alerts for security system accessories.');
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
214
|
// ── Post-parse normalisation ────────────────────────────────────────────────
|
|
248
215
|
|
|
249
216
|
private normalize(opts: SecuritySystemOptions): void {
|
|
@@ -3,7 +3,7 @@ import { EventType } from '../types/event-type.js';
|
|
|
3
3
|
import type { EventPayloadMap } from '../types/event-payload-map-type.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Typed event bus used to decouple side-effect services (
|
|
6
|
+
* Typed event bus used to decouple side-effect services (commands,
|
|
7
7
|
* webhooks, storage) from the core state-machine handlers.
|
|
8
8
|
*/
|
|
9
9
|
export class EventBusService extends EventEmitter {
|
|
@@ -5,7 +5,6 @@ import type { SystemState } from '../interfaces/system-state-interface.js';
|
|
|
5
5
|
import type { SecuritySystemOptions } from '../interfaces/options-interface.js';
|
|
6
6
|
import type { ServiceRegistry } from '../interfaces/service-registry-interface.js';
|
|
7
7
|
import type { StorageService } from '../services/storage-service.js';
|
|
8
|
-
import type { AudioService } from '../services/audio-service.js';
|
|
9
8
|
import { EventType } from '../types/event-type.js';
|
|
10
9
|
|
|
11
10
|
// ── Minimal mocks ─────────────────────────────────────────────────────────────
|
|
@@ -37,8 +36,8 @@ function makeServices(): ServiceRegistry {
|
|
|
37
36
|
'armingLockSwitchService', 'armingLockHomeSwitchService', 'armingLockAwaySwitchService',
|
|
38
37
|
'armingLockNightSwitchService', 'modeHomeSwitchService', 'modeAwaySwitchService',
|
|
39
38
|
'modeNightSwitchService', 'modeOffSwitchService', 'modeAwayExtendedSwitchService',
|
|
40
|
-
'modePauseSwitchService', '
|
|
41
|
-
'trippedMotionSensorService', '
|
|
39
|
+
'modePauseSwitchService', 'armingMotionSensorService',
|
|
40
|
+
'trippedMotionSensorService', 'triggeredResetMotionSensorService',
|
|
42
41
|
];
|
|
43
42
|
for (const k of keys) {
|
|
44
43
|
s[k] = makeMockService();
|
|
@@ -57,7 +56,6 @@ function makeState(overrides: Partial<SystemState> = {}): SystemState {
|
|
|
57
56
|
isKnocked: false,
|
|
58
57
|
serverAuthenticationAttempts: 0,
|
|
59
58
|
pausedCurrentState: null,
|
|
60
|
-
audioProcess: null,
|
|
61
59
|
...overrides,
|
|
62
60
|
};
|
|
63
61
|
}
|
|
@@ -79,8 +77,6 @@ function makeOptions(overrides: Partial<SecuritySystemOptions> = {}): SecuritySy
|
|
|
79
77
|
homeTriggerSeconds: null,
|
|
80
78
|
awayTriggerSeconds: null,
|
|
81
79
|
nightTriggerSeconds: null,
|
|
82
|
-
triggeredMotionSensor: false,
|
|
83
|
-
triggeredMotionSensorSeconds: 5,
|
|
84
80
|
trippedMotionSensor: false,
|
|
85
81
|
trippedMotionSensorSeconds: 5,
|
|
86
82
|
resetOffFlow: false,
|
|
@@ -96,10 +92,6 @@ function makeStorage() {
|
|
|
96
92
|
return { save: vi.fn(), load: vi.fn(), init: vi.fn() } as unknown as StorageService;
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
function makeAudio() {
|
|
100
|
-
return { play: vi.fn(), stop: vi.fn(), attachToBus: vi.fn() } as unknown as AudioService;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
95
|
function makeTimers() {
|
|
104
96
|
return {
|
|
105
97
|
setArmTimer: vi.fn(), clearArmTimer: vi.fn(),
|
|
@@ -108,7 +100,6 @@ function makeTimers() {
|
|
|
108
100
|
setDoubleKnockTimer: vi.fn(), clearDoubleKnockTimer: vi.fn(),
|
|
109
101
|
setResetTimer: vi.fn(), clearResetTimer: vi.fn(),
|
|
110
102
|
setTrippedInterval: vi.fn(), clearTrippedInterval: vi.fn(),
|
|
111
|
-
setTriggeredInterval: vi.fn(), clearTriggeredInterval: vi.fn(),
|
|
112
103
|
clearAll: vi.fn(),
|
|
113
104
|
} as any;
|
|
114
105
|
}
|
|
@@ -118,9 +109,6 @@ function makeMockSensor() {
|
|
|
118
109
|
resetArmingMotionSensor: vi.fn(),
|
|
119
110
|
setTrippedMotionSensor: vi.fn(),
|
|
120
111
|
resetTrippedMotionSensor: vi.fn(),
|
|
121
|
-
pulseTriggeredMotionSensor: vi.fn(),
|
|
122
|
-
setTriggeredMotionSensor: vi.fn(),
|
|
123
|
-
resetTriggeredMotionSensor: vi.fn(),
|
|
124
112
|
pulseResetMotionSensor: vi.fn(),
|
|
125
113
|
updateArmingMotionSensor: vi.fn(),
|
|
126
114
|
};
|
|
@@ -144,7 +132,7 @@ describe('StateHandler.getArmingSeconds', async () => {
|
|
|
144
132
|
const bus = new EventBusService();
|
|
145
133
|
|
|
146
134
|
const sensor = makeMockSensor() as any;
|
|
147
|
-
stateHandler = new StateHandler(services, state, options, {} as any, log as any, bus, makeStorage(),
|
|
135
|
+
stateHandler = new StateHandler(services, state, options, {} as any, log as any, bus, makeStorage(), makeTimers(), sensor);
|
|
148
136
|
});
|
|
149
137
|
|
|
150
138
|
it('returns 0 when current state is TRIGGERED', () => {
|
|
@@ -175,7 +163,7 @@ describe('StateHandler.updateTargetState', async () => {
|
|
|
175
163
|
const bus = new EventBusService();
|
|
176
164
|
const sensor = makeMockSensor() as any;
|
|
177
165
|
const timers = makeTimers();
|
|
178
|
-
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(),
|
|
166
|
+
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(), timers, sensor);
|
|
179
167
|
|
|
180
168
|
const result = handler.updateTargetState(SecurityState.HOME, OriginType.INTERNAL, 0);
|
|
181
169
|
expect(result.success).toBe(true);
|
|
@@ -188,7 +176,7 @@ describe('StateHandler.updateTargetState', async () => {
|
|
|
188
176
|
const bus = new EventBusService();
|
|
189
177
|
const sensor = makeMockSensor() as any;
|
|
190
178
|
const timers = makeTimers();
|
|
191
|
-
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(),
|
|
179
|
+
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(), timers, sensor);
|
|
192
180
|
|
|
193
181
|
const result = handler.updateTargetState(SecurityState.HOME, OriginType.EXTERNAL, 0);
|
|
194
182
|
expect(result.success).toBe(true);
|
|
@@ -203,7 +191,7 @@ describe('StateHandler.updateTargetState', async () => {
|
|
|
203
191
|
const bus = new EventBusService();
|
|
204
192
|
const sensor = makeMockSensor() as any;
|
|
205
193
|
const timers = makeTimers();
|
|
206
|
-
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(),
|
|
194
|
+
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(), timers, sensor);
|
|
207
195
|
|
|
208
196
|
const result = handler.updateTargetState(SecurityState.HOME, OriginType.EXTERNAL, 0);
|
|
209
197
|
expect(result.success).toBe(true);
|
|
@@ -216,7 +204,7 @@ describe('StateHandler.updateTargetState', async () => {
|
|
|
216
204
|
const log = makeMockLog();
|
|
217
205
|
const bus = new EventBusService();
|
|
218
206
|
const sensor = makeMockSensor() as any;
|
|
219
|
-
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(),
|
|
207
|
+
const handler = new StateHandler(makeServices(), state, makeOptions(), {} as any, log as any, bus, makeStorage(), makeTimers(), sensor);
|
|
220
208
|
|
|
221
209
|
const result = handler.updateTargetState(SecurityState.HOME, OriginType.REGULAR_SWITCH, 0);
|
|
222
210
|
expect(result.success).toBe(true);
|
|
@@ -240,7 +228,7 @@ describe('StateHandler.setCurrentState - RESET_TRIP_SWITCHES', async () => {
|
|
|
240
228
|
|
|
241
229
|
const handler = new StateHandler(
|
|
242
230
|
makeServices(), state, makeOptions(), {} as any,
|
|
243
|
-
makeMockLog() as any, bus, makeStorage(),
|
|
231
|
+
makeMockLog() as any, bus, makeStorage(),
|
|
244
232
|
makeTimers(), makeMockSensor() as any,
|
|
245
233
|
);
|
|
246
234
|
|
|
@@ -257,7 +245,7 @@ describe('StateHandler.setCurrentState - RESET_TRIP_SWITCHES', async () => {
|
|
|
257
245
|
|
|
258
246
|
const handler = new StateHandler(
|
|
259
247
|
makeServices(), state, makeOptions(), {} as any,
|
|
260
|
-
makeMockLog() as any, bus, makeStorage(),
|
|
248
|
+
makeMockLog() as any, bus, makeStorage(),
|
|
261
249
|
makeTimers(), makeMockSensor() as any,
|
|
262
250
|
);
|
|
263
251
|
|
|
@@ -279,7 +267,7 @@ describe('StateHandler.updateTargetState - isTripping reset', async () => {
|
|
|
279
267
|
const state = makeState({ currentState: SecurityState.HOME, isTripping: true });
|
|
280
268
|
const handler = new StateHandler(
|
|
281
269
|
makeServices(), state, makeOptions(), {} as any,
|
|
282
|
-
makeMockLog() as any, new EventBusService(), makeStorage(),
|
|
270
|
+
makeMockLog() as any, new EventBusService(), makeStorage(),
|
|
283
271
|
makeTimers(), makeMockSensor() as any,
|
|
284
272
|
);
|
|
285
273
|
|
|
@@ -296,7 +284,7 @@ describe('StateHandler.updateTargetState - isTripping reset', async () => {
|
|
|
296
284
|
});
|
|
297
285
|
const handler = new StateHandler(
|
|
298
286
|
makeServices(), state, makeOptions(), {} as any,
|
|
299
|
-
makeMockLog() as any, new EventBusService(), makeStorage(),
|
|
287
|
+
makeMockLog() as any, new EventBusService(), makeStorage(),
|
|
300
288
|
makeTimers(), makeMockSensor() as any,
|
|
301
289
|
);
|
|
302
290
|
|
|
@@ -306,51 +294,12 @@ describe('StateHandler.updateTargetState - isTripping reset', async () => {
|
|
|
306
294
|
});
|
|
307
295
|
});
|
|
308
296
|
|
|
309
|
-
// ──
|
|
297
|
+
// ── Tripped sensor reset on TRIGGERED ────────────────────────────────────────
|
|
310
298
|
|
|
311
|
-
describe('StateHandler.setCurrentState -
|
|
299
|
+
describe('StateHandler.setCurrentState - tripped sensor reset', async () => {
|
|
312
300
|
const { StateHandler } = await import('../handlers/state-handler.js');
|
|
313
301
|
const { EventBusService } = await import('../services/event-bus-service.js');
|
|
314
302
|
|
|
315
|
-
it('starts triggered sensor steady-on when triggeredMotionSensorSeconds = 0', () => {
|
|
316
|
-
const state = makeState({ currentState: SecurityState.NIGHT });
|
|
317
|
-
const bus = new EventBusService();
|
|
318
|
-
const sensor = makeMockSensor() as any;
|
|
319
|
-
const timers = makeTimers();
|
|
320
|
-
|
|
321
|
-
const handler = new StateHandler(
|
|
322
|
-
makeServices(), state,
|
|
323
|
-
makeOptions({ triggeredMotionSensor: true, triggeredMotionSensorSeconds: 0 }),
|
|
324
|
-
{} as any, makeMockLog() as any, bus, makeStorage(), makeAudio(),
|
|
325
|
-
timers, sensor,
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
handler.setCurrentState(SecurityState.TRIGGERED, OriginType.EXTERNAL);
|
|
329
|
-
|
|
330
|
-
expect(sensor.setTriggeredMotionSensor).toHaveBeenCalledWith(true);
|
|
331
|
-
expect(sensor.pulseTriggeredMotionSensor).not.toHaveBeenCalled();
|
|
332
|
-
expect(timers.setTriggeredInterval).not.toHaveBeenCalled();
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('pulses triggered sensor with interval when triggeredMotionSensorSeconds > 0', () => {
|
|
336
|
-
const state = makeState({ currentState: SecurityState.NIGHT });
|
|
337
|
-
const bus = new EventBusService();
|
|
338
|
-
const sensor = makeMockSensor() as any;
|
|
339
|
-
const timers = makeTimers();
|
|
340
|
-
|
|
341
|
-
const handler = new StateHandler(
|
|
342
|
-
makeServices(), state,
|
|
343
|
-
makeOptions({ triggeredMotionSensor: true, triggeredMotionSensorSeconds: 10 }),
|
|
344
|
-
{} as any, makeMockLog() as any, bus, makeStorage(), makeAudio(),
|
|
345
|
-
timers, sensor,
|
|
346
|
-
);
|
|
347
|
-
|
|
348
|
-
handler.setCurrentState(SecurityState.TRIGGERED, OriginType.EXTERNAL);
|
|
349
|
-
|
|
350
|
-
expect(timers.setTriggeredInterval).toHaveBeenCalledWith(10000, expect.any(Function));
|
|
351
|
-
expect(sensor.setTriggeredMotionSensor).not.toHaveBeenCalled();
|
|
352
|
-
});
|
|
353
|
-
|
|
354
303
|
it('resets tripped motion sensor when entering TRIGGERED', () => {
|
|
355
304
|
const state = makeState({ currentState: SecurityState.NIGHT });
|
|
356
305
|
const bus = new EventBusService();
|
|
@@ -358,7 +307,7 @@ describe('StateHandler.setCurrentState - triggered motion sensor', async () => {
|
|
|
358
307
|
|
|
359
308
|
const handler = new StateHandler(
|
|
360
309
|
makeServices(), state, makeOptions(), {} as any,
|
|
361
|
-
makeMockLog() as any, bus, makeStorage(),
|
|
310
|
+
makeMockLog() as any, bus, makeStorage(),
|
|
362
311
|
makeTimers(), sensor,
|
|
363
312
|
);
|
|
364
313
|
|
|
@@ -36,8 +36,8 @@ function makeServices(): ServiceRegistry {
|
|
|
36
36
|
'armingLockSwitchService', 'armingLockHomeSwitchService', 'armingLockAwaySwitchService',
|
|
37
37
|
'armingLockNightSwitchService', 'modeHomeSwitchService', 'modeAwaySwitchService',
|
|
38
38
|
'modeNightSwitchService', 'modeOffSwitchService', 'modeAwayExtendedSwitchService',
|
|
39
|
-
'modePauseSwitchService', '
|
|
40
|
-
'trippedMotionSensorService', '
|
|
39
|
+
'modePauseSwitchService', 'armingMotionSensorService',
|
|
40
|
+
'trippedMotionSensorService', 'triggeredResetMotionSensorService',
|
|
41
41
|
];
|
|
42
42
|
const registry: Record<string, ReturnType<typeof makeMockService> | unknown[]> = {};
|
|
43
43
|
for (const key of keys) {
|
|
@@ -60,7 +60,6 @@ function makeState(overrides: Partial<SystemState> = {}): SystemState {
|
|
|
60
60
|
isKnocked: false,
|
|
61
61
|
serverAuthenticationAttempts: 0,
|
|
62
62
|
pausedCurrentState: null,
|
|
63
|
-
audioProcess: null,
|
|
64
63
|
...overrides,
|
|
65
64
|
};
|
|
66
65
|
}
|
|
@@ -90,8 +89,6 @@ function makeOptions(overrides: Partial<SecuritySystemOptions> = {}): SecuritySy
|
|
|
90
89
|
homeArmSeconds: null,
|
|
91
90
|
awayArmSeconds: null,
|
|
92
91
|
nightArmSeconds: null,
|
|
93
|
-
triggeredMotionSensor: false,
|
|
94
|
-
triggeredMotionSensorSeconds: 5,
|
|
95
92
|
trippedMotionSensor: false,
|
|
96
93
|
trippedMotionSensorSeconds: 5,
|
|
97
94
|
resetOffFlow: false,
|
|
@@ -118,7 +115,6 @@ function makeMockTimers() {
|
|
|
118
115
|
setDoubleKnockTimer: vi.fn(), clearDoubleKnockTimer: vi.fn(),
|
|
119
116
|
setResetTimer: vi.fn(), clearResetTimer: vi.fn(),
|
|
120
117
|
setTrippedInterval: vi.fn(), clearTrippedInterval: vi.fn(),
|
|
121
|
-
setTriggeredInterval: vi.fn(), clearTriggeredInterval: vi.fn(),
|
|
122
118
|
clearAll: vi.fn(),
|
|
123
119
|
} as any;
|
|
124
120
|
}
|
|
@@ -34,8 +34,8 @@ function makeServices(): ServiceRegistry {
|
|
|
34
34
|
'armingLockHomeSwitchService', 'armingLockAwaySwitchService', 'armingLockNightSwitchService',
|
|
35
35
|
'modeHomeSwitchService', 'modeAwaySwitchService', 'modeNightSwitchService',
|
|
36
36
|
'modeOffSwitchService', 'modeAwayExtendedSwitchService', 'modePauseSwitchService',
|
|
37
|
-
'
|
|
38
|
-
'
|
|
37
|
+
'armingMotionSensorService', 'trippedMotionSensorService',
|
|
38
|
+
'triggeredResetMotionSensorService', 'accessoryInfoService',
|
|
39
39
|
];
|
|
40
40
|
const s: Record<string, ReturnType<typeof makeMockService> | unknown[]> = {};
|
|
41
41
|
for (const k of keys) {
|
|
@@ -58,7 +58,6 @@ function makeState(overrides: Partial<SystemState> = {}): SystemState {
|
|
|
58
58
|
isKnocked: false,
|
|
59
59
|
serverAuthenticationAttempts: 0,
|
|
60
60
|
pausedCurrentState: null,
|
|
61
|
-
audioProcess: null,
|
|
62
61
|
...overrides,
|
|
63
62
|
};
|
|
64
63
|
}
|
|
@@ -98,7 +97,6 @@ describe('TripHandler', async () => {
|
|
|
98
97
|
setTrippedMotionSensor: vi.fn(),
|
|
99
98
|
resetTrippedMotionSensor: vi.fn(),
|
|
100
99
|
};
|
|
101
|
-
const mockAudio = { stop: vi.fn(), play: vi.fn(), attachToBus: vi.fn() };
|
|
102
100
|
const mockTimers = {
|
|
103
101
|
setTriggerTimer: vi.fn(), clearTriggerTimer: vi.fn(), isTriggerRunning: vi.fn().mockReturnValue(false),
|
|
104
102
|
setTrippedInterval: vi.fn(), clearTrippedInterval: vi.fn(),
|
|
@@ -112,7 +110,7 @@ describe('TripHandler', async () => {
|
|
|
112
110
|
services = makeServices();
|
|
113
111
|
bus = new EventBusService();
|
|
114
112
|
const mockLog = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
|
|
115
|
-
tripHandler = new TripHandler(services, state, makeOptions(), {} as any, mockLog as any, bus,
|
|
113
|
+
tripHandler = new TripHandler(services, state, makeOptions(), {} as any, mockLog as any, bus, mockSensorHandler as any, mockTimers);
|
|
116
114
|
});
|
|
117
115
|
|
|
118
116
|
it('blocks trip when system is disarmed (not overriding)', () => {
|
|
@@ -156,7 +154,7 @@ describe('TripHandler', async () => {
|
|
|
156
154
|
services, state,
|
|
157
155
|
makeOptions({ trippedMotionSensor: true, trippedMotionSensorSeconds: 0 }),
|
|
158
156
|
{} as any, { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() } as any,
|
|
159
|
-
bus,
|
|
157
|
+
bus, mockSensorHandler as any, mockTimers,
|
|
160
158
|
);
|
|
161
159
|
|
|
162
160
|
handler.updateTripSwitch(true, OriginType.REGULAR_SWITCH, false);
|
|
@@ -171,7 +169,7 @@ describe('TripHandler', async () => {
|
|
|
171
169
|
services, state,
|
|
172
170
|
makeOptions({ trippedMotionSensor: true, trippedMotionSensorSeconds: 10 }),
|
|
173
171
|
{} as any, { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() } as any,
|
|
174
|
-
bus,
|
|
172
|
+
bus, mockSensorHandler as any, mockTimers,
|
|
175
173
|
);
|
|
176
174
|
|
|
177
175
|
handler.updateTripSwitch(true, OriginType.REGULAR_SWITCH, false);
|
|
@@ -186,7 +184,7 @@ describe('TripHandler', async () => {
|
|
|
186
184
|
services, state,
|
|
187
185
|
makeOptions({ trippedMotionSensor: true }),
|
|
188
186
|
{} as any, { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() } as any,
|
|
189
|
-
bus,
|
|
187
|
+
bus, mockSensorHandler as any, mockTimers,
|
|
190
188
|
);
|
|
191
189
|
|
|
192
190
|
handler.updateTripSwitch(false, OriginType.REGULAR_SWITCH, false);
|
|
@@ -195,13 +193,12 @@ describe('TripHandler', async () => {
|
|
|
195
193
|
});
|
|
196
194
|
});
|
|
197
195
|
|
|
198
|
-
it('cancels trip and
|
|
196
|
+
it('cancels trip and emits TRIP_CANCELLED', () => {
|
|
199
197
|
const emitted: unknown[] = [];
|
|
200
198
|
bus.on(EventType.TRIP_CANCELLED, (payload) => emitted.push(payload));
|
|
201
199
|
|
|
202
200
|
tripHandler.updateTripSwitch(false, OriginType.REGULAR_SWITCH, false);
|
|
203
201
|
|
|
204
|
-
expect(mockAudio.stop).toHaveBeenCalled();
|
|
205
202
|
expect(emitted).toHaveLength(1);
|
|
206
203
|
});
|
|
207
204
|
|
|
@@ -333,7 +330,6 @@ describe('TripHandler', async () => {
|
|
|
333
330
|
state.currentState = SecurityState.HOME;
|
|
334
331
|
const result = tripHandler.triggerIfModeSet(SecurityState.HOME, false);
|
|
335
332
|
expect(result.success).toBe(true);
|
|
336
|
-
expect(mockAudio.stop).toHaveBeenCalled();
|
|
337
333
|
});
|
|
338
334
|
|
|
339
335
|
it('resetTripSwitches includes custom trip switch services', () => {
|
|
@@ -15,7 +15,6 @@ export class TimerManager {
|
|
|
15
15
|
private doubleKnockTimer: TimerHandle = null;
|
|
16
16
|
private resetTimer: TimerHandle = null;
|
|
17
17
|
private trippedInterval: IntervalHandle = null;
|
|
18
|
-
private triggeredInterval: IntervalHandle = null;
|
|
19
18
|
|
|
20
19
|
constructor(private readonly log: Logging) {}
|
|
21
20
|
|
|
@@ -128,28 +127,12 @@ export class TimerManager {
|
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
|
|
131
|
-
// ── Triggered motion sensor interval ─���─────────────────────────────────────
|
|
132
|
-
|
|
133
|
-
setTriggeredInterval(ms: number, cb: () => void): void {
|
|
134
|
-
this.clearTriggeredInterval();
|
|
135
|
-
this.triggeredInterval = setInterval(cb, ms);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
clearTriggeredInterval(): void {
|
|
139
|
-
if (this.triggeredInterval) {
|
|
140
|
-
clearInterval(this.triggeredInterval);
|
|
141
|
-
this.triggeredInterval = null;
|
|
142
|
-
this.log.debug('Triggered interval (Cleared)');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
130
|
// ── Bulk clear ─────────────────────────────────────────────────────────────
|
|
147
131
|
|
|
148
132
|
/** Clears every active timer and interval. */
|
|
149
133
|
clearAll(): void {
|
|
150
134
|
this.clearTriggerTimer();
|
|
151
135
|
this.clearArmTimer();
|
|
152
|
-
this.clearTriggeredInterval();
|
|
153
136
|
this.clearTrippedInterval();
|
|
154
137
|
this.clearDoubleKnockTimer();
|
|
155
138
|
this.clearPauseTimer();
|
package/src/types/mode-type.ts
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ConditionContext } from '../interfaces/condition-context-interface.js';
|
|
2
|
-
import { Condition } from './condition.js';
|
|
3
|
-
/**
|
|
4
|
-
* Blocks a new trip activation when the alarm has already been triggered.
|
|
5
|
-
* Prevents stacking multiple trigger events on an active alarm.
|
|
6
|
-
*/
|
|
7
|
-
export declare class AlreadyTriggeredCondition extends Condition {
|
|
8
|
-
readonly name = "already-triggered";
|
|
9
|
-
evaluate({ state, value, log }: ConditionContext): boolean;
|
|
10
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SecurityState } from '../types/security-state-type.js';
|
|
2
|
-
import { Condition } from './condition.js';
|
|
3
|
-
/**
|
|
4
|
-
* Blocks a new trip activation when the alarm has already been triggered.
|
|
5
|
-
* Prevents stacking multiple trigger events on an active alarm.
|
|
6
|
-
*/
|
|
7
|
-
export class AlreadyTriggeredCondition extends Condition {
|
|
8
|
-
name = 'already-triggered';
|
|
9
|
-
evaluate({ state, value, log }) {
|
|
10
|
-
this.clearFailureReason();
|
|
11
|
-
if (!value) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const blocked = state.currentState === SecurityState.TRIGGERED;
|
|
15
|
-
if (blocked) {
|
|
16
|
-
this._failureReason = 'Security System (Already triggered): alarm is already active';
|
|
17
|
-
log.warn(this._failureReason);
|
|
18
|
-
}
|
|
19
|
-
return blocked;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=already-triggered-condition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"already-triggered-condition.js","sourceRoot":"","sources":["../../src/conditions/already-triggered-condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAC7C,IAAI,GAAG,mBAAmB,CAAC;IAEpC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAoB;QAC9C,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,KAAK,aAAa,CAAC,SAAS,CAAC;QAC/D,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,cAAc,GAAG,8DAA8D,CAAC;YACrF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ConditionContext } from '../interfaces/condition-context-interface.js';
|
|
2
|
-
import { Condition } from './condition.js';
|
|
3
|
-
/**
|
|
4
|
-
* Blocks a trip action while the arm delay countdown is still running.
|
|
5
|
-
* Prevents an intruder from tripping the system before it has fully armed.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ArmingInProgressCondition extends Condition {
|
|
8
|
-
readonly name = "arming-in-progress";
|
|
9
|
-
evaluate({ state, value, log }: ConditionContext): boolean;
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Condition } from './condition.js';
|
|
2
|
-
/**
|
|
3
|
-
* Blocks a trip action while the arm delay countdown is still running.
|
|
4
|
-
* Prevents an intruder from tripping the system before it has fully armed.
|
|
5
|
-
*/
|
|
6
|
-
export class ArmingInProgressCondition extends Condition {
|
|
7
|
-
name = 'arming-in-progress';
|
|
8
|
-
evaluate({ state, value, log }) {
|
|
9
|
-
this.clearFailureReason();
|
|
10
|
-
if (!value) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (state.isArming) {
|
|
14
|
-
this._failureReason = 'Trip Switch (Still arming): arm delay countdown is still in progress';
|
|
15
|
-
log.warn(this._failureReason);
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=arming-in-progress-condition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arming-in-progress-condition.js","sourceRoot":"","sources":["../../src/conditions/arming-in-progress-condition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAC7C,IAAI,GAAG,oBAAoB,CAAC;IAErC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAoB;QAC9C,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,cAAc,GAAG,sEAAsE,CAAC;YAC7F,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ConditionContext } from '../interfaces/condition-context-interface.js';
|
|
2
|
-
import type { CharacteristicConstructor } from '../interfaces/hap-types-interface.js';
|
|
3
|
-
import { Condition } from './condition.js';
|
|
4
|
-
/**
|
|
5
|
-
* Blocks arming when an arming-lock switch (global or mode-specific) is active.
|
|
6
|
-
* Does NOT block disarming.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ArmingLockCondition extends Condition {
|
|
9
|
-
private readonly Characteristic;
|
|
10
|
-
readonly name = "arming-lock";
|
|
11
|
-
constructor(Characteristic: CharacteristicConstructor);
|
|
12
|
-
evaluate({ state, services, options }: ConditionContext): boolean;
|
|
13
|
-
}
|