Skip to content

Commit 74e58df

Browse files
authored
[dahuadoor] Use DHIP invite for SIP button mapping (#20628)
* [dahuadoor] Wire SIP backchannel relay into call lifecycle Signed-off-by: Sven Schad <svnsssd@gmail.com>
1 parent 8a08d57 commit 74e58df

16 files changed

Lines changed: 961 additions & 265 deletions

File tree

bundles/org.openhab.binding.dahuadoor/README.md

Lines changed: 128 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Devices in a different subnet or VLAN will not be found automatically and must b
2222

2323
### VTO2202/VTO3211 Device
2424

25-
Outdoor station device configuration.
25+
VTO2202 is a single-button outdoor station; VTO3211 is a dual-button outdoor station.
2626

2727
| Parameter | Type | Required | Default | Description |
2828
| ------------- | ------- | -------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -38,11 +38,16 @@ Outdoor station device configuration.
3838
| stunServer | text | No | stun.l.google.com:19302 | STUN server in `host:port` format used by go2rtc. |
3939
| rtspChannel | integer | No | 1 | RTSP channel index on the Dahua device. |
4040
| rtspSubtype | integer | No | 0 | RTSP stream subtype (`0` main stream, `1` sub stream). |
41-
| enableSip | boolean | No | false | Enables local SIP client registration for call signaling and SIP state channels. |
42-
| sipExtension | text | No | | SIP extension used for registration (for example `9901#2`). |
43-
| sipPassword | text | No | | SIP password used for SIP authentication (falls back to `password` when empty). |
44-
| localSipPort | integer | No | 5062 | Local UDP port used by the SIP client. Must be unique per thing when multiple SIP clients are active. |
45-
| sipRealm | text | No | VDP | SIP authentication realm used for digest authentication. |
41+
| enableSip | boolean | No | false | Enables local SIP client registration for call/doorbell signaling. |
42+
| sipExtension | text | No | | SIP extension (also used as SIP username), e.g. `9901#2`. |
43+
| sipPassword | text | No | | SIP password; if empty, the binding falls back to `password`. |
44+
| localSipPort | integer | No | 5060 | Local UDP SIP listening port. |
45+
| sipRealm | text | No | VDP | SIP authentication realm (default for Dahua VTO devices). |
46+
47+
**Note on SIP configuration:**
48+
To enable SIP call signaling, set `enableSip=true` and configure at least `sipExtension`.
49+
If your VTO requires a dedicated SIP password, set `sipPassword`; otherwise the binding uses `password`.
50+
`localSipPort` and `sipRealm` usually work with their defaults (`5060` and `VDP`).
4651

4752
**Note:** Windows paths are not currently supported.
4853

@@ -60,63 +65,31 @@ keytool -importcert -alias dahua-door -file ca.crt \
6065

6166
### VTO2202 Channels (Single Button)
6267

63-
| Channel ID | Type | Read/Write | Description |
64-
| ----------- | ------- | ---------- | --------------------------------------------------------- |
65-
| bell-button | Trigger | Read | Triggers when doorbell button is pressed (event: PRESSED) |
66-
| door-image | Image | Read | Camera snapshot taken when doorbell is pressed |
67-
| open-door-1 | Switch | Write | Command to open door relay 1 |
68-
| open-door-2 | Switch | Write | Command to open door relay 2 |
69-
| webrtc-url | String | Read | Proxy path for WebRTC SDP offer/answer exchange |
70-
| sip-registered | Switch | Read | ON when SIP client registration is active |
71-
| sip-call-state | String | Read | Current SIP call state (IDLE, RINGING, ANSWERING, ACTIVE, TERMINATING, HUNGUP) |
68+
| Channel ID | Type | Read/Write | Description |
69+
| -------------- | ------- | ---------- | ---------------------------------------------------------------------------------- |
70+
| bell-button | Trigger | Read | Triggers when doorbell button is pressed (event: PRESSED) |
71+
| door-image | Image | Read | Camera snapshot taken when doorbell is pressed |
72+
| open-door-1 | Switch | Write | Command to open door relay 1 |
73+
| open-door-2 | Switch | Write | Command to open door relay 2 |
74+
| webrtc-url | String | Read | Proxy path for browser SDP offer/answer exchange via openHAB |
75+
| sip-registered | Switch | Read | `ON` when SIP registration is successful |
76+
| sip-call-state | String | Read | SIP call state (`IDLE`, `RINGING`, `ANSWERING`, `ACTIVE`, `TERMINATING`, `HUNGUP`) |
7277

7378
### VTO3211 Channels (Dual Button)
7479

75-
| Channel ID | Type | Read/Write | Description |
76-
| ------------- | ------- | ---------- | -------------------------------------------------- |
77-
| bell-button-1 | Trigger | Read | Triggers when button 1 is pressed (event: PRESSED) |
78-
| bell-button-2 | Trigger | Read | Triggers when button 2 is pressed (event: PRESSED) |
79-
| door-image-1 | Image | Read | Camera snapshot when button 1 is pressed |
80-
| door-image-2 | Image | Read | Camera snapshot when button 2 is pressed |
81-
| open-door-1 | Switch | Write | Command to open door relay 1 |
82-
| open-door-2 | Switch | Write | Command to open door relay 2 |
83-
| webrtc-url | String | Read | Proxy path for WebRTC SDP offer/answer exchange |
84-
| sip-registered | Switch | Read | ON when SIP client registration is active |
85-
| sip-call-state | String | Read | Current SIP call state (IDLE, RINGING, ANSWERING, ACTIVE, TERMINATING, HUNGUP) |
86-
87-
## Intercom Operation
88-
89-
Intercom operation is implemented with WebRTC via the `go2rtc` binary.
90-
It converts the Dahua RTP audio/video stream into browser-compatible WebRTC. The audio stream is transcoded using `ffmpeg`. Hence both tools are needed.
91-
When `enableWebRTC=true`, the binding starts a local `go2rtc` sidecar and exposes the `webrtc-url` channel.
92-
93-
Known working version used during development: `go2rtc 1.9.9`.
94-
95-
### Tool installation
96-
97-
Download and install the matching `go2rtc` binary for your operating system:
98-
99-
- <https://github.com/AlexxIT/go2rtc>
100-
- <https://github.com/AlexxIT/go2rtc/releases>
101-
102-
Common binaries in releases are typically named like:
103-
104-
- Linux x86_64: `go2rtc_linux_amd64`
105-
- Linux ARM64: `go2rtc_linux_arm64` (e.g. openHABian distro)
106-
- Windows x86_64: `go2rtc_windows_amd64.exe`
107-
- macOS Apple Silicon: `go2rtc_darwin_arm64`
108-
109-
`ffmpeg` can be installed manually or via your openHABian setup tooling, depending on your setup.
110-
For Debian/openHABian you can use `sudo apt install ffmpeg`.
111-
112-
Quick prerequisites check:
113-
114-
```bash
115-
go2rtc -version
116-
ffmpeg -version
117-
```
80+
| Channel ID | Type | Read/Write | Description |
81+
| -------------- | ------- | ---------- | ---------------------------------------------------------------------------------- |
82+
| bell-button-1 | Trigger | Read | Triggers when button 1 is pressed (event: PRESSED) |
83+
| bell-button-2 | Trigger | Read | Triggers when button 2 is pressed (event: PRESSED) |
84+
| door-image-1 | Image | Read | Camera snapshot when button 1 is pressed |
85+
| door-image-2 | Image | Read | Camera snapshot when button 2 is pressed |
86+
| open-door-1 | Switch | Write | Command to open door relay 1 |
87+
| open-door-2 | Switch | Write | Command to open door relay 2 |
88+
| webrtc-url | String | Read | Proxy path for browser SDP offer/answer exchange via openHAB |
89+
| sip-registered | Switch | Read | `ON` when SIP registration is successful |
90+
| sip-call-state | String | Read | SIP call state (`IDLE`, `RINGING`, `ANSWERING`, `ACTIVE`, `TERMINATING`, `HUNGUP`) |
11891

119-
## Examples
92+
## Examples (w/o Intercom)
12093

12194
### VTO2202 Example (Single Button)
12295

@@ -188,21 +161,107 @@ Send notifications for both buttons:
188161
```java
189162
rule "Apartment 1 Doorbell"
190163
when
191-
Channel "dahuadoor:vto3211:entrance:bell-button-1" triggered PRESSED
164+
Channel "dahuadoor:vto3211:entrance:bell-button-1" triggered PRESSED
192165
then
193-
sendBroadcastNotification("Visitor at Apartment 1", "door",
194-
"entrance", "Entrance", "door-notifications", null,
195-
"item:Apartment1Image",
196-
"Open Door=command:OpenApartment1:ON", null)
166+
sendBroadcastNotification("Visitor at Apartment 1", "door",
167+
"entrance", "Entrance", "door-notifications", null,
168+
"item:Apartment1Image",
169+
"Open Door=command:OpenApartment1:ON", null)
197170
end
198171

199172
rule "Apartment 2 Doorbell"
200173
when
201-
Channel "dahuadoor:vto3211:entrance:bell-button-2" triggered PRESSED
174+
Channel "dahuadoor:vto3211:entrance:bell-button-2" triggered PRESSED
202175
then
203-
sendBroadcastNotification("Visitor at Apartment 2", "door",
204-
"entrance", "Entrance", "door-notifications", null,
205-
"item:Apartment2Image",
206-
"Open Door=command:OpenApartment2:ON", null)
176+
sendBroadcastNotification("Visitor at Apartment 2", "door",
177+
"entrance", "Entrance", "door-notifications", null,
178+
"item:Apartment2Image",
179+
"Open Door=command:OpenApartment2:ON", null)
207180
end
208181
```
182+
183+
## Intercom operation using customized widget in Main UI
184+
185+
Intercom operation is implemented with WebRTC via the `go2rtc` binary.
186+
It converts the Dahua RTP audio/video stream into browser-compatible WebRTC. The audio stream is transcoded using `ffmpeg`. Hence both tools are needed.
187+
When `enableWebRTC=true`, the binding starts everything automatically when a call is received.
188+
The binding registers itself at the VTO. Define a new terminal (for example `9901#2`, type `public`) and use that account as `sipExtension` plus the corresponding `sipPassword`.
189+
You can try Dahua's default password for initial testing, but do not use it in production. Consult your VTO manual for setup details.
190+
191+
### Tool installation
192+
193+
Download and install the matching `go2rtc` binary for your operating system:
194+
195+
- <https://github.com/AlexxIT/go2rtc>
196+
- <https://github.com/AlexxIT/go2rtc/releases>
197+
198+
Common binaries in releases are typically named like:
199+
200+
- Linux x86_64: `go2rtc_linux_amd64`
201+
- Linux ARM64: `go2rtc_linux_arm64` (e.g. openHABian distro)
202+
- Windows x86_64: `go2rtc_windows_amd64.exe`
203+
- macOS Apple Silicon: `go2rtc_darwin_arm64`
204+
205+
`ffmpeg` can be installed manually or via your openHABian setup tooling, depending on your setup.
206+
For Debian/openHABian you can use `sudo apt install ffmpeg`.
207+
208+
Quick prerequisites check:
209+
210+
```bash
211+
go2rtc -version
212+
ffmpeg -version
213+
```
214+
215+
### Configuration and Examples
216+
217+
Intercom operation provides these channels:
218+
219+
- `webrtc-url`: base path for browser SDP exchange, for example `/dahuadoor/webrtc/dahua_<thing_uid>`
220+
- `sip-call-state`: call state used by the widget logic
221+
- `sip-registered`: SIP registration state used by the widget logic
222+
223+
SIP parameters used in the example below:
224+
225+
- `enableSip=true` and `sipExtension` are required to register the local SIP client.
226+
- `sipPassword` is optional; when empty, the binding uses `password` from the thing.
227+
- `localSipPort=5060` and `sipRealm="VDP"` are the typical defaults for Dahua VTO setups.
228+
229+
Example of a working configuration:
230+
231+
#### Things
232+
233+
```java
234+
Thing dahuadoor:vto2202:frontdoor "Front Door Station" @ "Entrance" [
235+
hostname="192.168.1.100",
236+
username="admin",
237+
password="password123",
238+
snapshotPath="/var/lib/openhab/door-images",
239+
enableWebRTC=true,
240+
go2rtcPath="/usr/local/bin/go2rtc",
241+
go2rtcApiPort=1984,
242+
webRtcPort=8555,
243+
stunServer="stun.l.google.com:19302",
244+
enableSip=true,
245+
sipExtension="9901#2",
246+
sipPassword="123456",
247+
localSipPort=5060,
248+
sipRealm="VDP"
249+
]
250+
```
251+
252+
#### Items
253+
254+
```java
255+
String DahuaDoor_WebRTC_URL "WebRTC URL" { channel="dahuadoor:vto2202:frontdoor:webrtc-url" }
256+
String DahuaDoor_SIP_CallState "SIP Call State" { channel="dahuadoor:vto2202:frontdoor:sip-call-state" }
257+
Switch DahuaDoor_SIP_Registered "SIP Registered" { channel="dahuadoor:vto2202:frontdoor:sip-registered" }
258+
Switch DahuaDoor_Doorbell "Doorbell Session"
259+
Switch DoorOpener "Open Door" { channel="dahuadoor:vto2202:frontdoor:open-door-1" }
260+
Switch DoorOpener_GarageTrigger "Open Door 2" { channel="dahuadoor:vto2202:frontdoor:open-door-2" }
261+
```
262+
263+
#### Widget
264+
265+
The DahuaDoor Intercom widget for MainUI is available in the Marketplace:
266+
267+
[DahuaDoor Intercom Widget](https://community.openhab.org/t/dahua-door-intercom-widget/169092)

0 commit comments

Comments
 (0)