homebridge-securitysystem 12.0.0-beta.2 → 13.0.0-beta.1
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/AGENTS.md +55 -24
- package/CHANGELOG.md +29 -0
- package/config.schema.json +1 -145
- package/dist/constants/default-constant.d.ts +0 -3
- package/dist/constants/default-constant.js +0 -3
- package/dist/constants/default-constant.js.map +1 -1
- package/dist/constants/switch-uuid-constant.d.ts +0 -2
- package/dist/constants/switch-uuid-constant.js +0 -2
- package/dist/constants/switch-uuid-constant.js.map +1 -1
- package/dist/handlers/sensor-handler.d.ts +0 -3
- package/dist/handlers/sensor-handler.js +0 -15
- package/dist/handlers/sensor-handler.js.map +1 -1
- package/dist/handlers/state-handler.d.ts +1 -4
- package/dist/handlers/state-handler.js +1 -15
- package/dist/handlers/state-handler.js.map +1 -1
- package/dist/handlers/trip-handler.d.ts +1 -3
- package/dist/handlers/trip-handler.js +1 -4
- package/dist/handlers/trip-handler.js.map +1 -1
- package/dist/homekit/homekit-registrar.js +1 -5
- package/dist/homekit/homekit-registrar.js.map +1 -1
- package/dist/homekit/service-factory.js +0 -10
- package/dist/homekit/service-factory.js.map +1 -1
- package/dist/interfaces/options-interface.d.ts +0 -16
- package/dist/interfaces/service-registry-interface.d.ts +0 -2
- package/dist/interfaces/system-state-interface.d.ts +0 -2
- package/dist/security-system.d.ts +0 -1
- package/dist/security-system.js +2 -11
- package/dist/security-system.js.map +1 -1
- package/dist/services/configuration-service.d.ts +0 -1
- package/dist/services/configuration-service.js +0 -29
- package/dist/services/configuration-service.js.map +1 -1
- package/dist/services/event-bus-service.d.ts +1 -1
- package/dist/services/event-bus-service.js +1 -1
- package/dist/tests/conditions.test.js +0 -1
- package/dist/tests/conditions.test.js.map +1 -1
- package/dist/tests/mqtt-service.test.js +0 -1
- package/dist/tests/mqtt-service.test.js.map +1 -1
- package/dist/tests/server-service.test.js +0 -1
- package/dist/tests/server-service.test.js.map +1 -1
- package/dist/tests/state-handler.test.js +14 -45
- package/dist/tests/state-handler.test.js.map +1 -1
- package/dist/tests/switch-handler.test.js +2 -6
- package/dist/tests/switch-handler.test.js.map +1 -1
- package/dist/tests/trip-handler.test.js +7 -11
- package/dist/tests/trip-handler.test.js.map +1 -1
- package/dist/timers/timer-manager.d.ts +0 -3
- package/dist/timers/timer-manager.js +0 -14
- package/dist/timers/timer-manager.js.map +1 -1
- package/dist/types/mode-type.d.ts +1 -1
- 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/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/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/AGENTS.md
CHANGED
|
@@ -6,13 +6,14 @@ This document defines the architecture, naming conventions, and rules that all c
|
|
|
6
6
|
|
|
7
7
|
## Project Overview
|
|
8
8
|
|
|
9
|
-
`homebridge-securitysystem` is a Homebridge
|
|
9
|
+
`homebridge-securitysystem` is a Homebridge accessory plugin (not a platform plugin) that exposes a fully-featured security system to HomeKit. It is written in TypeScript with ESM modules.
|
|
10
10
|
|
|
11
11
|
The plugin:
|
|
12
|
-
- Exposes one `SecuritySystem` HAP service plus
|
|
13
|
-
- Uses an event-driven architecture: core state changes emit domain events; side-effect services (
|
|
12
|
+
- Exposes one `SecuritySystem` HAP service plus a configurable set of optional switch/sensor accessories (trip, mode, and arming-lock switches; motion sensors).
|
|
13
|
+
- Uses an event-driven architecture: core state changes emit domain events; side-effect services (webhook, command, MQTT) listen and react.
|
|
14
14
|
- Uses an abstract `Condition` class hierarchy to encapsulate all blocking-logic decisions.
|
|
15
|
-
- Provides an optional Hono HTTP server for remote control.
|
|
15
|
+
- Provides an optional Hono HTTP server (zod-validated routes with OpenAPI and Scalar docs) for remote control.
|
|
16
|
+
- Optionally publishes status updates over MQTT.
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
@@ -24,9 +25,12 @@ src/
|
|
|
24
25
|
conditions/ Abstract Condition base + concrete condition classes
|
|
25
26
|
constants/ Compile-time constants (no logic)
|
|
26
27
|
handlers/ Stateful handlers wired by security-system.ts
|
|
28
|
+
homekit/ HomeKit service construction + characteristic registration
|
|
27
29
|
interfaces/ TypeScript interfaces (plain object shapes)
|
|
28
|
-
|
|
30
|
+
schemas/ Zod schemas for HTTP server request/response validation
|
|
31
|
+
services/ Stateful services (webhook, command, MQTT, storage, server, event bus)
|
|
29
32
|
tests/ Vitest test suites
|
|
33
|
+
timers/ Centralised timer/interval ownership (TimerManager)
|
|
30
34
|
types/ TypeScript enums and type aliases
|
|
31
35
|
utils/ Pure utility functions
|
|
32
36
|
index.ts Homebridge plugin entry point
|
|
@@ -44,6 +48,9 @@ src/
|
|
|
44
48
|
| `constants/` | `const` objects, literal values | Logic, mutable state |
|
|
45
49
|
| `utils/` | Pure functions with no side effects | Classes, state, I/O |
|
|
46
50
|
| `conditions/` | Classes extending `Condition` | Handlers, services |
|
|
51
|
+
| `schemas/` | Zod schemas for HTTP validation | Logic, I/O |
|
|
52
|
+
| `timers/` | Timer/interval ownership (`TimerManager`) | Timer logic embedded in handlers |
|
|
53
|
+
| `homekit/` | HomeKit service construction, characteristic registration | State-machine logic |
|
|
47
54
|
| `services/` | Stateful singleton classes, I/O | Embedded types, enums, interfaces |
|
|
48
55
|
| `handlers/` | State-machine logic classes | Embedded types, enums, interfaces |
|
|
49
56
|
|
|
@@ -61,9 +68,13 @@ All filenames use **kebab-case** with a mandatory suffix describing their kind:
|
|
|
61
68
|
| Interface | `-interface.ts` | `system-state-interface.ts` |
|
|
62
69
|
| Constant object | `-constant.ts` | `homekit-constant.ts` |
|
|
63
70
|
| Utility functions | `-util.ts` | `state-util.ts` |
|
|
64
|
-
|
|
|
71
|
+
| Zod schema | `-schema.ts` | `error-schema.ts` |
|
|
72
|
+
| Service class | `-service.ts` | `webhook-service.ts` |
|
|
65
73
|
| Handler class | `-handler.ts` | `state-handler.ts` |
|
|
66
74
|
| Condition class | `-condition.ts` | `double-knock-condition.ts` |
|
|
75
|
+
| HomeKit registrar class | `-registrar.ts` | `homekit-registrar.ts` |
|
|
76
|
+
| Factory function | `-factory.ts` | `service-factory.ts` |
|
|
77
|
+
| Timer manager class | `-manager.ts` | `timer-manager.ts` |
|
|
67
78
|
| Test suite | `.test.ts` | `conditions.test.ts` |
|
|
68
79
|
|
|
69
80
|
---
|
|
@@ -109,7 +120,7 @@ Forbidden examples and their correct replacements:
|
|
|
109
120
|
### Class Names
|
|
110
121
|
|
|
111
122
|
- PascalCase, no abbreviations.
|
|
112
|
-
- Suffix matches the layer: `...Service`, `...Handler`, `...Condition`.
|
|
123
|
+
- Suffix matches the layer: `...Service`, `...Handler`, `...Condition`, `...Registrar`, `...Manager`.
|
|
113
124
|
|
|
114
125
|
### Enum Members
|
|
115
126
|
|
|
@@ -124,17 +135,17 @@ Forbidden examples and their correct replacements:
|
|
|
124
135
|
|
|
125
136
|
## Architecture: Event-Driven Side Effects
|
|
126
137
|
|
|
127
|
-
The core state machine (`StateHandler`, `TripHandler`, `SwitchHandler`) never calls side-effect services directly. Instead it emits domain events via `EventBusService`:
|
|
138
|
+
The core state machine (`StateHandler`, `TripHandler`, `SwitchHandler`) never calls the bus-attached side-effect services directly. Instead it emits domain events via `EventBusService`:
|
|
128
139
|
|
|
129
140
|
```
|
|
130
141
|
StateHandler → bus.emit(EventType.CURRENT_CHANGED, payload)
|
|
131
142
|
↓ ↓ ↓
|
|
132
|
-
|
|
143
|
+
WebhookService CommandService MqttService
|
|
133
144
|
```
|
|
134
145
|
|
|
135
|
-
|
|
146
|
+
`StorageService` is constructor-injected into the handlers that need it; `WebhookService`, `CommandService`, and `MqttService` are purely event-driven and call `attachToBus(bus)` during construction in `security-system.ts`.
|
|
136
147
|
|
|
137
|
-
**New side effects must follow this pattern** — never add direct calls from handlers to services.
|
|
148
|
+
**New side effects must follow this pattern** — never add direct calls from handlers to services. The MQTT client is disconnected on shutdown via an `api.on('shutdown', ...)` hook wired in `security-system.ts`.
|
|
138
149
|
|
|
139
150
|
Events and their payload types are defined in `src/types/event-type.ts`. The mapping from event to payload is in `src/types/event-payload-map-type.ts`.
|
|
140
151
|
|
|
@@ -147,24 +158,36 @@ All trip-blocking decisions use the `Condition` abstract base class:
|
|
|
147
158
|
```typescript
|
|
148
159
|
abstract class Condition {
|
|
149
160
|
abstract readonly name: string;
|
|
161
|
+
protected _failureReason: string | undefined;
|
|
162
|
+
get failureReason(): string | undefined;
|
|
163
|
+
protected clearFailureReason(): void;
|
|
150
164
|
abstract evaluate(context: ConditionContext): boolean;
|
|
151
165
|
}
|
|
152
166
|
```
|
|
153
167
|
|
|
154
|
-
`evaluate` returns `true` to **block** the action, `false` to **allow** it.
|
|
168
|
+
`evaluate` returns `true` to **block** the action, `false` to **allow** it. Implementations must call `this.clearFailureReason()` at the top of `evaluate()` and set `this._failureReason` before returning `true`; callers read it via `failureReason` to surface the blocking reason to the user.
|
|
155
169
|
|
|
156
|
-
|
|
170
|
+
The context is the `ConditionContext` interface in `src/interfaces/condition-context-interface.ts` (`state`, `services`, `options`, `value`, `origin`, `log`).
|
|
171
|
+
|
|
172
|
+
Conditions are instantiated once inside `TripHandler` and evaluated in order: `NotArmedCondition`, `ArmingInProgressCondition`, `DoubleKnockCondition`, `AlreadyTriggeredCondition`, `TriggerAlreadyRunningCondition`. To add a new blocking rule, create a new file in `conditions/`, extend `Condition`, and add it to the list in `TripHandler`.
|
|
157
173
|
|
|
158
174
|
---
|
|
159
175
|
|
|
160
|
-
## Architecture:
|
|
176
|
+
## Architecture: Handler Wiring & Dependency Resolution
|
|
177
|
+
|
|
178
|
+
Handlers are constructed in a fixed order in `security-system.ts` so no two handlers hold constructor references to each other:
|
|
161
179
|
|
|
162
|
-
|
|
180
|
+
1. `SensorHandler` (leaf — no handler dependencies)
|
|
181
|
+
2. `StateHandler` (depends on `SensorHandler`)
|
|
182
|
+
3. `SwitchHandler` (one-way constructor dependency on `StateHandler`)
|
|
183
|
+
4. `TripHandler` (depends on `SensorHandler`; no `StateHandler` reference)
|
|
163
184
|
|
|
164
|
-
|
|
165
|
-
2. Wire them with `setHandlers()` / `setStateHandler()` after all instances exist.
|
|
185
|
+
Coordination between `StateHandler` ↔ `TripHandler` and `StateHandler` ↔ `SwitchHandler` is done through the event bus rather than setter injection:
|
|
166
186
|
|
|
167
|
-
|
|
187
|
+
- `switchHandler.subscribeToStateEvents(bus)` registers listeners for `RESET_MODE_SWITCHES` / `UPDATE_MODE_SWITCHES`.
|
|
188
|
+
- `security-system.ts` subscribes to `TRIGGER_FIRED` (calls `stateHandler.setCurrentState(TRIGGERED, origin)`) and `TRIP_CANCELLED` (falls back to OFF or `stateHandler.resetTimers()`).
|
|
189
|
+
|
|
190
|
+
Do not introduce constructor cycles or setter injection between handlers — wire cross-handler coordination through the bus.
|
|
168
191
|
|
|
169
192
|
---
|
|
170
193
|
|
|
@@ -192,23 +215,31 @@ if (!value) {
|
|
|
192
215
|
- Validate only at system boundaries (config parsing, HTTP input, external storage).
|
|
193
216
|
- Do not add defensive null-checks for values guaranteed by the type system.
|
|
194
217
|
|
|
218
|
+
### Timers
|
|
219
|
+
State-machine timers and intervals (arm, trigger, pause, double-knock, reset, tripped/triggered sensor polling) are owned by `TimerManager` (`src/timers/timer-manager.ts`). Handlers call its `set...Timer()` / `clear...Timer()` methods instead of creating raw timer handles, and never store timer handles in `SystemState`. Short-lived one-off delays (sensor pulses, HTTP-side trip deferral) may use raw `setTimeout`.
|
|
220
|
+
|
|
195
221
|
---
|
|
196
222
|
|
|
197
223
|
## Testing
|
|
198
224
|
|
|
199
|
-
-
|
|
225
|
+
- Package manager is **pnpm** (`pnpm-lock.yaml`).
|
|
226
|
+
- Framework: **Vitest** (`pnpm test`).
|
|
227
|
+
- Lint with **Oxlint** (`pnpm run lint`); typecheck with `pnpm run typecheck` (`tsc --noEmit`); build with `pnpm run build`.
|
|
200
228
|
- Test files live in `src/tests/` and are named `<subject>.test.ts`.
|
|
201
229
|
- Tests cover: conditions (all blocking paths), handler logic, and event-driven interactions.
|
|
202
230
|
- Mock only what is strictly necessary. Prefer structural mocks over full mock libraries.
|
|
203
231
|
- Do not test private methods directly — test through the public API.
|
|
232
|
+
- The HTTP server exposes its Hono app via `get app` for integration tests.
|
|
204
233
|
|
|
205
234
|
---
|
|
206
235
|
|
|
207
236
|
## Adding a New Feature
|
|
208
237
|
|
|
209
238
|
1. **Types/interfaces first** — create files in `types/` or `interfaces/` before writing logic.
|
|
210
|
-
2. **Condition** — if the feature blocks a trip, add a `Condition` subclass
|
|
211
|
-
3. **
|
|
212
|
-
4. **
|
|
213
|
-
5. **
|
|
214
|
-
6. **
|
|
239
|
+
2. **Condition** — if the feature blocks a trip, add a `Condition` subclass and register it in `TripHandler`.
|
|
240
|
+
3. **Timer** — if the feature needs delays or polling, add methods to `TimerManager` rather than raw `setTimeout`/`setInterval` calls.
|
|
241
|
+
4. **Service** — if the feature is a side effect, implement `attachToBus(bus)` and wire it in `security-system.ts`. If it holds a connection (e.g. MQTT), clean it up on `api.on('shutdown')`.
|
|
242
|
+
5. **HTTP endpoint** — if the feature is exposed over the server, add a zod schema in `schemas/` and a route in `server-service.ts`.
|
|
243
|
+
6. **Handler** — if the feature changes state-machine logic, modify the relevant handler and coordinate via the event bus.
|
|
244
|
+
7. **Tests** — add a test covering the happy path and the main blocking/edge case.
|
|
245
|
+
8. **No abbreviations** — all new identifiers must be fully spelled out.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v12.0.0 - 2026-08-30
|
|
4
|
+
|
|
5
|
+
<!-- Release notes generated using configuration in .github/release.yml at v12.0.0 -->
|
|
6
|
+
|
|
7
|
+
## What's Changed
|
|
8
|
+
### 💥 Breaking Changes
|
|
9
|
+
* Remove file logging by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/988
|
|
10
|
+
* feat: use full URL per webhook event (remove base URL) by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/992
|
|
11
|
+
### 🛠️ Other Changes
|
|
12
|
+
* Deprecate audio playback by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/989
|
|
13
|
+
* Deprecate triggered sensor by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/990
|
|
14
|
+
* docs: update AGENTS.md to match current architecture by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/995
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
**Full Changelog**: https://github.com/MiguelRipoll23/homebridge-securitysystem/compare/v11.4.1...v12.0.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## v12.0.0-beta.2 - 2026-08-29
|
|
21
|
+
|
|
22
|
+
<!-- Release notes generated using configuration in .github/release.yml at v12.0.0-beta.2 -->
|
|
23
|
+
|
|
24
|
+
## What's Changed
|
|
25
|
+
### 💥 Breaking Changes
|
|
26
|
+
* feat: use full URL per webhook event (remove base URL) by @MiguelRipoll23 in https://github.com/MiguelRipoll23/homebridge-securitysystem/pull/992
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
**Full Changelog**: https://github.com/MiguelRipoll23/homebridge-securitysystem/compare/v12.0.0-beta.1...v12.0.0-beta.2
|
|
30
|
+
|
|
31
|
+
|
|
3
32
|
## v12.0.0-beta.1 - 2026-08-29
|
|
4
33
|
|
|
5
34
|
<!-- Release notes generated using configuration in .github/release.yml at v12.0.0-beta.1 -->
|
package/config.schema.json
CHANGED
|
@@ -323,23 +323,6 @@
|
|
|
323
323
|
"functionBody": "return !(model.disabled_modes || []).includes('Night');"
|
|
324
324
|
}
|
|
325
325
|
},
|
|
326
|
-
"audio_switch": {
|
|
327
|
-
"title": "Show Audio Enable Switch (Deprecated)",
|
|
328
|
-
"description": "Adds a global switch to enable or disable audio except for alarm triggered. Deprecated — audio playback is deprecated, use command hooks instead.",
|
|
329
|
-
"type": "boolean",
|
|
330
|
-
"default": false,
|
|
331
|
-
"required": false
|
|
332
|
-
},
|
|
333
|
-
"audio_switch_name": {
|
|
334
|
-
"title": "Audio Enable Switch Name (Deprecated)",
|
|
335
|
-
"description": "",
|
|
336
|
-
"type": "string",
|
|
337
|
-
"default": "Enable Audio",
|
|
338
|
-
"required": false,
|
|
339
|
-
"condition": {
|
|
340
|
-
"functionBody": "return model.audio_switch === true;"
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
326
|
"arming_sensor": {
|
|
344
327
|
"title": "Show Arming Sensor",
|
|
345
328
|
"description": "Adds a sensor that asserts when the security system is being armed.",
|
|
@@ -365,24 +348,6 @@
|
|
|
365
348
|
"functionBody": "return model.tripped_sensor === true;"
|
|
366
349
|
}
|
|
367
350
|
},
|
|
368
|
-
"triggered_sensor": {
|
|
369
|
-
"title": "Show Triggered Sensor (Deprecated)",
|
|
370
|
-
"description": "Adds a sensor that pulses at the set rate when the security system has been triggered. Deprecated — Apple already provides emergency alerts for security system accessories, so this sensor is redundant.",
|
|
371
|
-
"type": "boolean",
|
|
372
|
-
"default": false,
|
|
373
|
-
"required": false
|
|
374
|
-
},
|
|
375
|
-
"triggered_sensor_seconds": {
|
|
376
|
-
"title": "Triggered Sensor Pulse Rate (seconds) (Deprecated)",
|
|
377
|
-
"description": "Set to 0 for steady on.",
|
|
378
|
-
"type": "integer",
|
|
379
|
-
"default": 5,
|
|
380
|
-
"required": false,
|
|
381
|
-
"minimum": 0,
|
|
382
|
-
"condition": {
|
|
383
|
-
"functionBody": "return model.triggered_sensor === true;"
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
351
|
"reset_sensor": {
|
|
387
352
|
"title": "Show Triggered Reset Sensor",
|
|
388
353
|
"description": "Adds a sensor that asserts when the security system has reset after being triggered.",
|
|
@@ -390,72 +355,6 @@
|
|
|
390
355
|
"default": false,
|
|
391
356
|
"required": false
|
|
392
357
|
},
|
|
393
|
-
"audio": {
|
|
394
|
-
"title": "Play Sounds (Deprecated, local-only, ffmpeg required)",
|
|
395
|
-
"description": "Warns of pending or current events by playing sounds. Deprecated — use command hooks (command_current_*) to play audio instead, which is more flexible.",
|
|
396
|
-
"type": "boolean",
|
|
397
|
-
"default": false,
|
|
398
|
-
"required": false
|
|
399
|
-
},
|
|
400
|
-
"audio_language": {
|
|
401
|
-
"title": "Audio Language",
|
|
402
|
-
"description": "",
|
|
403
|
-
"type": "string",
|
|
404
|
-
"default": "en-US",
|
|
405
|
-
"required": false,
|
|
406
|
-
"enum": ["en-US", "de-DE"]
|
|
407
|
-
},
|
|
408
|
-
"audio_extra_variables": {
|
|
409
|
-
"title": "Audio Extra Variables",
|
|
410
|
-
"description": "Add extra environment variables to the ffplay command that will be executed",
|
|
411
|
-
"type": "array",
|
|
412
|
-
"items": {
|
|
413
|
-
"title": "Environment Variable",
|
|
414
|
-
"type": "object",
|
|
415
|
-
"properties": {
|
|
416
|
-
"key": {
|
|
417
|
-
"title": "Name",
|
|
418
|
-
"type": "string",
|
|
419
|
-
"required": true
|
|
420
|
-
},
|
|
421
|
-
"value": {
|
|
422
|
-
"title": "Value",
|
|
423
|
-
"type": "string",
|
|
424
|
-
"required": true
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
"required": false
|
|
429
|
-
},
|
|
430
|
-
"audio_path": {
|
|
431
|
-
"title": "Custom Audio Path",
|
|
432
|
-
"description": "Instructions will be created in this path.",
|
|
433
|
-
"type": "string",
|
|
434
|
-
"required": false,
|
|
435
|
-
"placeholder": "/home/user/sounds"
|
|
436
|
-
},
|
|
437
|
-
"audio_volume": {
|
|
438
|
-
"title": "Audio Volume",
|
|
439
|
-
"description": "",
|
|
440
|
-
"type": "string",
|
|
441
|
-
"required": false,
|
|
442
|
-
"default": 100,
|
|
443
|
-
"placeholder": "100"
|
|
444
|
-
},
|
|
445
|
-
"audio_arming_looped": {
|
|
446
|
-
"title": "Loop Arming Sound",
|
|
447
|
-
"description": "",
|
|
448
|
-
"type": "boolean",
|
|
449
|
-
"default": false,
|
|
450
|
-
"required": false
|
|
451
|
-
},
|
|
452
|
-
"audio_alert_looped": {
|
|
453
|
-
"title": "Loop Tripped Sound",
|
|
454
|
-
"description": "",
|
|
455
|
-
"type": "boolean",
|
|
456
|
-
"default": false,
|
|
457
|
-
"required": false
|
|
458
|
-
},
|
|
459
358
|
"server_port": {
|
|
460
359
|
"title": "Listening Port",
|
|
461
360
|
"description": "",
|
|
@@ -888,9 +787,7 @@
|
|
|
888
787
|
"type": "tabarray",
|
|
889
788
|
"title": "{{ value.label || 'Night Switch' }}",
|
|
890
789
|
"items": ["trip_night_switches[].label"]
|
|
891
|
-
}
|
|
892
|
-
"audio_switch",
|
|
893
|
-
"audio_switch_name"
|
|
790
|
+
}
|
|
894
791
|
]
|
|
895
792
|
},
|
|
896
793
|
{
|
|
@@ -908,50 +805,9 @@
|
|
|
908
805
|
"flex-direction": "row",
|
|
909
806
|
"items": ["tripped_sensor", "tripped_sensor_seconds"]
|
|
910
807
|
},
|
|
911
|
-
{
|
|
912
|
-
"type": "div",
|
|
913
|
-
"displayFlex": true,
|
|
914
|
-
"flex-flow": "row",
|
|
915
|
-
"flex-direction": "row",
|
|
916
|
-
"items": ["triggered_sensor", "triggered_sensor_seconds"]
|
|
917
|
-
},
|
|
918
808
|
"reset_sensor"
|
|
919
809
|
]
|
|
920
810
|
},
|
|
921
|
-
{
|
|
922
|
-
"type": "fieldset",
|
|
923
|
-
"title": "Audio (Deprecated)",
|
|
924
|
-
"description": "Play sounds on your connected speakers to notify events. Deprecated — use command hooks to play audio instead, which is more flexible.",
|
|
925
|
-
"expandable": true,
|
|
926
|
-
"expanded": false,
|
|
927
|
-
"items": [
|
|
928
|
-
{
|
|
929
|
-
"type": "div",
|
|
930
|
-
"displayFlex": true,
|
|
931
|
-
"flex-flow": "row wrap",
|
|
932
|
-
"flex-direction": "row",
|
|
933
|
-
"items": ["audio", "audio_language"]
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
"type": "div",
|
|
937
|
-
"displayFlex": true,
|
|
938
|
-
"flex-flow": "row wrap",
|
|
939
|
-
"flex-direction": "row",
|
|
940
|
-
"items": ["audio_path", "audio_volume"]
|
|
941
|
-
},
|
|
942
|
-
"audio_arming_looped",
|
|
943
|
-
"audio_alert_looped",
|
|
944
|
-
{
|
|
945
|
-
"key": "audio_extra_variables",
|
|
946
|
-
"type": "tabarray",
|
|
947
|
-
"title": "{{ value.key || 'Environment Variable' }}",
|
|
948
|
-
"items": [
|
|
949
|
-
"audio_extra_variables[].key",
|
|
950
|
-
"audio_extra_variables[].value"
|
|
951
|
-
]
|
|
952
|
-
}
|
|
953
|
-
]
|
|
954
|
-
},
|
|
955
811
|
{
|
|
956
812
|
"type": "fieldset",
|
|
957
813
|
"title": "Server",
|
|
@@ -8,9 +8,7 @@ export declare const DEFAULTS: {
|
|
|
8
8
|
readonly RESET_MINUTES: 10;
|
|
9
9
|
readonly DOUBLE_KNOCK_SECONDS: 90;
|
|
10
10
|
readonly TRIPPED_SENSOR_SECONDS: 5;
|
|
11
|
-
readonly TRIGGERED_SENSOR_SECONDS: 5;
|
|
12
11
|
readonly PAUSE_MINUTES: 0;
|
|
13
|
-
readonly AUDIO_LANGUAGE: 'en-US';
|
|
14
12
|
readonly TRIP_SWITCH_NAME: 'Trip';
|
|
15
13
|
readonly TRIP_HOME_SWITCH_NAME: 'Trip Home';
|
|
16
14
|
readonly TRIP_AWAY_SWITCH_NAME: 'Trip Away';
|
|
@@ -22,6 +20,5 @@ export declare const DEFAULTS: {
|
|
|
22
20
|
readonly MODE_OFF_SWITCH_NAME: 'Mode Off';
|
|
23
21
|
readonly MODE_AWAY_EXTENDED_SWITCH_NAME: 'Mode Away Extended';
|
|
24
22
|
readonly MODE_PAUSE_SWITCH_NAME: 'Mode Pause';
|
|
25
|
-
readonly AUDIO_SWITCH_NAME: 'Audio';
|
|
26
23
|
readonly MQTT_TOPIC: 'security-system/state';
|
|
27
24
|
};
|
|
@@ -8,9 +8,7 @@ export const DEFAULTS = {
|
|
|
8
8
|
RESET_MINUTES: 10,
|
|
9
9
|
DOUBLE_KNOCK_SECONDS: 90,
|
|
10
10
|
TRIPPED_SENSOR_SECONDS: 5,
|
|
11
|
-
TRIGGERED_SENSOR_SECONDS: 5,
|
|
12
11
|
PAUSE_MINUTES: 0,
|
|
13
|
-
AUDIO_LANGUAGE: 'en-US',
|
|
14
12
|
// Switch display names
|
|
15
13
|
TRIP_SWITCH_NAME: 'Trip',
|
|
16
14
|
TRIP_HOME_SWITCH_NAME: 'Trip Home',
|
|
@@ -23,7 +21,6 @@ export const DEFAULTS = {
|
|
|
23
21
|
MODE_OFF_SWITCH_NAME: 'Mode Off',
|
|
24
22
|
MODE_AWAY_EXTENDED_SWITCH_NAME: 'Mode Away Extended',
|
|
25
23
|
MODE_PAUSE_SWITCH_NAME: 'Mode Pause',
|
|
26
|
-
AUDIO_SWITCH_NAME: 'Audio',
|
|
27
24
|
// MQTT
|
|
28
25
|
MQTT_TOPIC: 'security-system/state',
|
|
29
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-constant.js","sourceRoot":"","sources":["../../src/constants/default-constant.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,gBAAgB;IAC/B,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,CAAC;IACd,eAAe,EAAE,CAAC;IAClB,aAAa,EAAE,EAAE;IACjB,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,CAAC;IACzB,
|
|
1
|
+
{"version":3,"file":"default-constant.js","sourceRoot":"","sources":["../../src/constants/default-constant.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,gBAAgB;IAC/B,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,CAAC;IACd,eAAe,EAAE,CAAC;IAClB,aAAa,EAAE,EAAE;IACjB,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,CAAC;IACzB,aAAa,EAAE,CAAC;IAEhB,uBAAuB;IACvB,gBAAgB,EAAE,MAAM;IACxB,qBAAqB,EAAE,WAAW;IAClC,qBAAqB,EAAE,WAAW;IAClC,sBAAsB,EAAE,YAAY;IACpC,yBAAyB,EAAE,eAAe;IAC1C,qBAAqB,EAAE,WAAW;IAClC,qBAAqB,EAAE,WAAW;IAClC,sBAAsB,EAAE,YAAY;IACpC,oBAAoB,EAAE,UAAU;IAChC,8BAA8B,EAAE,oBAAoB;IACpD,sBAAsB,EAAE,YAAY;IAEpC,OAAO;IACP,UAAU,EAAE,uBAAuB;CAC3B,CAAC"}
|
|
@@ -15,9 +15,7 @@ export declare const SWITCH_UUIDS: {
|
|
|
15
15
|
readonly MODE_OFF: 'mode-off';
|
|
16
16
|
readonly MODE_AWAY_EXTENDED: 'mode-away-extended';
|
|
17
17
|
readonly MODE_PAUSE: 'mode-pause';
|
|
18
|
-
readonly AUDIO: 'kx82r64zN3txDXKFiX9JDi';
|
|
19
18
|
readonly ARMING_SENSOR: 'arming-motion-sensor';
|
|
20
19
|
readonly TRIPPED_SENSOR: 'siren-tripped';
|
|
21
|
-
readonly TRIGGERED_SENSOR: 'siren-triggered';
|
|
22
20
|
readonly RESET_SENSOR: 'reset-event';
|
|
23
21
|
};
|
|
@@ -15,10 +15,8 @@ export const SWITCH_UUIDS = {
|
|
|
15
15
|
MODE_OFF: 'mode-off',
|
|
16
16
|
MODE_AWAY_EXTENDED: 'mode-away-extended',
|
|
17
17
|
MODE_PAUSE: 'mode-pause',
|
|
18
|
-
AUDIO: 'kx82r64zN3txDXKFiX9JDi',
|
|
19
18
|
ARMING_SENSOR: 'arming-motion-sensor',
|
|
20
19
|
TRIPPED_SENSOR: 'siren-tripped',
|
|
21
|
-
TRIGGERED_SENSOR: 'siren-triggered',
|
|
22
20
|
RESET_SENSOR: 'reset-event',
|
|
23
21
|
};
|
|
24
22
|
//# sourceMappingURL=switch-uuid-constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-uuid-constant.js","sourceRoot":"","sources":["../../src/constants/switch-uuid-constant.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,aAAa;IACzB,aAAa,EAAE,YAAY;IAC3B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,kBAAkB,EAAE,oBAAoB;IACxC,UAAU,EAAE,YAAY;IACxB,
|
|
1
|
+
{"version":3,"file":"switch-uuid-constant.js","sourceRoot":"","sources":["../../src/constants/switch-uuid-constant.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,aAAa;IACzB,aAAa,EAAE,YAAY;IAC3B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,kBAAkB,EAAE,oBAAoB;IACxC,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,sBAAsB;IACrC,cAAc,EAAE,eAAe;IAC/B,YAAY,EAAE,aAAa;CACnB,CAAC"}
|
|
@@ -12,9 +12,6 @@ export declare class SensorHandler {
|
|
|
12
12
|
pulseTrippedMotionSensor(): void;
|
|
13
13
|
setTrippedMotionSensor(value: boolean): void;
|
|
14
14
|
resetTrippedMotionSensor(): void;
|
|
15
|
-
pulseTriggeredMotionSensor(): void;
|
|
16
|
-
setTriggeredMotionSensor(value: boolean): void;
|
|
17
|
-
resetTriggeredMotionSensor(): void;
|
|
18
15
|
pulseResetMotionSensor(): void;
|
|
19
16
|
private scheduleReset;
|
|
20
17
|
}
|
|
@@ -35,21 +35,6 @@ export class SensorHandler {
|
|
|
35
35
|
char.updateValue(false);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
// ── Triggered sensor ───────────────────────────────────────────────────────
|
|
39
|
-
pulseTriggeredMotionSensor() {
|
|
40
|
-
this.setTriggeredMotionSensor(true);
|
|
41
|
-
this.scheduleReset(this.services.triggeredMotionSensorService);
|
|
42
|
-
}
|
|
43
|
-
setTriggeredMotionSensor(value) {
|
|
44
|
-
this.services.triggeredMotionSensorService.updateCharacteristic(this.Characteristic.MotionDetected, value);
|
|
45
|
-
}
|
|
46
|
-
resetTriggeredMotionSensor() {
|
|
47
|
-
const char = this.services.triggeredMotionSensorService
|
|
48
|
-
.getCharacteristic(this.Characteristic.MotionDetected);
|
|
49
|
-
if (char.value) {
|
|
50
|
-
char.updateValue(false);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
38
|
// ── Reset sensor ───────────────────────────────────────────────────────────
|
|
54
39
|
pulseResetMotionSensor() {
|
|
55
40
|
this.services.triggeredResetMotionSensorService.updateCharacteristic(this.Characteristic.MotionDetected, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensor-handler.js","sourceRoot":"","sources":["../../src/handlers/sensor-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,wDAAwD;AACxD,MAAM,OAAO,aAAa;IAEL,QAAQ;IACR,cAAc;IACd,GAAG;IAHtB,YACmB,QAAyB,EACzB,cAAyC,EACzC,GAAY;wBAFZ,QAAQ;8BACR,cAAc;mB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IAE9E,sBAAsB;QACpB,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,oBAAoB,CAClE,IAAI,CAAC,cAAc,CAAC,cAAc,EAClC,IAAI,CACL,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC;QACpE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;IAED,8EAA8E;IAEtE,aAAa,CAAC,OAAgB;QACpC,UAAU,CAAC,GAAG,EAAE;YACd,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC,EAAE,eAAe,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -7,7 +7,6 @@ import type { SystemState } from '../interfaces/system-state-interface.js';
|
|
|
7
7
|
import type { SecuritySystemOptions } from '../interfaces/options-interface.js';
|
|
8
8
|
import type { EventBusService } from '../services/event-bus-service.js';
|
|
9
9
|
import type { StorageService } from '../services/storage-service.js';
|
|
10
|
-
import type { AudioService } from '../services/audio-service.js';
|
|
11
10
|
import type { SensorHandler } from './sensor-handler.js';
|
|
12
11
|
import type { TimerManager } from '../timers/timer-manager.js';
|
|
13
12
|
import type { ServiceResult } from '../types/service-result-type.js';
|
|
@@ -24,10 +23,9 @@ export declare class StateHandler {
|
|
|
24
23
|
private readonly log;
|
|
25
24
|
private readonly bus;
|
|
26
25
|
private readonly storageService;
|
|
27
|
-
private readonly audio;
|
|
28
26
|
private readonly timers;
|
|
29
27
|
private readonly sensorHandler;
|
|
30
|
-
constructor(services: ServiceRegistry, state: SystemState, options: SecuritySystemOptions, Characteristic: CharacteristicConstructor, log: Logging, bus: EventBusService, storageService: StorageService,
|
|
28
|
+
constructor(services: ServiceRegistry, state: SystemState, options: SecuritySystemOptions, Characteristic: CharacteristicConstructor, log: Logging, bus: EventBusService, storageService: StorageService, timers: TimerManager, sensorHandler: SensorHandler);
|
|
31
29
|
setCurrentState(state: SecurityState, origin: OriginType): void;
|
|
32
30
|
updateTargetState(state: SecurityState, origin: OriginType, delay: number): ServiceResult;
|
|
33
31
|
getArmingSeconds(targetState: SecurityState): number;
|
|
@@ -46,7 +44,6 @@ export declare class StateHandler {
|
|
|
46
44
|
private handleTargetStateChange;
|
|
47
45
|
private handleCurrentStateChange;
|
|
48
46
|
private handleTriggeredState;
|
|
49
|
-
private startTriggeredMotionSensor;
|
|
50
47
|
private handleArmingState;
|
|
51
48
|
private resetViaOffMode;
|
|
52
49
|
}
|
|
@@ -17,10 +17,9 @@ export class StateHandler {
|
|
|
17
17
|
log;
|
|
18
18
|
bus;
|
|
19
19
|
storageService;
|
|
20
|
-
audio;
|
|
21
20
|
timers;
|
|
22
21
|
sensorHandler;
|
|
23
|
-
constructor(services, state, options, Characteristic, log, bus, storageService,
|
|
22
|
+
constructor(services, state, options, Characteristic, log, bus, storageService, timers, sensorHandler) {
|
|
24
23
|
this.services = services;
|
|
25
24
|
this.state = state;
|
|
26
25
|
this.options = options;
|
|
@@ -28,14 +27,12 @@ export class StateHandler {
|
|
|
28
27
|
this.log = log;
|
|
29
28
|
this.bus = bus;
|
|
30
29
|
this.storageService = storageService;
|
|
31
|
-
this.audio = audio;
|
|
32
30
|
this.timers = timers;
|
|
33
31
|
this.sensorHandler = sensorHandler;
|
|
34
32
|
}
|
|
35
33
|
// ── Public API ─────────────────────────────────────────────────────────────
|
|
36
34
|
setCurrentState(state, origin) {
|
|
37
35
|
this.sensorHandler.resetArmingMotionSensor();
|
|
38
|
-
this.audio.play('current', state);
|
|
39
36
|
if (this.state.currentState === state) {
|
|
40
37
|
this.log.warn('Current mode (Already set)');
|
|
41
38
|
return;
|
|
@@ -149,7 +146,6 @@ export class StateHandler {
|
|
|
149
146
|
// Notify handlers to reset their displayed state (bus is synchronous).
|
|
150
147
|
this.bus.emit(EventType.RESET_TRIP_SWITCHES, {});
|
|
151
148
|
this.sensorHandler.resetTrippedMotionSensor();
|
|
152
|
-
this.sensorHandler.resetTriggeredMotionSensor();
|
|
153
149
|
this.bus.emit(EventType.RESET_MODE_SWITCHES, {});
|
|
154
150
|
this.bus.emit(EventType.UPDATE_MODE_SWITCHES, {});
|
|
155
151
|
this.bus.emit(EventType.TARGET_CHANGED, { state: this.state.targetState, origin });
|
|
@@ -177,7 +173,6 @@ export class StateHandler {
|
|
|
177
173
|
handleTriggeredState() {
|
|
178
174
|
this.timers.clearTrippedInterval();
|
|
179
175
|
this.sensorHandler.resetTrippedMotionSensor();
|
|
180
|
-
this.startTriggeredMotionSensor();
|
|
181
176
|
this.timers.setResetTimer(this.options.resetMinutes * 60 * 1000, () => {
|
|
182
177
|
this.log.info('Reset (Finished)');
|
|
183
178
|
this.sensorHandler.pulseResetMotionSensor();
|
|
@@ -189,15 +184,6 @@ export class StateHandler {
|
|
|
189
184
|
}
|
|
190
185
|
});
|
|
191
186
|
}
|
|
192
|
-
startTriggeredMotionSensor() {
|
|
193
|
-
const seconds = this.options.triggeredMotionSensorSeconds;
|
|
194
|
-
if (seconds === 0) {
|
|
195
|
-
this.sensorHandler.setTriggeredMotionSensor(true);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
this.timers.setTriggeredInterval(seconds * 1000, () => this.sensorHandler.pulseTriggeredMotionSensor());
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
187
|
handleArmingState() {
|
|
202
188
|
this.sensorHandler.updateArmingMotionSensor(true);
|
|
203
189
|
this.bus.emit(EventType.ARMING, { state: this.state.targetState });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-handler.js","sourceRoot":"","sources":["../../src/handlers/state-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACj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