homebridge-dahua-ultimate 1.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.
- homebridge-dahua-ultimate/.gitignore +9 -0
- homebridge-dahua-ultimate/.npmignore +11 -0
- homebridge-dahua-ultimate/CHANGELOG.md +38 -0
- homebridge-dahua-ultimate/DEPLOYMENT.md +309 -0
- homebridge-dahua-ultimate/README.md +340 -0
- homebridge-dahua-ultimate/config.schema.json +292 -0
- homebridge-dahua-ultimate/package.json +43 -0
- homebridge-dahua-ultimate/src/accessories/camera.ts +179 -0
- homebridge-dahua-ultimate/src/configTypes.ts +201 -0
- homebridge-dahua-ultimate/src/dahua/api.ts +307 -0
- homebridge-dahua-ultimate/src/dahua/discovery.ts +241 -0
- homebridge-dahua-ultimate/src/dahua/events.ts +244 -0
- homebridge-dahua-ultimate/src/ffmpeg/path.ts +95 -0
- homebridge-dahua-ultimate/src/ffmpeg/probe.ts +134 -0
- homebridge-dahua-ultimate/src/index.ts +10 -0
- homebridge-dahua-ultimate/src/platform.ts +241 -0
- homebridge-dahua-ultimate/src/settings.ts +87 -0
- homebridge-dahua-ultimate/src/streaming/delegate.ts +589 -0
- homebridge-dahua-ultimate/src/streaming/hksvHelpers.ts +97 -0
- homebridge-dahua-ultimate/src/streaming/prebuffer.ts +206 -0
- homebridge-dahua-ultimate/src/streaming/recordingDelegate.ts +478 -0
- homebridge-dahua-ultimate/tsconfig.json +25 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2026-02-15
|
|
6
|
+
|
|
7
|
+
### Initial Release
|
|
8
|
+
|
|
9
|
+
#### Features
|
|
10
|
+
- ✅ Automatic camera discovery from Dahua NVR
|
|
11
|
+
- ✅ Hardware-accelerated streaming (VAAPI/VideoToolbox/NVENC/OMX)
|
|
12
|
+
- ✅ Real-time motion detection events
|
|
13
|
+
- ✅ IVS event support (line crossing, intrusion detection)
|
|
14
|
+
- ✅ HomeKit Secure Video (HKSV) recording support
|
|
15
|
+
- ✅ Multiple stream types (main/sub/third stream)
|
|
16
|
+
- ✅ Zero-configuration autodiscovery
|
|
17
|
+
- ✅ Full digest authentication support
|
|
18
|
+
- ✅ Automatic reconnection on network errors
|
|
19
|
+
- ✅ Comprehensive error handling and logging
|
|
20
|
+
|
|
21
|
+
#### Supported Devices
|
|
22
|
+
- Dahua NVR (all models)
|
|
23
|
+
- Dahua DVR (all models)
|
|
24
|
+
- Dahua IP Cameras (when connected to NVR)
|
|
25
|
+
- OEM brands: Lorex, Amcrest, Honeywell
|
|
26
|
+
|
|
27
|
+
#### Known Limitations
|
|
28
|
+
- Advanced AI events (face detection, ANPR) not yet implemented
|
|
29
|
+
- PTZ control not yet implemented
|
|
30
|
+
- Audio two-way communication not yet implemented
|
|
31
|
+
|
|
32
|
+
#### Dependencies
|
|
33
|
+
- Homebridge >= 1.6.0
|
|
34
|
+
- Node.js >= 18.17.0
|
|
35
|
+
- FFmpeg (required for streaming)
|
|
36
|
+
|
|
37
|
+
#### Acknowledgments
|
|
38
|
+
Based on homebridge-hikvision-ultimate plugin architecture.
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# Deployment Guide - Homebridge Dahua Ultimate v1.0.0
|
|
2
|
+
|
|
3
|
+
## Pre-Release Checklist
|
|
4
|
+
|
|
5
|
+
### 1. Code Review
|
|
6
|
+
- [ ] All TypeScript files compile without errors
|
|
7
|
+
- [ ] No console.log statements (use proper logging)
|
|
8
|
+
- [ ] Error handling implemented for all API calls
|
|
9
|
+
- [ ] Memory leaks checked (event listeners cleaned up)
|
|
10
|
+
|
|
11
|
+
### 2. Testing Checklist
|
|
12
|
+
|
|
13
|
+
#### Discovery Testing
|
|
14
|
+
- [ ] Test autodiscovery with 1 camera
|
|
15
|
+
- [ ] Test autodiscovery with 4+ cameras
|
|
16
|
+
- [ ] Test autodiscovery with 16+ cameras
|
|
17
|
+
- [ ] Verify channel names are correct
|
|
18
|
+
- [ ] Verify device info is retrieved
|
|
19
|
+
|
|
20
|
+
#### Streaming Testing
|
|
21
|
+
- [ ] Test main stream (1080p/4MP)
|
|
22
|
+
- [ ] Test sub stream (720p/D1)
|
|
23
|
+
- [ ] Test third stream (if available)
|
|
24
|
+
- [ ] Test with VAAPI hardware encoding
|
|
25
|
+
- [ ] Test with software encoding
|
|
26
|
+
- [ ] Test audio streaming
|
|
27
|
+
|
|
28
|
+
#### Motion Detection Testing
|
|
29
|
+
- [ ] Verify motion events trigger
|
|
30
|
+
- [ ] Verify motion events clear after timeout
|
|
31
|
+
- [ ] Test with multiple cameras simultaneously
|
|
32
|
+
- [ ] Test event stream reconnection after network loss
|
|
33
|
+
- [ ] Test IVS line crossing events
|
|
34
|
+
- [ ] Test IVS intrusion events
|
|
35
|
+
|
|
36
|
+
#### Edge Cases
|
|
37
|
+
- [ ] Test with NVR offline (graceful failure)
|
|
38
|
+
- [ ] Test with incorrect credentials
|
|
39
|
+
- [ ] Test with camera disconnected
|
|
40
|
+
- [ ] Test Homebridge restart
|
|
41
|
+
- [ ] Test network interruption/recovery
|
|
42
|
+
|
|
43
|
+
### 3. Build and Package
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cd homebridge-dahua-ultimate
|
|
47
|
+
|
|
48
|
+
# Install dependencies
|
|
49
|
+
npm install
|
|
50
|
+
|
|
51
|
+
# Build TypeScript
|
|
52
|
+
npm run build
|
|
53
|
+
|
|
54
|
+
# Verify dist/ directory created
|
|
55
|
+
ls -la dist/
|
|
56
|
+
|
|
57
|
+
# Test locally before publishing
|
|
58
|
+
npm link
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Local Testing
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Link plugin locally
|
|
65
|
+
npm link
|
|
66
|
+
|
|
67
|
+
# In your homebridge config
|
|
68
|
+
{
|
|
69
|
+
"platforms": [{
|
|
70
|
+
"platform": "DahuaUltimate",
|
|
71
|
+
"host": "192.168.1.100",
|
|
72
|
+
"username": "admin",
|
|
73
|
+
"password": "password"
|
|
74
|
+
}]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# Restart Homebridge
|
|
78
|
+
sudo systemctl restart homebridge
|
|
79
|
+
|
|
80
|
+
# Monitor logs
|
|
81
|
+
tail -f /var/lib/homebridge/homebridge.log
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 5. Verification Tests
|
|
85
|
+
|
|
86
|
+
Run these tests with your actual Dahua NVR:
|
|
87
|
+
|
|
88
|
+
#### Test 1: Discovery
|
|
89
|
+
```bash
|
|
90
|
+
# Expected output:
|
|
91
|
+
# [Dahua] ✅ Connected to Dahua NVR: NVR5216-16P-4KS2 (...)
|
|
92
|
+
# [Dahua] 🔍 Discovering cameras from Dahua NVR...
|
|
93
|
+
# [Dahua] Found 8 camera(s)
|
|
94
|
+
# [Dahua] Adding new camera: Front Door (Channel 1)
|
|
95
|
+
# ...
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Test 2: Streaming
|
|
99
|
+
```bash
|
|
100
|
+
# Open Home app
|
|
101
|
+
# Select any camera
|
|
102
|
+
# Video should start within 2-3 seconds
|
|
103
|
+
# No buffering or stuttering
|
|
104
|
+
# Audio should work (if enabled)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Test 3: Motion Detection
|
|
108
|
+
```bash
|
|
109
|
+
# Expected in logs:
|
|
110
|
+
# [Dahua] 🎬 Starting motion event stream...
|
|
111
|
+
# [Dahua] ✅ Event stream connected and receiving data
|
|
112
|
+
# [Dahua] 👂 Registered listeners for 8 camera(s)
|
|
113
|
+
|
|
114
|
+
# Trigger motion on camera:
|
|
115
|
+
# [Dahua] 🚨 Motion event: channel=1, type=VideoMotion, active=true
|
|
116
|
+
# [Dahua] 📢 Notifying 1 listener(s) for channel 1
|
|
117
|
+
# [Front Door] Motion detected
|
|
118
|
+
|
|
119
|
+
# In Home app:
|
|
120
|
+
# Motion sensor should show "Motion Detected"
|
|
121
|
+
# After timeout:
|
|
122
|
+
# [Dahua] 🚨 Motion event: channel=1, type=VideoMotion, active=false
|
|
123
|
+
# Motion sensor should clear
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Publishing to NPM
|
|
127
|
+
|
|
128
|
+
### First Time Setup
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Create NPM account if needed
|
|
132
|
+
npm adduser
|
|
133
|
+
|
|
134
|
+
# Verify login
|
|
135
|
+
npm whoami
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Publish Steps
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
cd homebridge-dahua-ultimate
|
|
142
|
+
|
|
143
|
+
# Ensure clean build
|
|
144
|
+
rm -rf dist node_modules
|
|
145
|
+
npm install
|
|
146
|
+
npm run build
|
|
147
|
+
|
|
148
|
+
# Verify package contents
|
|
149
|
+
npm pack
|
|
150
|
+
tar -tzf homebridge-dahua-ultimate-1.0.0.tgz
|
|
151
|
+
|
|
152
|
+
# Should include:
|
|
153
|
+
# - dist/
|
|
154
|
+
# - config.schema.json
|
|
155
|
+
# - package.json
|
|
156
|
+
# - README.md
|
|
157
|
+
# - CHANGELOG.md
|
|
158
|
+
|
|
159
|
+
# Publish to NPM
|
|
160
|
+
npm publish
|
|
161
|
+
|
|
162
|
+
# Or for testing, publish with tag
|
|
163
|
+
npm publish --tag beta
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Post-Publish Verification
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Install from NPM
|
|
170
|
+
npm install -g homebridge-dahua-ultimate
|
|
171
|
+
|
|
172
|
+
# Verify installation
|
|
173
|
+
npm list -g homebridge-dahua-ultimate
|
|
174
|
+
|
|
175
|
+
# Test with fresh install
|
|
176
|
+
# (on different machine or VM)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Homebridge Verified Plugin Submission
|
|
180
|
+
|
|
181
|
+
### Requirements
|
|
182
|
+
|
|
183
|
+
1. **Plugin must be published to NPM**
|
|
184
|
+
2. **Working config.schema.json**
|
|
185
|
+
3. **Clear README with setup instructions**
|
|
186
|
+
4. **Test with Homebridge Config UI X**
|
|
187
|
+
5. **No critical bugs**
|
|
188
|
+
|
|
189
|
+
### Submission Process
|
|
190
|
+
|
|
191
|
+
1. Go to https://github.com/homebridge/homebridge/wiki/Request-Verification
|
|
192
|
+
2. Create verification request
|
|
193
|
+
3. Provide:
|
|
194
|
+
- NPM package name: `homebridge-dahua-ultimate`
|
|
195
|
+
- GitHub repository URL
|
|
196
|
+
- Test results
|
|
197
|
+
- Screenshots of working plugin
|
|
198
|
+
|
|
199
|
+
## Version Management
|
|
200
|
+
|
|
201
|
+
### Semantic Versioning
|
|
202
|
+
|
|
203
|
+
- `1.0.0` - Initial release
|
|
204
|
+
- `1.0.1` - Bug fixes
|
|
205
|
+
- `1.1.0` - New features (backwards compatible)
|
|
206
|
+
- `2.0.0` - Breaking changes
|
|
207
|
+
|
|
208
|
+
### Release Process
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Bug fix
|
|
212
|
+
npm version patch
|
|
213
|
+
npm publish
|
|
214
|
+
|
|
215
|
+
# New feature
|
|
216
|
+
npm version minor
|
|
217
|
+
npm publish
|
|
218
|
+
|
|
219
|
+
# Breaking change
|
|
220
|
+
npm version major
|
|
221
|
+
npm publish
|
|
222
|
+
|
|
223
|
+
# Always push tags
|
|
224
|
+
git push --tags
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Maintenance
|
|
228
|
+
|
|
229
|
+
### Monthly Tasks
|
|
230
|
+
- [ ] Update dependencies
|
|
231
|
+
- [ ] Review open issues
|
|
232
|
+
- [ ] Test with latest Homebridge version
|
|
233
|
+
- [ ] Update README if needed
|
|
234
|
+
|
|
235
|
+
### Quarterly Tasks
|
|
236
|
+
- [ ] Review API compatibility
|
|
237
|
+
- [ ] Check for new Dahua API features
|
|
238
|
+
- [ ] Performance optimization review
|
|
239
|
+
- [ ] Security audit
|
|
240
|
+
|
|
241
|
+
## Support Channels
|
|
242
|
+
|
|
243
|
+
1. **GitHub Issues** - Bug reports and feature requests
|
|
244
|
+
2. **Homebridge Discord** - Community support
|
|
245
|
+
3. **NPM Page** - Package information
|
|
246
|
+
|
|
247
|
+
## Success Metrics
|
|
248
|
+
|
|
249
|
+
Track these after release:
|
|
250
|
+
|
|
251
|
+
- [ ] NPM downloads per week
|
|
252
|
+
- [ ] GitHub stars
|
|
253
|
+
- [ ] Issue open/close rate
|
|
254
|
+
- [ ] User satisfaction (Discord feedback)
|
|
255
|
+
- [ ] Verified badge obtained
|
|
256
|
+
|
|
257
|
+
## Rollback Plan
|
|
258
|
+
|
|
259
|
+
If critical bugs found after release:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Unpublish version (within 72 hours)
|
|
263
|
+
npm unpublish homebridge-dahua-ultimate@1.0.0
|
|
264
|
+
|
|
265
|
+
# Or deprecate
|
|
266
|
+
npm deprecate homebridge-dahua-ultimate@1.0.0 "Critical bug - use 1.0.1"
|
|
267
|
+
|
|
268
|
+
# Publish fixed version
|
|
269
|
+
npm version patch
|
|
270
|
+
npm publish
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Documentation Links
|
|
274
|
+
|
|
275
|
+
- NPM Package: https://www.npmjs.com/package/homebridge-dahua-ultimate
|
|
276
|
+
- GitHub Repo: https://github.com/yourusername/homebridge-dahua-ultimate
|
|
277
|
+
- Homebridge Wiki: https://github.com/homebridge/homebridge/wiki
|
|
278
|
+
|
|
279
|
+
## Common Issues During Testing
|
|
280
|
+
|
|
281
|
+
### Issue: "Cannot find module"
|
|
282
|
+
**Solution**: Run `npm run build` before testing
|
|
283
|
+
|
|
284
|
+
### Issue: Motion events not triggering
|
|
285
|
+
**Solution**:
|
|
286
|
+
1. Check `debugMotion: true`
|
|
287
|
+
2. Verify event stream connected
|
|
288
|
+
3. Test motion in camera web UI first
|
|
289
|
+
|
|
290
|
+
### Issue: High CPU usage
|
|
291
|
+
**Solution**:
|
|
292
|
+
1. Verify hardware encoder is working
|
|
293
|
+
2. Check `vainfo` output
|
|
294
|
+
3. Try software encoder as fallback
|
|
295
|
+
|
|
296
|
+
### Issue: Cameras not discovered
|
|
297
|
+
**Solution**:
|
|
298
|
+
1. Test API endpoint manually with curl
|
|
299
|
+
2. Check NVR firmware version
|
|
300
|
+
3. Verify digest authentication working
|
|
301
|
+
|
|
302
|
+
## Next Steps After v1.0.0
|
|
303
|
+
|
|
304
|
+
Planned features for future releases:
|
|
305
|
+
|
|
306
|
+
- **v1.1.0**: PTZ control support
|
|
307
|
+
- **v1.2.0**: Audio two-way communication
|
|
308
|
+
- **v1.3.0**: Advanced AI events (face detection, ANPR)
|
|
309
|
+
- **v2.0.0**: Multiple NVR support
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Homebridge Dahua Ultimate
|
|
2
|
+
|
|
3
|
+
[](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
|
|
4
|
+
[](https://www.npmjs.com/package/homebridge-dahua-ultimate)
|
|
5
|
+
[](https://www.npmjs.com/package/homebridge-dahua-ultimate)
|
|
6
|
+
|
|
7
|
+
Complete Dahua NVR integration for Homebridge with hardware-accelerated streaming and real-time motion detection.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
✅ **Automatic Discovery** - Finds all cameras connected to your Dahua NVR
|
|
12
|
+
✅ **Hardware Acceleration** - Full GPU support (VAAPI/VideoToolbox/NVENC/OMX)
|
|
13
|
+
✅ **Motion Detection** - Real-time motion events pushed to HomeKit
|
|
14
|
+
✅ **Multiple Streams** - Main/Sub/Third stream support
|
|
15
|
+
✅ **HKSV Support** - HomeKit Secure Video recording
|
|
16
|
+
✅ **Event Streams** - Line crossing, intrusion detection, video loss
|
|
17
|
+
✅ **Zero Configuration** - Works out-of-the-box with auto-discovery
|
|
18
|
+
|
|
19
|
+
## Supported Devices
|
|
20
|
+
|
|
21
|
+
- Dahua NVR (all models)
|
|
22
|
+
- Dahua DVR (all models)
|
|
23
|
+
- Dahua IP Cameras (when connected to NVR)
|
|
24
|
+
- OEM brands: Lorex, Amcrest, Honeywell, etc.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g homebridge-dahua-ultimate
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or install via Homebridge Config UI X.
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
### Minimal Configuration (Recommended)
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"platforms": [
|
|
41
|
+
{
|
|
42
|
+
"platform": "DahuaUltimate",
|
|
43
|
+
"name": "Dahua NVR",
|
|
44
|
+
"host": "192.168.1.100",
|
|
45
|
+
"username": "admin",
|
|
46
|
+
"password": "yourpassword"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
That's it! The plugin will automatically discover all your cameras.
|
|
53
|
+
|
|
54
|
+
### Complete Configuration Example
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"platforms": [
|
|
59
|
+
{
|
|
60
|
+
"platform": "DahuaUltimate",
|
|
61
|
+
"name": "Dahua NVR",
|
|
62
|
+
"host": "192.168.1.100",
|
|
63
|
+
"port": 80,
|
|
64
|
+
"secure": false,
|
|
65
|
+
"username": "admin",
|
|
66
|
+
"password": "yourpassword",
|
|
67
|
+
"streamType": "mainstream",
|
|
68
|
+
"videoProcessor": "/usr/bin/ffmpeg",
|
|
69
|
+
"debugMotion": false,
|
|
70
|
+
"probeOnStartup": false,
|
|
71
|
+
"cameras": [
|
|
72
|
+
{
|
|
73
|
+
"channelId": 1,
|
|
74
|
+
"name": "Front Door",
|
|
75
|
+
"manufacturer": "Dahua",
|
|
76
|
+
"model": "IPC-HDW5831R-ZE",
|
|
77
|
+
"enableMotion": true,
|
|
78
|
+
"motionTimeout": 1,
|
|
79
|
+
"enableRecording": false,
|
|
80
|
+
"videoConfig": {
|
|
81
|
+
"maxStreams": 2,
|
|
82
|
+
"maxWidth": 1920,
|
|
83
|
+
"maxHeight": 1080,
|
|
84
|
+
"maxBitrate": 2000,
|
|
85
|
+
"encoder": "vaapi",
|
|
86
|
+
"audio": true,
|
|
87
|
+
"debug": false
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Hardware Acceleration Setup
|
|
97
|
+
|
|
98
|
+
### AMD/Intel GPU (VAAPI) - Recommended for Linux
|
|
99
|
+
|
|
100
|
+
1. Install VAAPI drivers:
|
|
101
|
+
```bash
|
|
102
|
+
# Ubuntu/Debian
|
|
103
|
+
sudo apt-get install vainfo mesa-va-drivers
|
|
104
|
+
|
|
105
|
+
# Verify VAAPI
|
|
106
|
+
vainfo
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
2. Configure camera to use VAAPI:
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"videoConfig": {
|
|
113
|
+
"encoder": "vaapi"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
3. Performance: Reduces CPU usage from 40-80% to 5-15%
|
|
119
|
+
|
|
120
|
+
### Apple Silicon/Intel (VideoToolbox)
|
|
121
|
+
|
|
122
|
+
VideoToolbox is automatically available on macOS:
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"videoConfig": {
|
|
126
|
+
"encoder": "videotoolbox"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### NVIDIA GPU (NVENC)
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"videoConfig": {
|
|
136
|
+
"encoder": "nvenc"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Raspberry Pi (OMX)
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"videoConfig": {
|
|
146
|
+
"encoder": "omx"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Motion Detection
|
|
152
|
+
|
|
153
|
+
Motion detection is enabled by default and works with:
|
|
154
|
+
|
|
155
|
+
- **Video Motion Detection** (VMD)
|
|
156
|
+
- **Line Crossing Detection** (IVS Tripwire)
|
|
157
|
+
- **Intrusion Detection** (IVS Region)
|
|
158
|
+
- **Alarm Inputs**
|
|
159
|
+
|
|
160
|
+
### Configure Motion Timeout
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"cameras": [
|
|
165
|
+
{
|
|
166
|
+
"channelId": 1,
|
|
167
|
+
"enableMotion": true,
|
|
168
|
+
"motionTimeout": 1 // Seconds to report motion after detection
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Disable Motion for Specific Camera
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"cameras": [
|
|
179
|
+
{
|
|
180
|
+
"channelId": 2,
|
|
181
|
+
"enableMotion": false
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## HomeKit Secure Video (HKSV)
|
|
188
|
+
|
|
189
|
+
To enable HKSV recording:
|
|
190
|
+
|
|
191
|
+
1. Enable in camera config:
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"cameras": [
|
|
195
|
+
{
|
|
196
|
+
"channelId": 1,
|
|
197
|
+
"enableRecording": true
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
2. In the Home app:
|
|
204
|
+
- Open camera settings
|
|
205
|
+
- Select "Recording Options"
|
|
206
|
+
- Choose recording mode
|
|
207
|
+
- Requires iCloud+ subscription
|
|
208
|
+
|
|
209
|
+
## Stream Types
|
|
210
|
+
|
|
211
|
+
Choose the stream quality based on your network:
|
|
212
|
+
|
|
213
|
+
- **mainstream** - 1080p/4MP (default) - Best quality, higher bandwidth
|
|
214
|
+
- **substream** - 720p/D1 - Good quality, medium bandwidth
|
|
215
|
+
- **thirdstream** - CIF/QCIF - Lower quality, low bandwidth
|
|
216
|
+
|
|
217
|
+
Configure globally:
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"streamType": "mainstream"
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Or per camera:
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"cameras": [
|
|
228
|
+
{
|
|
229
|
+
"channelId": 1,
|
|
230
|
+
"videoConfig": {
|
|
231
|
+
"maxWidth": 1280,
|
|
232
|
+
"maxHeight": 720
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Troubleshooting
|
|
240
|
+
|
|
241
|
+
### Camera Not Discovered
|
|
242
|
+
|
|
243
|
+
1. Check NVR is accessible:
|
|
244
|
+
```bash
|
|
245
|
+
curl -u admin:password http://192.168.1.100/cgi-bin/magicBox.cgi?action=getSystemInfo
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
2. Enable debug logging:
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"debugMotion": true
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
3. Check Homebridge logs for errors
|
|
256
|
+
|
|
257
|
+
### Motion Detection Not Working
|
|
258
|
+
|
|
259
|
+
1. Verify motion detection is enabled in camera web UI
|
|
260
|
+
2. Enable motion debug:
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"debugMotion": true
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
3. Check logs for motion events:
|
|
268
|
+
```
|
|
269
|
+
[Dahua] 🚨 Motion event: channel=1, type=VideoMotion, active=true
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Streams Not Loading
|
|
273
|
+
|
|
274
|
+
1. Test RTSP manually:
|
|
275
|
+
```bash
|
|
276
|
+
ffplay -rtsp_transport tcp "rtsp://admin:password@192.168.1.100:554/cam/realmonitor?channel=1&subtype=0"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
2. Check credentials and host/port
|
|
280
|
+
3. Enable video debug:
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"cameras": [{
|
|
284
|
+
"videoConfig": {
|
|
285
|
+
"debug": true
|
|
286
|
+
}
|
|
287
|
+
}]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### High CPU Usage
|
|
292
|
+
|
|
293
|
+
1. Enable hardware acceleration (VAAPI recommended for Linux)
|
|
294
|
+
2. Use sub-stream instead of main stream
|
|
295
|
+
3. Reduce max bitrate:
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"videoConfig": {
|
|
299
|
+
"maxBitrate": 1000
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## API Endpoints Used
|
|
305
|
+
|
|
306
|
+
This plugin uses the following Dahua HTTP API endpoints:
|
|
307
|
+
|
|
308
|
+
- `/cgi-bin/configManager.cgi?action=getConfig&name=Encode` - Channel discovery
|
|
309
|
+
- `/cgi-bin/configManager.cgi?action=getConfig&name=ChannelTitle` - Channel names
|
|
310
|
+
- `/cgi-bin/magicBox.cgi?action=getSystemInfo` - Device info
|
|
311
|
+
- `/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion,...]` - Motion events
|
|
312
|
+
- `rtsp://host:554/cam/realmonitor?channel=N&subtype=0` - Video streaming
|
|
313
|
+
|
|
314
|
+
## Comparison to Other Plugins
|
|
315
|
+
|
|
316
|
+
| Feature | Dahua Ultimate | homebridge-dahua | homebridge-camera-ffmpeg |
|
|
317
|
+
|---------|----------------|------------------|--------------------------|
|
|
318
|
+
| Auto-discovery | ✅ | ❌ | ❌ |
|
|
319
|
+
| Motion events | ✅ Real-time | ✅ Polling | ❌ |
|
|
320
|
+
| Hardware accel | ✅ Full GPU | ❌ | ⚠️ Manual |
|
|
321
|
+
| HKSV | ✅ | ❌ | ✅ |
|
|
322
|
+
| IVS events | ✅ | ❌ | ❌ |
|
|
323
|
+
| Zero config | ✅ | ❌ | ❌ |
|
|
324
|
+
|
|
325
|
+
## Contributing
|
|
326
|
+
|
|
327
|
+
Contributions welcome! Please open an issue or PR on GitHub.
|
|
328
|
+
|
|
329
|
+
## License
|
|
330
|
+
|
|
331
|
+
MIT
|
|
332
|
+
|
|
333
|
+
## Credits
|
|
334
|
+
|
|
335
|
+
Based on the excellent [homebridge-hikvision-ultimate](https://github.com/yourusername/homebridge-hikvision-ultimate) plugin architecture.
|
|
336
|
+
|
|
337
|
+
## Support
|
|
338
|
+
|
|
339
|
+
- [GitHub Issues](https://github.com/yourusername/homebridge-dahua-ultimate/issues)
|
|
340
|
+
- [Homebridge Discord](https://discord.gg/homebridge)
|