@homebridge-plugins/homebridge-eufy-security 4.6.0-beta.2 → 4.6.0-beta.21
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/.claude/CLAUDE.md +175 -0
- package/.claude/PRD.md +241 -0
- package/.claude/skills/architect/SKILL.md +76 -0
- package/.claude/skills/developer/SKILL.md +55 -0
- package/.claude/skills/new-device-support/SKILL.md +13 -42
- package/.claude/skills/new-device-support/map-properties.mjs +45 -0
- package/.claude/skills/planner/SKILL.md +96 -0
- package/.claude/skills/qa/SKILL.md +74 -0
- package/.claude/skills/support/SKILL.md +175 -0
- package/dist/accessories/CameraAccessory.js +7 -0
- package/dist/accessories/CameraAccessory.js.map +1 -1
- package/dist/controller/LocalLivestreamManager.js +79 -8
- package/dist/controller/LocalLivestreamManager.js.map +1 -1
- package/dist/controller/recordingDelegate.js +4 -2
- package/dist/controller/recordingDelegate.js.map +1 -1
- package/dist/controller/streamingDelegate.js +28 -3
- package/dist/controller/streamingDelegate.js.map +1 -1
- package/dist/platform.js +3 -2
- package/dist/platform.js.map +1 -1
- package/dist/utils/configTypes.js +1 -0
- package/dist/utils/configTypes.js.map +1 -1
- package/dist/utils/ffmpeg.js +123 -15
- package/dist/utils/ffmpeg.js.map +1 -1
- package/dist/utils/utils.js +21 -2
- package/dist/utils/utils.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/homebridge-ui/public/assets/devices/eufyCamS4_large.png +0 -0
- package/homebridge-ui/public/assets/devices/homebase3_large.png +0 -0
- package/homebridge-ui/public/views/device-detail.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with the homebridge-eufy-security plugin.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Homebridge plugin that exposes Eufy Security devices to Apple HomeKit. Published as `@homebridge-plugins/homebridge-eufy-security` under the `homebridge-plugins` GitHub organization.
|
|
8
|
+
|
|
9
|
+
Depends on `eufy-security-client` (upstream: bropat/eufy-security-client) for cloud API, P2P, push notifications, and MQTT communication.
|
|
10
|
+
|
|
11
|
+
For detailed functional requirements, device coverage, configuration options, and architecture boundaries, see `.claude/PRD.md`.
|
|
12
|
+
|
|
13
|
+
## Build & Dev Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run build # rimraf dist -> tsc -> copy media/ to dist/
|
|
17
|
+
npm run build-plugin # rimraf dist -> tsc (no media copy)
|
|
18
|
+
npm run lint # eslint 'src/**/*.ts' --max-warnings=0
|
|
19
|
+
npm run lint-fix # eslint with --fix
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- No test suite -- there are no unit or integration tests
|
|
23
|
+
- Output: `dist/`
|
|
24
|
+
- `--max-warnings=0` is enforced -- all warnings must be fixed before committing
|
|
25
|
+
- ESLint uses flat config (`eslint.config.mjs`); `@typescript-eslint/no-explicit-any` is globally disabled -- do not add eslint-disable comments for it
|
|
26
|
+
- Run `npm run lint` and `npm run build` before pushing
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
Entry point `src/index.ts` registers `EufySecurityPlatform` with Homebridge. The platform class (`src/platform.ts`) is the core -- it initializes the `EufySecurity` client, discovers devices, and creates HomeKit accessories.
|
|
31
|
+
|
|
32
|
+
**Accessory classes** in `src/accessories/` map Eufy device types to HomeKit services:
|
|
33
|
+
- `BaseAccessory.ts` -- root base class (characteristic registration, service pruning)
|
|
34
|
+
- `Device.ts` (`DeviceAccessory`) -- extends `BaseAccessory`; adds sensor/battery services, property helpers
|
|
35
|
+
- `CameraAccessory` -- cameras, doorbells, floodlights (handles streaming delegates); extends `DeviceAccessory`
|
|
36
|
+
- `StationAccessory` -- base stations (security system service for arm/disarm); extends `BaseAccessory` directly
|
|
37
|
+
- `LockAccessory`, `EntrySensorAccessory`, `MotionSensorAccessory`, `SmartDropAccessory` -- extend `DeviceAccessory`
|
|
38
|
+
- `AutoSyncStationAccessory` -- virtual accessory that syncs station guard mode with HomeKit
|
|
39
|
+
|
|
40
|
+
**Streaming pipeline** in `src/controller/`:
|
|
41
|
+
- `streamingDelegate.ts` -- HomeKit camera streaming (FFmpeg-based)
|
|
42
|
+
- `recordingDelegate.ts` -- HomeKit Secure Video recording
|
|
43
|
+
- `snapshotDelegate.ts` -- snapshot handling
|
|
44
|
+
- `LocalLivestreamManager.ts` -- manages P2P livestream sessions
|
|
45
|
+
|
|
46
|
+
**Utilities** in `src/utils/`: logging (`utils.ts`), FFmpeg wrapper (`ffmpeg.ts`), two-way audio (`Talkback.ts`), config schema (`configTypes.ts`), internal interfaces (`interfaces.ts`).
|
|
47
|
+
|
|
48
|
+
**Constants** in `src/settings.ts`: HKSV segment lengths, snapshot cache ages, streaming bitrate headroom, IDR intervals -- reference this when tuning streaming or recording behaviour.
|
|
49
|
+
|
|
50
|
+
**Plugin UI** in `homebridge-ui/`: `server.js` (plain JS, eslint-ignored) handles UI server logic and diagnostics generation. The UI and the plugin runtime (`src/`) are **separate processes** that share state through `accessories.json` on disk (written by `src/utils/accessoriesStore.ts`, read by `homebridge-ui/server.js`). Both independently import `eufy-security-client` types (`DeviceType`, `PropertyName`, `Device`, etc.) -- changes to the device/station record shape must be kept in sync between `accessoriesStore.ts` and `server.js`.
|
|
51
|
+
|
|
52
|
+
### Key source files for device registration and triage
|
|
53
|
+
|
|
54
|
+
- `src/platform.ts` (`register_device`) -- device registration logic; devices can stack multiple capabilities (independent `if` blocks, not `else if`)
|
|
55
|
+
|
|
56
|
+
## Key Technical Details
|
|
57
|
+
|
|
58
|
+
- ESM project (`"type": "module"`, `"module": "NodeNext"`) -- imports must use `.js` extensions (NodeNext resolution requires explicit extensions)
|
|
59
|
+
- TypeScript strict mode, ES2022 target (`noImplicitAny: false` relaxes implicit-any checks)
|
|
60
|
+
- Node.js 20, 22, or 24 required
|
|
61
|
+
- Homebridge >=1.9.0 or ^2.0.0-beta
|
|
62
|
+
- Uses `ffmpeg-for-homebridge` for video transcoding
|
|
63
|
+
- `src/version.ts` is auto-generated at prebuild time -- do not edit manually
|
|
64
|
+
- `prepublishOnly` runs lint + build automatically before `npm publish`
|
|
65
|
+
- For local development, `eufy-security-client` can be pointed to a local path (e.g. `"../eufy-security-client"`)
|
|
66
|
+
|
|
67
|
+
## Git Workflow
|
|
68
|
+
|
|
69
|
+
**IMPORTANT: Create the branch BEFORE editing any files.**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Create dedicated branch from beta before making any changes
|
|
73
|
+
git checkout beta-*.*.* && git pull origin beta-*.*.*
|
|
74
|
+
git checkout -b [fix/feat/chore]/<short-description>
|
|
75
|
+
|
|
76
|
+
# Stage and commit each change individually
|
|
77
|
+
git add <file>
|
|
78
|
+
git commit -m "fix: <concise description of what changed and why>"
|
|
79
|
+
|
|
80
|
+
# Push and create PR
|
|
81
|
+
git push -u origin fix/<short-description>
|
|
82
|
+
gh pr create --base beta-*.*.* --title "<concise title>" --body-file /tmp/pr-body.md
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- Branch from `beta-*.*.*`, not `master`
|
|
86
|
+
- PR target: `beta-*.*.*`
|
|
87
|
+
- Branch naming: `fix/`, `feat/`, `chore/` prefix
|
|
88
|
+
|
|
89
|
+
### Commit message rules
|
|
90
|
+
|
|
91
|
+
- Single line, no line breaks mid-sentence
|
|
92
|
+
- Describe the **spirit** of the change, not the code diff
|
|
93
|
+
- No Co-Authored-By
|
|
94
|
+
|
|
95
|
+
### PR body
|
|
96
|
+
|
|
97
|
+
- Write to `/tmp/pr-body-<branch>.md` using file creation -- **never** use heredoc (`cat << EOF`) in the terminal (quotes and special characters break it)
|
|
98
|
+
- Describe the **spirit** of the change, not the code diff
|
|
99
|
+
- Concise description of the problem and fix
|
|
100
|
+
- PR body is **not** the release note -- keep it focused on the code change for reviewers
|
|
101
|
+
- No Co-Authored-By
|
|
102
|
+
|
|
103
|
+
### Release notes
|
|
104
|
+
|
|
105
|
+
- Write to `/tmp/release-notes-<version>.md` using file creation
|
|
106
|
+
- **Audience is end users** -- focus on what matters to them: new devices, behaviour changes, removed settings, required actions
|
|
107
|
+
- **Concise, bullet-driven** -- no markdown tables, no verbose paragraphs. Short section intros (1-2 sentences max) followed by bullet lists
|
|
108
|
+
- **No internal milestones** -- don't mention "first GA since X" or beta iteration counts
|
|
109
|
+
- **Structure for a branch** (e.g., `4.4.x`), not a single version:
|
|
110
|
+
- Individual `## v4.4.x` entries at the top with version-specific changes
|
|
111
|
+
- A shared `## What's in 4.4.x` section below covering the full branch
|
|
112
|
+
- **Required actions front and center** -- if users need to change config or upgrade Node.js, say so early and clearly
|
|
113
|
+
- **Tone**: direct, no filler, no emojis
|
|
114
|
+
|
|
115
|
+
### Issue comments
|
|
116
|
+
|
|
117
|
+
- Use `gh issue comment <number> --repo homebridge-plugins/homebridge-eufy-security --body "<message>"`
|
|
118
|
+
- Use first person ("I")
|
|
119
|
+
- Thank the user by @mention
|
|
120
|
+
- Be formal and concise
|
|
121
|
+
- **Audience is end users** -- keep language simple, no internal jargon
|
|
122
|
+
- Don't scope a fix to a specific device when it applies broadly
|
|
123
|
+
- When a fix is merged, check the published beta version (`npm view @homebridge-plugins/homebridge-eufy-security dist-tags`) and mention it in the comment
|
|
124
|
+
|
|
125
|
+
## Dependency Policy -- `eufy-security-client`
|
|
126
|
+
|
|
127
|
+
**CRITICAL:**
|
|
128
|
+
- **`beta-*.*.*` branches** -- use the `dev` dist-tag (`"eufy-security-client": "dev"`)
|
|
129
|
+
- **`master` branch** -- **NEVER** use the `dev` dist-tag. Always use a pinned stable version (e.g. `"^3.7.2"`). Before merging to master, replace `"dev"` with the corresponding stable release version.
|
|
130
|
+
|
|
131
|
+
When updating the `eufy-security-client` version in `package.json`:
|
|
132
|
+
1. Check the upstream changelog and README at https://github.com/bropat/eufy-security-client/blob/master/README.md
|
|
133
|
+
2. Identify breaking changes, new features, or device support changes
|
|
134
|
+
3. Summarize the impact in the PR body
|
|
135
|
+
4. If there are breaking changes, note any required code adjustments
|
|
136
|
+
|
|
137
|
+
## Skills
|
|
138
|
+
|
|
139
|
+
Skills in `.claude/skills/` provide structured workflows for common tasks:
|
|
140
|
+
|
|
141
|
+
| Skill | Purpose |
|
|
142
|
+
|---|---|
|
|
143
|
+
| `planner` | Build a step-by-step action plan with guardrails before coding |
|
|
144
|
+
| `developer` | Execute code changes following an approved plan or direct instructions |
|
|
145
|
+
| `qa` | Verify build, lint, imports, architecture, and git hygiene before pushing |
|
|
146
|
+
| `architect` | Quick codebase questions, mini-bug debugging, workflow improvement |
|
|
147
|
+
| `support` | Triage GitHub issues using diagnostics archives and logs |
|
|
148
|
+
| `new-device-support` | Full workflow to add a new Eufy device type across both repos |
|
|
149
|
+
|
|
150
|
+
Typical flow: **planner** -> **developer** -> **qa**. Use **architect** for exploration and **support** for issue triage.
|
|
151
|
+
|
|
152
|
+
## Diagnostic Triage
|
|
153
|
+
|
|
154
|
+
For issue triage, use the `support` skill with an issue number (e.g. `/support 423`). For the full triage reference, see `.github/prompts/diag-triage.prompt.md`. For adding new device types, use the `new-device-support` skill. Key points:
|
|
155
|
+
|
|
156
|
+
- Diagnostics archives are encrypted (RSA-4096 + AES-256-GCM); decrypt with `node scripts/decrypt-diagnostics.mjs <file>.tar.gz.enc`
|
|
157
|
+
- Always check archive completeness before analysis -- missing runtime logs means the plugin wasn't running
|
|
158
|
+
- Check if debug mode is enabled (`enableDetailedLogging`); if disabled, ask the user to enable it and re-export
|
|
159
|
+
- Narrow down whether the issue is in `homebridge-eufy-security` (accessory registration, HomeKit mapping, config handling) or in `eufy-security-client` (device discovery, property events, P2P, push notifications)
|
|
160
|
+
- If the environment indicates HOOBS: label `hoobs` + `wontfix` and close -- HOOBS is not supported
|
|
161
|
+
|
|
162
|
+
### Label recommendations
|
|
163
|
+
|
|
164
|
+
| Label | When to use |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `depends on eufy-security-client` | Issue originates in bropat's eufy-security-client library |
|
|
167
|
+
| `device-support` | New device type support request |
|
|
168
|
+
| `debug log missing` | Diagnostics lack logs or debug mode was disabled |
|
|
169
|
+
| `configuration issue` | Problem caused by user config |
|
|
170
|
+
| `livestream` | Camera livestream, video feed, P2P, RTSP, streaming failures |
|
|
171
|
+
| `question` | Further information is requested |
|
|
172
|
+
| `resolved in beta` | Fix already in current beta |
|
|
173
|
+
| `needs triage` | New issue awaiting initial analysis |
|
|
174
|
+
| `duplicate` | Issue or PR already exists |
|
|
175
|
+
| `hoobs` | HOOBS-specific -- label as `hoobs` + `wontfix` and close |
|
package/.claude/PRD.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# PRD -- homebridge-eufy-security
|
|
2
|
+
|
|
3
|
+
Product Requirements Document for `@homebridge-plugins/homebridge-eufy-security`.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Expose Eufy Security devices to Apple HomeKit via Homebridge. Users control cameras, doorbells, locks, sensors, base stations, and delivery boxes from the Home app -- including live video, HomeKit Secure Video recording, arm/disarm, and two-way audio.
|
|
8
|
+
|
|
9
|
+
## Target Users
|
|
10
|
+
|
|
11
|
+
Homebridge users with Eufy Security hardware who want native HomeKit integration without Eufy's official HomeKit firmware (limited or unavailable for most devices).
|
|
12
|
+
|
|
13
|
+
## System Requirements
|
|
14
|
+
|
|
15
|
+
| Requirement | Value |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Node.js | 20, 22, or 24 |
|
|
18
|
+
| Homebridge | >=1.9.0 or ^2.0.0-beta |
|
|
19
|
+
| Eufy Account | Dedicated guest account (admin accounts blocked) |
|
|
20
|
+
| FFmpeg | Bundled via `ffmpeg-for-homebridge` |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Functional Requirements
|
|
25
|
+
|
|
26
|
+
### FR-1: Device Discovery & Registration
|
|
27
|
+
|
|
28
|
+
- Connect to Eufy cloud via `eufy-security-client` (cloud API, P2P, push notifications, MQTT)
|
|
29
|
+
- Discover stations and devices automatically on plugin startup
|
|
30
|
+
- Batch device processing with 10-second debounce to avoid thrashing during sync
|
|
31
|
+
- Hot-add/remove devices after initial discovery completes
|
|
32
|
+
- Restore cached accessories across Homebridge restarts
|
|
33
|
+
- Prune stale cached accessories when `cleanCache: true`
|
|
34
|
+
- Devices can stack multiple capabilities (camera + motion sensor + doorbell) via independent registration blocks
|
|
35
|
+
|
|
36
|
+
### FR-2: Camera Streaming
|
|
37
|
+
|
|
38
|
+
#### FR-2.1: Live Streaming
|
|
39
|
+
- P2P direct stream (default, low latency)
|
|
40
|
+
- RTSP stream (opt-in per camera)
|
|
41
|
+
- FFmpeg transcoding to H.264 + AAC-ELD with SRTP encryption
|
|
42
|
+
- Hardware encoder detection: VideoToolbox (macOS), V4L2 (Raspberry Pi), VAAPI/QSV (Linux)
|
|
43
|
+
- Fallback to libx264 software encoding
|
|
44
|
+
- Configurable max resolution, bitrate, frame rate
|
|
45
|
+
- Max concurrent streams per camera (default 2)
|
|
46
|
+
- Configurable livestream duration (default 30s, max 86400s)
|
|
47
|
+
- RTCP keep-alive monitoring with inactivity timeout
|
|
48
|
+
|
|
49
|
+
#### FR-2.2: HomeKit Secure Video (HKSV)
|
|
50
|
+
- Record motion/doorbell events as fMP4 fragments
|
|
51
|
+
- 4-second segment length (HomeKit requirement)
|
|
52
|
+
- 8-second timeshift buffer for pre-motion capture
|
|
53
|
+
- Audio recording (AAC-ELD or AAC-LC per HomeKit config)
|
|
54
|
+
- Snapshot capture during active recording
|
|
55
|
+
- Max 3 segment errors before connection reset
|
|
56
|
+
|
|
57
|
+
#### FR-2.3: Snapshots
|
|
58
|
+
- Four handling modes: AlwaysFresh, Balanced, CloudOnly (default), Auto
|
|
59
|
+
- Intelligent caching with configurable thresholds (fresh: 15s, balanced: 30s)
|
|
60
|
+
- Placeholder images for offline/disabled/unavailable states
|
|
61
|
+
- Cloud snapshot skip within 30s of livestream capture (prevents quality degradation)
|
|
62
|
+
|
|
63
|
+
#### FR-2.4: Two-Way Audio (Talkback)
|
|
64
|
+
- Bidirectional audio via duplex stream
|
|
65
|
+
- Caches audio data until device is ready
|
|
66
|
+
- 2-second silence auto-stop
|
|
67
|
+
- Configurable channel count (mono default)
|
|
68
|
+
|
|
69
|
+
### FR-3: Security System (Stations)
|
|
70
|
+
|
|
71
|
+
- Map Eufy guard modes to HomeKit security states (Stay, Away, Night, Off)
|
|
72
|
+
- Per-station guard mode mapping (configurable numeric mode values)
|
|
73
|
+
- Manual alarm trigger with configurable duration and HomeKit mode filter
|
|
74
|
+
- Alarm arm delay and alarm event handling via push notifications
|
|
75
|
+
- Multi-station sync via virtual AutoSyncStationAccessory (opt-in)
|
|
76
|
+
|
|
77
|
+
### FR-4: Locks
|
|
78
|
+
|
|
79
|
+
- Lock/unlock control via HomeKit LockMechanism service
|
|
80
|
+
- Lock jammed state detection via push notifications
|
|
81
|
+
- Lock management service (auto-security timeout, admin-only access)
|
|
82
|
+
|
|
83
|
+
### FR-5: Sensors
|
|
84
|
+
|
|
85
|
+
#### FR-5.1: Motion Sensors
|
|
86
|
+
- Standalone motion detection service
|
|
87
|
+
- Camera-integrated motion with configurable timeout
|
|
88
|
+
- Multi-event support: person, pet, vehicle, sound, crying, dog, stranger
|
|
89
|
+
|
|
90
|
+
#### FR-5.2: Entry Sensors (Contact Sensors)
|
|
91
|
+
- Door/window open/closed state
|
|
92
|
+
|
|
93
|
+
### FR-6: Doorbells
|
|
94
|
+
|
|
95
|
+
- ProgrammableSwitchEvent on ring
|
|
96
|
+
- Optional motion-triggers-doorbell mode
|
|
97
|
+
- Optional indoor chime control switch
|
|
98
|
+
- Snapshot delay on doorbell ring (configurable)
|
|
99
|
+
|
|
100
|
+
### FR-7: Floodlights
|
|
101
|
+
|
|
102
|
+
- Lightbulb service for floodlight control
|
|
103
|
+
- Combined camera + light capabilities
|
|
104
|
+
|
|
105
|
+
### FR-8: Smart Drop (Package Boxes)
|
|
106
|
+
|
|
107
|
+
- One-way open via LockMechanism
|
|
108
|
+
- Package delivery detection via ContactSensor
|
|
109
|
+
|
|
110
|
+
### FR-9: Per-Device Switches
|
|
111
|
+
|
|
112
|
+
- Enable/disable device switch
|
|
113
|
+
- Motion detection toggle switch
|
|
114
|
+
- Light control switch (floodlights)
|
|
115
|
+
- Indoor chime toggle switch
|
|
116
|
+
- All switches individually configurable per camera
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Configuration Requirements
|
|
121
|
+
|
|
122
|
+
### CR-1: Global Configuration
|
|
123
|
+
- Eufy credentials (username, password, device name)
|
|
124
|
+
- Country code (ISO 3166-1 alpha-2)
|
|
125
|
+
- Polling interval (default 10 minutes)
|
|
126
|
+
- Global guard mode mapping (hkHome, hkAway, hkNight, hkOff)
|
|
127
|
+
- Device/station ignore lists by serial number
|
|
128
|
+
- Debug logging toggle (`enableDetailedLogging`)
|
|
129
|
+
- Log file opt-out (`omitLogFiles`)
|
|
130
|
+
- Cache cleanup toggle (`cleanCache`, default true)
|
|
131
|
+
- Auto-sync station mode toggle
|
|
132
|
+
- Embedded PKCS1 support toggle (Node.js <24.5 workaround)
|
|
133
|
+
|
|
134
|
+
### CR-2: Per-Camera Configuration
|
|
135
|
+
- Stream source: P2P or RTSP
|
|
136
|
+
- Enable/disable camera streaming entirely
|
|
137
|
+
- Snapshot handling method (AlwaysFresh, Balanced, CloudOnly, Auto)
|
|
138
|
+
- Audio enable/disable
|
|
139
|
+
- Talkback enable/disable with channel count
|
|
140
|
+
- HKSV recording duration
|
|
141
|
+
- Motion timeout
|
|
142
|
+
- Per-switch visibility (enable, motion, light, indoor chime)
|
|
143
|
+
- Full FFmpeg video config override (codec, resolution, bitrate, filters, encoder options, custom binary path)
|
|
144
|
+
|
|
145
|
+
### CR-3: Per-Station Configuration
|
|
146
|
+
- Guard mode mapping overrides (hkHome, hkAway, hkNight, hkOff)
|
|
147
|
+
- Manual alarm trigger modes and duration
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Plugin UI Requirements
|
|
152
|
+
|
|
153
|
+
### UI-1: Device Discovery
|
|
154
|
+
- Login flow with TFA and captcha support
|
|
155
|
+
- Discovery progress reporting (authenticating, queuing, processing, done)
|
|
156
|
+
- Skip button for unsupported device intel wait
|
|
157
|
+
- Admin account detection and blocking
|
|
158
|
+
|
|
159
|
+
### UI-2: Device Management
|
|
160
|
+
- Display discovered stations and devices with type, capabilities, power status
|
|
161
|
+
- Show unsupported devices separately
|
|
162
|
+
- Detect running plugin via heartbeat (accessories.json `storedAt` < 90s old)
|
|
163
|
+
- Load stored accessories from cache when plugin is not running
|
|
164
|
+
|
|
165
|
+
### UI-3: Diagnostics
|
|
166
|
+
- Generate encrypted diagnostics archive (RSA-4096 + AES-256-GCM)
|
|
167
|
+
- Rate-limited to 60-second minimum between downloads
|
|
168
|
+
- Archive includes: config (sanitized), all log files, accessories.json, system info
|
|
169
|
+
- Decryptable via `node scripts/decrypt-diagnostics.mjs`
|
|
170
|
+
|
|
171
|
+
### UI-4: Storage Management
|
|
172
|
+
- Reset plugin storage (persistent.json, accessories.json)
|
|
173
|
+
- Clean all storage option
|
|
174
|
+
- System info endpoint (plugin version, Node.js version, host OS)
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Non-Functional Requirements
|
|
179
|
+
|
|
180
|
+
### NFR-1: Logging
|
|
181
|
+
- Rotating file streams (daily rotation, max 3 archives, 200MB limit)
|
|
182
|
+
- Styled console output (color-coded by level)
|
|
183
|
+
- Debug mode adds file:line references and library-level logging
|
|
184
|
+
- Separate log streams: plugin, library, UI server, UI library, FFmpeg (global + per-camera + snapshots)
|
|
185
|
+
|
|
186
|
+
### NFR-2: Reliability
|
|
187
|
+
- Connection retry (3 attempts, 30s backoff) on Eufy cloud failure
|
|
188
|
+
- P2P stream retry with exponential backoff (2-10s, max 3 attempts, 15s timeout per attempt)
|
|
189
|
+
- Multi-consumer stream sharing via reference counting (streaming, recording, snapshots share one P2P connection)
|
|
190
|
+
- 5-second grace period before stopping shared P2P stream
|
|
191
|
+
- Node.js MaxListeners raised to 30 for multi-camera setups
|
|
192
|
+
- fMP4 box validation (max 50MB per box) during HKSV recording
|
|
193
|
+
|
|
194
|
+
### NFR-3: Compatibility
|
|
195
|
+
- ESM module (`"type": "module"`, `"module": "NodeNext"`)
|
|
196
|
+
- TypeScript strict mode, ES2022 target
|
|
197
|
+
- PKCS1 padding workaround for Node.js 20/22 (restored natively in Node.js 24.5+)
|
|
198
|
+
- Hardware codec probing at startup with graceful software fallback
|
|
199
|
+
|
|
200
|
+
### NFR-4: Security
|
|
201
|
+
- Encrypted credential persistence (never logged)
|
|
202
|
+
- Guest account enforcement (admin account usage blocked)
|
|
203
|
+
- TFA/captcha graceful handling with shutdown and re-auth prompt
|
|
204
|
+
- Diagnostics archives encrypted before export
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Architecture Boundaries
|
|
209
|
+
|
|
210
|
+
### homebridge-eufy-security (this plugin)
|
|
211
|
+
- Accessory registration and HomeKit service mapping
|
|
212
|
+
- FFmpeg transcoding pipeline
|
|
213
|
+
- Configuration handling and validation
|
|
214
|
+
- Plugin UI (device discovery, diagnostics, storage management)
|
|
215
|
+
- accessories.json persistence for UI communication
|
|
216
|
+
|
|
217
|
+
### eufy-security-client (upstream dependency)
|
|
218
|
+
- Eufy cloud API authentication and communication
|
|
219
|
+
- P2P connection establishment and stream management
|
|
220
|
+
- Push notification and MQTT event handling
|
|
221
|
+
- Device type classification and property management
|
|
222
|
+
- Command execution (arm/disarm, lock/unlock, etc.)
|
|
223
|
+
|
|
224
|
+
Issues must be triaged to the correct layer. The plugin communicates with the library via events (`station added`, `device added`, `property changed`, push events) and commands.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Device Type Coverage
|
|
229
|
+
|
|
230
|
+
| Category | HomeKit Services |
|
|
231
|
+
|---|---|
|
|
232
|
+
| Cameras | CameraRTPStreamManagement, MotionSensor, optional Switches |
|
|
233
|
+
| Doorbells | Doorbell + Camera services, ProgrammableSwitchEvent |
|
|
234
|
+
| Floodlights | Camera + Lightbulb services |
|
|
235
|
+
| Base Stations | SecuritySystem (arm/disarm), optional manual alarm Switch |
|
|
236
|
+
| Smart Locks | LockMechanism, LockManagement |
|
|
237
|
+
| Entry Sensors | ContactSensor |
|
|
238
|
+
| Motion Sensors | MotionSensor |
|
|
239
|
+
| Smart Drop | LockMechanism (open-only), ContactSensor (package detect) |
|
|
240
|
+
| Video Locks | Camera + Lock services (LockWifiVideo) |
|
|
241
|
+
| Auto-Sync Station | Virtual SecuritySystem syncing multiple stations |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architect
|
|
3
|
+
description: Answer quick architectural questions, debug mini-issues, explore the codebase, and help improve skills and workflows. Use this skill when the user asks "how does X work", "where is Y", "why does Z happen", wants to understand code flow, trace a bug through the system, or asks about the relationship between components. Also use when the user wants to improve an existing skill or refine development workflows. This is the lightweight, exploratory counterpart to the planner -- use it for questions and small fixes, not multi-file changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architect
|
|
7
|
+
|
|
8
|
+
You are an architectural advisor for homebridge-eufy-security. You answer questions quickly, trace code paths, debug small issues, and help refine the development workflow. You are the "thinking" mode -- fast, focused, and precise.
|
|
9
|
+
|
|
10
|
+
Refer to CLAUDE.md for the full architecture and project conventions.
|
|
11
|
+
|
|
12
|
+
## What you do
|
|
13
|
+
|
|
14
|
+
### Codebase exploration
|
|
15
|
+
|
|
16
|
+
When the user asks "how does X work" or "where is Y":
|
|
17
|
+
|
|
18
|
+
1. Search the codebase (Glob, Grep) to find the relevant code
|
|
19
|
+
2. Read the key files
|
|
20
|
+
3. Explain the flow concisely with file:line references
|
|
21
|
+
4. Draw the path through the system if it crosses multiple files
|
|
22
|
+
|
|
23
|
+
Quick-reference starting points:
|
|
24
|
+
|
|
25
|
+
| Question | Start here |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Device discovery? | `src/platform.ts` -- `onStationAdded`, `onDeviceAdded`, `register_device` |
|
|
28
|
+
| Streaming? | `src/controller/streamingDelegate.ts` -> `LocalLivestreamManager.ts` |
|
|
29
|
+
| HKSV recording? | `src/controller/recordingDelegate.ts` |
|
|
30
|
+
| Snapshots? | `src/controller/snapshotDelegate.ts` |
|
|
31
|
+
| UI <-> plugin? | `src/utils/accessoriesStore.ts` -> `homebridge-ui/server.js` |
|
|
32
|
+
| Arm/disarm? | `src/accessories/StationAccessory.ts` |
|
|
33
|
+
| Two-way audio? | `src/utils/Talkback.ts` |
|
|
34
|
+
|
|
35
|
+
### Mini-bug debugging
|
|
36
|
+
|
|
37
|
+
For small, contained bugs:
|
|
38
|
+
|
|
39
|
+
1. Reproduce the understanding -- what's expected vs what happens?
|
|
40
|
+
2. Trace the code path from trigger to symptom
|
|
41
|
+
3. Identify the root cause with file:line reference
|
|
42
|
+
4. If it's a one-line fix, suggest it directly
|
|
43
|
+
5. If it's bigger, recommend using the planner skill
|
|
44
|
+
|
|
45
|
+
### Skill and workflow improvement
|
|
46
|
+
|
|
47
|
+
When the user wants to refine skills or workflows:
|
|
48
|
+
|
|
49
|
+
1. Read the current skill/workflow file
|
|
50
|
+
2. Identify what's working and what's not based on user feedback
|
|
51
|
+
3. Suggest specific, minimal changes
|
|
52
|
+
4. Apply changes after user approval
|
|
53
|
+
|
|
54
|
+
### Quick code review
|
|
55
|
+
|
|
56
|
+
When asked to review code or a diff:
|
|
57
|
+
|
|
58
|
+
1. Focus on correctness, not style
|
|
59
|
+
2. Check the architectural boundaries (plugin vs eufy-security-client)
|
|
60
|
+
3. Flag potential issues with file:line references
|
|
61
|
+
4. Don't nitpick -- only flag things that could break or confuse
|
|
62
|
+
|
|
63
|
+
## How to respond
|
|
64
|
+
|
|
65
|
+
- Be concise. Use file:line references.
|
|
66
|
+
- Show the relevant code snippet when it helps understanding.
|
|
67
|
+
- If the answer requires reading more than 3-4 files, use subagents for parallel exploration.
|
|
68
|
+
- If the question turns into a multi-file change request, suggest switching to the planner skill.
|
|
69
|
+
- If you're unsure, say so. Don't speculate about code you haven't read.
|
|
70
|
+
|
|
71
|
+
## What you don't do
|
|
72
|
+
|
|
73
|
+
- Don't make multi-file code changes (use planner -> developer)
|
|
74
|
+
- Don't run builds or lint (use QA skill)
|
|
75
|
+
- Don't create PRs or push code (use the git workflow directly)
|
|
76
|
+
- Don't write lengthy essays -- keep answers tight and actionable
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: developer
|
|
3
|
+
description: Execute code changes following an approved plan or direct user instructions. Use this skill when the user says "implement", "code it", "go ahead", "execute the plan", or when transitioning from the planner skill after approval. Also use for direct coding tasks where the user provides clear, specific instructions. This skill writes clean, correct code respecting all project conventions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Developer
|
|
7
|
+
|
|
8
|
+
You are a code execution agent for homebridge-eufy-security. You write code that is clean, correct, and follows every project convention. You either execute an approved plan from the planner skill, or implement direct user instructions.
|
|
9
|
+
|
|
10
|
+
Follow all conventions in CLAUDE.md (ESM imports, lint, architecture patterns, code style, git workflow).
|
|
11
|
+
|
|
12
|
+
## Before writing any code
|
|
13
|
+
|
|
14
|
+
1. **Read first**: Read every file you intend to modify. Understand existing patterns before touching them.
|
|
15
|
+
2. **Check the plan**: If a plan was approved, follow it exactly. If you spot an issue with the plan during implementation, stop and flag it -- don't silently deviate.
|
|
16
|
+
3. **Branch check**: Verify you're on the correct branch per CLAUDE.md git workflow.
|
|
17
|
+
|
|
18
|
+
## Implementation workflow
|
|
19
|
+
|
|
20
|
+
### Step 1 -- Write the code
|
|
21
|
+
|
|
22
|
+
Make changes file by file, following the plan order. For each file:
|
|
23
|
+
- Use the Edit tool for modifications (not Bash with sed/awk)
|
|
24
|
+
- Use Write only for new files
|
|
25
|
+
- Keep changes minimal and focused
|
|
26
|
+
- Don't add features beyond what was requested
|
|
27
|
+
- Don't refactor surrounding code while fixing a bug
|
|
28
|
+
|
|
29
|
+
### Step 2 -- Self-review
|
|
30
|
+
|
|
31
|
+
After all changes are made, re-read each modified file to verify:
|
|
32
|
+
- No syntax errors
|
|
33
|
+
- Imports use `.js` extensions
|
|
34
|
+
- No accidental duplicate code
|
|
35
|
+
- Changes match the plan
|
|
36
|
+
|
|
37
|
+
### Step 3 -- Verify
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run lint
|
|
41
|
+
npm run build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If either fails, fix the issue immediately. Do not commit code that doesn't lint or build.
|
|
45
|
+
|
|
46
|
+
### Step 4 -- Commit
|
|
47
|
+
|
|
48
|
+
Follow the git workflow from CLAUDE.md. Stage each logical change individually.
|
|
49
|
+
|
|
50
|
+
## When things go wrong
|
|
51
|
+
|
|
52
|
+
- **Lint failure**: Fix the warning. Don't disable the rule.
|
|
53
|
+
- **Build failure**: Read the error. If it's a type error, trace it back. If it's an import error, check `.js` extensions.
|
|
54
|
+
- **Plan doesn't work**: Stop. Explain what you found. Don't improvise a workaround without user approval.
|
|
55
|
+
- **Unclear requirement**: Ask. Don't guess.
|
|
@@ -96,37 +96,25 @@ case <type_number>: return '<image_large>.png';
|
|
|
96
96
|
Execute the plan. Key implementation notes:
|
|
97
97
|
|
|
98
98
|
- **Property mapping**: Use the output from `map-properties.mjs` (Phase 1) as the primary guide. When multiple property constants match the same `param_type` (e.g. `DeviceWatermarkProperty` vs `DeviceWatermarkSoloWiredDoorbellProperty`), pick the variant used by the closest existing device. Check the "Used by DeviceTypes" column in the script output.
|
|
99
|
+
- **Companion custom properties**: Some properties have required companions with `custom_*` keys that never appear in raw device data (they're populated at runtime). The script detects these and marks them with `⚠ companion`. Always include them — omitting a companion breaks functionality silently. Key pairs: `DeviceRTSPStream` → `DeviceRTSPStreamUrl`, `DeviceWifiRSSI` → `DeviceWifiSignalLevel`, `DeviceCellularRSSI` → `DeviceCellularSignalLevel`.
|
|
99
100
|
- **Insert in order**: When adding to enums, switch statements, or `if` chains, maintain numeric ordering by device type number.
|
|
100
101
|
- **Audio recording property**: Different device families use different audio recording property constants (e.g. `DeviceAudioRecordingProperty`, `DeviceAudioRecordingStarlight4gLTEProperty`). Match the closest existing device.
|
|
101
|
-
- **No Co-Authored-By**: Do not add co-author lines to commits.
|
|
102
102
|
|
|
103
103
|
## Phase 4 — Build & Lint Verification
|
|
104
104
|
|
|
105
|
-
Run
|
|
106
|
-
```bash
|
|
107
|
-
cd eufy-security-client && npm run build
|
|
108
|
-
cd homebridge-eufy-security && npm run build
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Then verify lint:
|
|
112
|
-
```bash
|
|
113
|
-
cd eufy-security-client && npm run lint
|
|
114
|
-
cd homebridge-eufy-security && npm run lint
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Note: eufy-security-client lint may fail due to a pre-existing `jiti` library issue unrelated to our changes. The TypeScript build succeeding is sufficient validation.
|
|
105
|
+
Run build and lint for both repos. Note: eufy-security-client lint may fail due to a pre-existing `jiti` library issue unrelated to our changes — the TypeScript build succeeding is sufficient validation.
|
|
118
106
|
|
|
119
107
|
## Phase 5 — Git & PR
|
|
120
108
|
|
|
121
|
-
|
|
109
|
+
Follow CLAUDE.md Git Workflow for commit messages, branch naming, and PR body format. This skill creates **two PRs** across repos:
|
|
110
|
+
|
|
111
|
+
### eufy-security-client (cross-fork)
|
|
122
112
|
|
|
123
|
-
1. Discard
|
|
124
|
-
2. Sync develop
|
|
125
|
-
3.
|
|
126
|
-
4. Stage only
|
|
127
|
-
5.
|
|
128
|
-
6. Push: `git push origin feat/<device-slug>`
|
|
129
|
-
7. Create cross-fork PR:
|
|
113
|
+
1. Discard unrelated changes (e.g. `package-lock.json`)
|
|
114
|
+
2. Sync develop: `git fetch upstream && git checkout develop && git merge upstream/develop`
|
|
115
|
+
3. Branch: `git checkout -b feat/<device-slug>`
|
|
116
|
+
4. Stage only: images, `src/http/types.ts`, `src/http/device.ts`, `src/push/service.ts`, `docs/supported_devices.md`
|
|
117
|
+
5. Cross-fork PR:
|
|
130
118
|
```bash
|
|
131
119
|
gh pr create --repo bropat/eufy-security-client --base develop \
|
|
132
120
|
--head lenoxys:feat/<device-slug> \
|
|
@@ -136,26 +124,9 @@ Note: eufy-security-client lint may fail due to a pre-existing `jiti` library is
|
|
|
136
124
|
|
|
137
125
|
### homebridge-eufy-security
|
|
138
126
|
|
|
139
|
-
1. Branch from
|
|
127
|
+
1. Branch from current beta: `git checkout -b feat/<device-slug>`
|
|
140
128
|
2. Stage: `homebridge-ui/public/utils/device-images.js` + any added image
|
|
141
|
-
3. Commit: `git commit -m "feat: add <Device Name> (<Model>, type <number>) device image mapping"`
|
|
142
|
-
4. Push: `git push origin feat/<device-slug>`
|
|
143
|
-
5. Create PR:
|
|
144
|
-
```bash
|
|
145
|
-
gh pr create --repo homebridge-plugins/homebridge-eufy-security \
|
|
146
|
-
--base <beta-branch> \
|
|
147
|
-
--title "feat: add <Device Name> (<Model>, type <number>) device image" \
|
|
148
|
-
--body-file /tmp/pr-body-<branch>.md
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### PR body format
|
|
152
|
-
|
|
153
|
-
Write PR bodies to `/tmp/pr-body-<branch>.md` files. Include:
|
|
154
|
-
- `## Summary` — bullet points describing the changes
|
|
155
|
-
- Cross-references: `Closes homebridge-plugins/homebridge-eufy-security#<issue>` in the client PR, `Closes #<issue>` in the plugin PR
|
|
156
|
-
- `Depends on bropat/eufy-security-client#<pr>` in the plugin PR
|
|
157
|
-
- `## Test plan` — checklist of verification steps
|
|
158
129
|
|
|
159
|
-
###
|
|
130
|
+
### Cross-referencing
|
|
160
131
|
|
|
161
|
-
After both PRs are created, update both
|
|
132
|
+
After both PRs are created, update both bodies so they reference each other.
|