harbor-python 1.4.0__tar.gz → 1.6.1__tar.gz

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.
@@ -0,0 +1,321 @@
1
+ Metadata-Version: 2.5
2
+ Name: harbor-python
3
+ Version: 1.6.1
4
+ Summary: Async local client for Harbor Sleep Cameras
5
+ Project-URL: Homepage, https://github.com/Harbor-Systems/harbor-python
6
+ Project-URL: Repository, https://github.com/Harbor-Systems/harbor-python
7
+ Project-URL: Issues, https://github.com/Harbor-Systems/harbor-python/issues
8
+ Project-URL: Changelog, https://github.com/Harbor-Systems/harbor-python/blob/main/CHANGELOG.md
9
+ Author: Andres Garcia, Lash-L
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: baby,baby monitor,camera,harbor,harbor sleep,mqtt,webrtc,whip
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: <4,>=3.11
26
+ Requires-Dist: aiomqtt>=2.5.0
27
+ Requires-Dist: pydantic>=2.12.2
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Harbor Python
31
+
32
+ Async Python client for connecting locally to Harbor Sleep Cameras.
33
+
34
+ `harbor-python` speaks directly to Harbor devices on your local network over MQTT, using the camera certificate material issued for your setup. It provides typed event parsing, device state tracking, command publishing, and helpers for configuring local WHIP streaming targets.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install harbor-python
40
+ ```
41
+
42
+ Python 3.11 or newer is required.
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ import asyncio
48
+
49
+ from harbor import Harbor, HarborCamera, HarborCameraConfig, HeartbeatUpdate
50
+
51
+
52
+ async def main() -> None:
53
+ config = HarborCameraConfig(
54
+ serial="CAMERA_SERIAL",
55
+ ip_address="192.168.1.50",
56
+ cert_path="/path/to/cert.pem",
57
+ key_path="/path/to/key.pem",
58
+ )
59
+
60
+ harbor = Harbor()
61
+ camera = HarborCamera(config)
62
+
63
+ camera.subscribe_updates(
64
+ lambda state: print(f"{state.serial} values: {state.values}")
65
+ )
66
+ camera.subscribe(
67
+ HeartbeatUpdate,
68
+ lambda event: print(f"temperature: {event.payload.temperature}"),
69
+ )
70
+
71
+ harbor.add_device(camera)
72
+ harbor.add_camera_connection(config)
73
+
74
+ try:
75
+ await harbor.start()
76
+ await asyncio.Event().wait()
77
+ finally:
78
+ await harbor.stop()
79
+
80
+
81
+ asyncio.run(main())
82
+ ```
83
+
84
+ On Windows, `aiomqtt` works best with the selector event loop policy:
85
+
86
+ ```python
87
+ import asyncio
88
+ import sys
89
+
90
+ if sys.platform == "win32":
91
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
92
+ ```
93
+
94
+ ## Certificate Configuration
95
+
96
+ `HarborCameraConfig` accepts certificate material in either form:
97
+
98
+ ```python
99
+ HarborCameraConfig(
100
+ serial="CAMERA_SERIAL",
101
+ ip_address="192.168.1.50",
102
+ cert_pem="<certificate PEM contents>",
103
+ key_pem="<private key PEM contents>",
104
+ )
105
+ ```
106
+
107
+ or:
108
+
109
+ ```python
110
+ HarborCameraConfig(
111
+ serial="CAMERA_SERIAL",
112
+ ip_address="192.168.1.50",
113
+ cert_path="/path/to/cert.pem",
114
+ key_path="/path/to/key.pem",
115
+ cert_dir="/path/to/ca-directory",
116
+ )
117
+ ```
118
+
119
+ When both PEM strings and file paths are provided, the in-memory PEM values are used.
120
+
121
+ ## Commands
122
+
123
+ Camera commands can be published directly:
124
+
125
+ ```python
126
+ await harbor.publish_camera_command("CAMERA_SERIAL", "some-command", {"value": True})
127
+ ```
128
+
129
+ For request/response commands, use `request_camera_command` or the settings helper:
130
+
131
+ ```python
132
+ settings = await harbor.get_camera_settings("CAMERA_SERIAL")
133
+ print(settings.settings)
134
+ ```
135
+
136
+ ### Camera controls
137
+
138
+ ```python
139
+ await harbor.set_camera_on("CAMERA_SERIAL", False) # privacy: pause the stream
140
+ await harbor.set_night_mode("CAMERA_SERIAL", "auto") # "auto" | "on" | "off"
141
+ await harbor.set_video_flip("CAMERA_SERIAL", True) # rotate the image 180°
142
+ await harbor.set_clock_display("CAMERA_SERIAL", False) # clock overlay on the video
143
+ await harbor.set_temperature_scale("CAMERA_SERIAL", "C") # "F" | "C"
144
+ await harbor.update_camera_settings(
145
+ "CAMERA_SERIAL", {"preference_video_ir_brightness": 40}
146
+ )
147
+ ```
148
+
149
+ Each control writes one preference and refreshes device state, so
150
+ `camera.state.values` reflects the change once the call returns:
151
+
152
+ | `camera.state.values[...]` | Type | Setting |
153
+ |---------------------------|------|---------|
154
+ | `camera_on` | `bool` | `preference_stream_paused` (inverted) |
155
+ | `night_mode_preference` | `"auto"` \| `"on"` \| `"off"` | `preference_video_night_mode` |
156
+ | `night_mode` | `bool` | runtime IR state (read-only, see below) |
157
+ | `video_flip` | `bool` | `preference_video_flip` |
158
+ | `clock_display` | `bool` | `preference_video_has_clock_display` |
159
+ | `temperature_scale` | `"F"` \| `"C"` | `preference_temperature_scale` |
160
+
161
+ `set_video_flip` and `set_clock_display` take real booleans — `1`/`0` and
162
+ `"true"` raise `ValueError` rather than being sent as a number or string,
163
+ which the firmware would reject.
164
+
165
+ The enum setters validate against the firmware's own option list, exported as
166
+ `NIGHT_MODE_MODES` and `TEMPERATURE_SCALES`. Matching is exact: `"f"` raises
167
+ `ValueError`, because the device compares the string verbatim. State values
168
+ preserve case for the same reason — what you read back is always something you
169
+ can write.
170
+
171
+ #### Night mode
172
+
173
+ Night mode is a **three-way preference**, not a boolean — `"auto"`, `"on"` or
174
+ `"off"` (default `"auto"`). Passing a bool raises `ValueError` rather than
175
+ guessing at a mode. A camera exposes two separate night-mode values:
176
+
177
+ | `camera.state.values[...]` | Type | Meaning |
178
+ |---------------------------|------|---------|
179
+ | `night_mode_preference` | `"auto"` \| `"on"` \| `"off"` | The setting. This is what `set_night_mode` writes and what reads back. |
180
+ | `night_mode` | `bool` | Whether IR is engaged *right now*. Read-only and device-driven — under `"auto"` it flips on its own as light levels change. |
181
+
182
+ Consumers building a UI entity should bind it to `night_mode_preference`, since
183
+ `night_mode` moves independently of any command.
184
+
185
+ ### Command errors
186
+
187
+ A rejected command raises `HarborCommandError`, which carries the parsed
188
+ `status` and the firmware's per-field `errors` list:
189
+
190
+ ```python
191
+ from harbor import HarborCommandError, HarborUnsupportedCommandError
192
+
193
+ try:
194
+ await harbor.set_night_mode("CAMERA_SERIAL", "on")
195
+ except HarborUnsupportedCommandError:
196
+ ... # firmware has no such command; permanent, so stop offering the feature
197
+ except HarborCommandError as err:
198
+ print(err.status, err.errors) # e.g. "REQUEST_MALFORMED", [{"error_code": "INVALID_VALUE", ...}]
199
+ ```
200
+
201
+ `HarborUnsupportedCommandError` is a subclass of `HarborCommandError`, raised
202
+ only on a `RESOURCE_NOT_FOUND` status. That means the firmware has no handler
203
+ for the command at all, so retrying can never succeed.
204
+
205
+ ### Firmware compatibility
206
+
207
+ Commands are verified against real hardware, most recently a camera running
208
+ `os_version` **2.8.0** / `app_version` **2.8.0-rc1+c1b0a32**: `ping`,
209
+ `get-settings`, `update-settings`, `pause-stream`, `unpause-stream`,
210
+ `set-night-mode-ir-brightness`, `update-operating-mode`, `set-scheduled-reboot`
211
+ and `list-viewers` all respond `OK`. See `mqtt_home_assistant.md` for the full
212
+ audit and payload shapes.
213
+
214
+ ## WHIP Endpoint
215
+
216
+ Harbor cameras allow custom WHIP endpoints. This tells the camera where to stream and works with tools that support WHIP, including go2rtc and Frigate.
217
+
218
+ ### Setting up WHIP Ingestion (go2rtc)
219
+
220
+ You can self-host go2rtc in many ways; see the [go2rtc installation guide](https://go2rtc.org/#installation). If you use Home Assistant, the easiest option is the [go2rtc add-on](https://go2rtc.org/#go2rtc-home-assistant-add-on).
221
+
222
+ Once go2rtc is running, add a stream keyed by your camera serial number:
223
+
224
+ ```yaml
225
+ api:
226
+ listen: ":1984" # Change this if you use a non-default port.
227
+
228
+ streams:
229
+ "CAMERA_SERIAL":
230
+ ```
231
+
232
+ ### Setting up WHIP Ingestion (Frigate)
233
+
234
+ Frigate runs an instance of go2rtc under the hood. Add the following to your Frigate config:
235
+
236
+ ```yaml
237
+ go2rtc:
238
+ api:
239
+ listen: ":1984"
240
+ streams:
241
+ "CAMERA_SERIAL":
242
+ ```
243
+
244
+ ### Setting the Endpoint
245
+
246
+ 1. Open your Harbor app
247
+ 2. Go to Live
248
+ 3. Open Camera Settings
249
+ 4. Scroll down and click on Advanced Settings
250
+ 5. Enter the WHIP endpoint, for example: `http://192.168.1.10:1984/api/webrtc?dst=CAMERA_SERIAL`
251
+
252
+ Replace `CAMERA_SERIAL` with your camera serial number and `192.168.1.10` with the IP address of your go2rtc or Frigate server.
253
+
254
+ ### Repairing packet loss
255
+
256
+ WHIP media runs over UDP by default, and go2rtc does not negotiate
257
+ retransmission. `RegisterDefaultCodecs` in `pkg/webrtc/api.go` registers no RTX
258
+ (RFC 4588) codec, so go2rtc strips `rtx/90000` out of its SDP answer while still
259
+ advertising `a=rtcp-fb:96 nack`. Harbor cameras offer RTX correctly, but the
260
+ answer deletes the channel those retransmissions would travel on — go2rtc asks
261
+ the camera to retransmit over something it just removed, so nothing is ever
262
+ repaired. This is true as of go2rtc 1.9.10 and current master.
263
+
264
+ The symptom is occasional blocky or smeared frames that clear on the next
265
+ keyframe. Each lost packet damages the frame it belonged to, so even a very low
266
+ loss rate is visible — 0.03% loss on a 20 fps stream is a handful of damaged
267
+ frames every few minutes.
268
+
269
+ Running the WHIP session over ICE-TCP sidesteps this. The kernel retransmits
270
+ lost segments and delivers them in order, with no SDP negotiation involved:
271
+
272
+ ```yaml
273
+ webrtc:
274
+ listen: ":8555/tcp"
275
+ candidates:
276
+ - 192.168.1.10:8555
277
+ filters:
278
+ networks: [tcp4]
279
+ ```
280
+
281
+ Nest that block under `go2rtc:` if you are configuring Frigate.
282
+
283
+ Both settings are required. `filters` on its own is not enough: with a bare
284
+ `listen: ":8555"`, go2rtc registers every entry in `candidates` as **both** a TCP
285
+ and a UDP candidate, so it would keep advertising a UDP candidate that the filter
286
+ had stopped anything from listening on.
287
+
288
+ Confirm it took effect by checking the producer's transport, which should read
289
+ `http+tcp`:
290
+
291
+ ```bash
292
+ curl -s "http://192.168.1.10:1984/api/streams?src=CAMERA_SERIAL" | grep protocol
293
+ ```
294
+
295
+ Frigate does not expose port 1984 by default — use
296
+ `http://FRIGATE_HOST:5000/api/go2rtc/api/streams?src=CAMERA_SERIAL` instead.
297
+
298
+ What this costs:
299
+
300
+ - Loss becomes latency instead of corruption. A sustained wifi dropout shows up
301
+ as a stall rather than a glitch.
302
+ - `filters` applies to all inbound WebRTC, so browser live view moves to TCP as
303
+ well. If you watch streams from outside your network, forward **8555/tcp**, not
304
+ only UDP.
305
+ - The camera's congestion control stops having an effect, since TCP handles
306
+ pacing. That is not a concern at the camera's bitrate on a local network, but
307
+ it does mean the camera will not lower quality if the link saturates.
308
+
309
+ Measured on one Harbor camera pushing 1728x1080 HEVC over wifi, video packet loss
310
+ over a 3 minute sample went from 0.039% to 0.000%.
311
+
312
+ ## Development
313
+
314
+ ```bash
315
+ uv sync
316
+ uv run pytest
317
+ ```
318
+
319
+ ## License
320
+
321
+ Licensed under the Apache License 2.0.
@@ -0,0 +1,292 @@
1
+ # Harbor Python
2
+
3
+ Async Python client for connecting locally to Harbor Sleep Cameras.
4
+
5
+ `harbor-python` speaks directly to Harbor devices on your local network over MQTT, using the camera certificate material issued for your setup. It provides typed event parsing, device state tracking, command publishing, and helpers for configuring local WHIP streaming targets.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install harbor-python
11
+ ```
12
+
13
+ Python 3.11 or newer is required.
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ import asyncio
19
+
20
+ from harbor import Harbor, HarborCamera, HarborCameraConfig, HeartbeatUpdate
21
+
22
+
23
+ async def main() -> None:
24
+ config = HarborCameraConfig(
25
+ serial="CAMERA_SERIAL",
26
+ ip_address="192.168.1.50",
27
+ cert_path="/path/to/cert.pem",
28
+ key_path="/path/to/key.pem",
29
+ )
30
+
31
+ harbor = Harbor()
32
+ camera = HarborCamera(config)
33
+
34
+ camera.subscribe_updates(
35
+ lambda state: print(f"{state.serial} values: {state.values}")
36
+ )
37
+ camera.subscribe(
38
+ HeartbeatUpdate,
39
+ lambda event: print(f"temperature: {event.payload.temperature}"),
40
+ )
41
+
42
+ harbor.add_device(camera)
43
+ harbor.add_camera_connection(config)
44
+
45
+ try:
46
+ await harbor.start()
47
+ await asyncio.Event().wait()
48
+ finally:
49
+ await harbor.stop()
50
+
51
+
52
+ asyncio.run(main())
53
+ ```
54
+
55
+ On Windows, `aiomqtt` works best with the selector event loop policy:
56
+
57
+ ```python
58
+ import asyncio
59
+ import sys
60
+
61
+ if sys.platform == "win32":
62
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
63
+ ```
64
+
65
+ ## Certificate Configuration
66
+
67
+ `HarborCameraConfig` accepts certificate material in either form:
68
+
69
+ ```python
70
+ HarborCameraConfig(
71
+ serial="CAMERA_SERIAL",
72
+ ip_address="192.168.1.50",
73
+ cert_pem="<certificate PEM contents>",
74
+ key_pem="<private key PEM contents>",
75
+ )
76
+ ```
77
+
78
+ or:
79
+
80
+ ```python
81
+ HarborCameraConfig(
82
+ serial="CAMERA_SERIAL",
83
+ ip_address="192.168.1.50",
84
+ cert_path="/path/to/cert.pem",
85
+ key_path="/path/to/key.pem",
86
+ cert_dir="/path/to/ca-directory",
87
+ )
88
+ ```
89
+
90
+ When both PEM strings and file paths are provided, the in-memory PEM values are used.
91
+
92
+ ## Commands
93
+
94
+ Camera commands can be published directly:
95
+
96
+ ```python
97
+ await harbor.publish_camera_command("CAMERA_SERIAL", "some-command", {"value": True})
98
+ ```
99
+
100
+ For request/response commands, use `request_camera_command` or the settings helper:
101
+
102
+ ```python
103
+ settings = await harbor.get_camera_settings("CAMERA_SERIAL")
104
+ print(settings.settings)
105
+ ```
106
+
107
+ ### Camera controls
108
+
109
+ ```python
110
+ await harbor.set_camera_on("CAMERA_SERIAL", False) # privacy: pause the stream
111
+ await harbor.set_night_mode("CAMERA_SERIAL", "auto") # "auto" | "on" | "off"
112
+ await harbor.set_video_flip("CAMERA_SERIAL", True) # rotate the image 180°
113
+ await harbor.set_clock_display("CAMERA_SERIAL", False) # clock overlay on the video
114
+ await harbor.set_temperature_scale("CAMERA_SERIAL", "C") # "F" | "C"
115
+ await harbor.update_camera_settings(
116
+ "CAMERA_SERIAL", {"preference_video_ir_brightness": 40}
117
+ )
118
+ ```
119
+
120
+ Each control writes one preference and refreshes device state, so
121
+ `camera.state.values` reflects the change once the call returns:
122
+
123
+ | `camera.state.values[...]` | Type | Setting |
124
+ |---------------------------|------|---------|
125
+ | `camera_on` | `bool` | `preference_stream_paused` (inverted) |
126
+ | `night_mode_preference` | `"auto"` \| `"on"` \| `"off"` | `preference_video_night_mode` |
127
+ | `night_mode` | `bool` | runtime IR state (read-only, see below) |
128
+ | `video_flip` | `bool` | `preference_video_flip` |
129
+ | `clock_display` | `bool` | `preference_video_has_clock_display` |
130
+ | `temperature_scale` | `"F"` \| `"C"` | `preference_temperature_scale` |
131
+
132
+ `set_video_flip` and `set_clock_display` take real booleans — `1`/`0` and
133
+ `"true"` raise `ValueError` rather than being sent as a number or string,
134
+ which the firmware would reject.
135
+
136
+ The enum setters validate against the firmware's own option list, exported as
137
+ `NIGHT_MODE_MODES` and `TEMPERATURE_SCALES`. Matching is exact: `"f"` raises
138
+ `ValueError`, because the device compares the string verbatim. State values
139
+ preserve case for the same reason — what you read back is always something you
140
+ can write.
141
+
142
+ #### Night mode
143
+
144
+ Night mode is a **three-way preference**, not a boolean — `"auto"`, `"on"` or
145
+ `"off"` (default `"auto"`). Passing a bool raises `ValueError` rather than
146
+ guessing at a mode. A camera exposes two separate night-mode values:
147
+
148
+ | `camera.state.values[...]` | Type | Meaning |
149
+ |---------------------------|------|---------|
150
+ | `night_mode_preference` | `"auto"` \| `"on"` \| `"off"` | The setting. This is what `set_night_mode` writes and what reads back. |
151
+ | `night_mode` | `bool` | Whether IR is engaged *right now*. Read-only and device-driven — under `"auto"` it flips on its own as light levels change. |
152
+
153
+ Consumers building a UI entity should bind it to `night_mode_preference`, since
154
+ `night_mode` moves independently of any command.
155
+
156
+ ### Command errors
157
+
158
+ A rejected command raises `HarborCommandError`, which carries the parsed
159
+ `status` and the firmware's per-field `errors` list:
160
+
161
+ ```python
162
+ from harbor import HarborCommandError, HarborUnsupportedCommandError
163
+
164
+ try:
165
+ await harbor.set_night_mode("CAMERA_SERIAL", "on")
166
+ except HarborUnsupportedCommandError:
167
+ ... # firmware has no such command; permanent, so stop offering the feature
168
+ except HarborCommandError as err:
169
+ print(err.status, err.errors) # e.g. "REQUEST_MALFORMED", [{"error_code": "INVALID_VALUE", ...}]
170
+ ```
171
+
172
+ `HarborUnsupportedCommandError` is a subclass of `HarborCommandError`, raised
173
+ only on a `RESOURCE_NOT_FOUND` status. That means the firmware has no handler
174
+ for the command at all, so retrying can never succeed.
175
+
176
+ ### Firmware compatibility
177
+
178
+ Commands are verified against real hardware, most recently a camera running
179
+ `os_version` **2.8.0** / `app_version` **2.8.0-rc1+c1b0a32**: `ping`,
180
+ `get-settings`, `update-settings`, `pause-stream`, `unpause-stream`,
181
+ `set-night-mode-ir-brightness`, `update-operating-mode`, `set-scheduled-reboot`
182
+ and `list-viewers` all respond `OK`. See `mqtt_home_assistant.md` for the full
183
+ audit and payload shapes.
184
+
185
+ ## WHIP Endpoint
186
+
187
+ Harbor cameras allow custom WHIP endpoints. This tells the camera where to stream and works with tools that support WHIP, including go2rtc and Frigate.
188
+
189
+ ### Setting up WHIP Ingestion (go2rtc)
190
+
191
+ You can self-host go2rtc in many ways; see the [go2rtc installation guide](https://go2rtc.org/#installation). If you use Home Assistant, the easiest option is the [go2rtc add-on](https://go2rtc.org/#go2rtc-home-assistant-add-on).
192
+
193
+ Once go2rtc is running, add a stream keyed by your camera serial number:
194
+
195
+ ```yaml
196
+ api:
197
+ listen: ":1984" # Change this if you use a non-default port.
198
+
199
+ streams:
200
+ "CAMERA_SERIAL":
201
+ ```
202
+
203
+ ### Setting up WHIP Ingestion (Frigate)
204
+
205
+ Frigate runs an instance of go2rtc under the hood. Add the following to your Frigate config:
206
+
207
+ ```yaml
208
+ go2rtc:
209
+ api:
210
+ listen: ":1984"
211
+ streams:
212
+ "CAMERA_SERIAL":
213
+ ```
214
+
215
+ ### Setting the Endpoint
216
+
217
+ 1. Open your Harbor app
218
+ 2. Go to Live
219
+ 3. Open Camera Settings
220
+ 4. Scroll down and click on Advanced Settings
221
+ 5. Enter the WHIP endpoint, for example: `http://192.168.1.10:1984/api/webrtc?dst=CAMERA_SERIAL`
222
+
223
+ Replace `CAMERA_SERIAL` with your camera serial number and `192.168.1.10` with the IP address of your go2rtc or Frigate server.
224
+
225
+ ### Repairing packet loss
226
+
227
+ WHIP media runs over UDP by default, and go2rtc does not negotiate
228
+ retransmission. `RegisterDefaultCodecs` in `pkg/webrtc/api.go` registers no RTX
229
+ (RFC 4588) codec, so go2rtc strips `rtx/90000` out of its SDP answer while still
230
+ advertising `a=rtcp-fb:96 nack`. Harbor cameras offer RTX correctly, but the
231
+ answer deletes the channel those retransmissions would travel on — go2rtc asks
232
+ the camera to retransmit over something it just removed, so nothing is ever
233
+ repaired. This is true as of go2rtc 1.9.10 and current master.
234
+
235
+ The symptom is occasional blocky or smeared frames that clear on the next
236
+ keyframe. Each lost packet damages the frame it belonged to, so even a very low
237
+ loss rate is visible — 0.03% loss on a 20 fps stream is a handful of damaged
238
+ frames every few minutes.
239
+
240
+ Running the WHIP session over ICE-TCP sidesteps this. The kernel retransmits
241
+ lost segments and delivers them in order, with no SDP negotiation involved:
242
+
243
+ ```yaml
244
+ webrtc:
245
+ listen: ":8555/tcp"
246
+ candidates:
247
+ - 192.168.1.10:8555
248
+ filters:
249
+ networks: [tcp4]
250
+ ```
251
+
252
+ Nest that block under `go2rtc:` if you are configuring Frigate.
253
+
254
+ Both settings are required. `filters` on its own is not enough: with a bare
255
+ `listen: ":8555"`, go2rtc registers every entry in `candidates` as **both** a TCP
256
+ and a UDP candidate, so it would keep advertising a UDP candidate that the filter
257
+ had stopped anything from listening on.
258
+
259
+ Confirm it took effect by checking the producer's transport, which should read
260
+ `http+tcp`:
261
+
262
+ ```bash
263
+ curl -s "http://192.168.1.10:1984/api/streams?src=CAMERA_SERIAL" | grep protocol
264
+ ```
265
+
266
+ Frigate does not expose port 1984 by default — use
267
+ `http://FRIGATE_HOST:5000/api/go2rtc/api/streams?src=CAMERA_SERIAL` instead.
268
+
269
+ What this costs:
270
+
271
+ - Loss becomes latency instead of corruption. A sustained wifi dropout shows up
272
+ as a stall rather than a glitch.
273
+ - `filters` applies to all inbound WebRTC, so browser live view moves to TCP as
274
+ well. If you watch streams from outside your network, forward **8555/tcp**, not
275
+ only UDP.
276
+ - The camera's congestion control stops having an effect, since TCP handles
277
+ pacing. That is not a concern at the camera's bitrate on a local network, but
278
+ it does mean the camera will not lower quality if the link saturates.
279
+
280
+ Measured on one Harbor camera pushing 1728x1080 HEVC over wifi, video packet loss
281
+ over a 3 minute sample went from 0.039% to 0.000%.
282
+
283
+ ## Development
284
+
285
+ ```bash
286
+ uv sync
287
+ uv run pytest
288
+ ```
289
+
290
+ ## License
291
+
292
+ Licensed under the Apache License 2.0.
@@ -5,12 +5,22 @@ from .data.mqtt_models import (
5
5
  HeartbeatEvent,
6
6
  LocalLivekitHeartbeatEvent,
7
7
  MotionDetectedEvent,
8
+ NoiseDetectedEvent,
9
+ Settings,
8
10
  SettingsEvent,
11
+ SettingsState,
12
+ UpdateCameraSettingsRequest,
9
13
  ViewerJoinedEvent,
10
14
  ViewerLeftEvent,
11
15
  )
12
16
  from .device import HarborDevice
13
- from .devices.camera import SPEAKER_STATES, STREAM_QUALITIES, HarborCamera
17
+ from .devices.camera import (
18
+ NIGHT_MODE_PREFERENCES,
19
+ SPEAKER_STATES,
20
+ STREAM_QUALITIES,
21
+ TEMPERATURE_SCALE_VALUES,
22
+ HarborCamera,
23
+ )
14
24
  from .devices.monitor import HarborMonitor
15
25
  from .events import (
16
26
  CameraEventUpdate,
@@ -20,6 +30,7 @@ from .events import (
20
30
  HeartbeatUpdate,
21
31
  LocalLivekitHeartbeatUpdate,
22
32
  MotionDetectedUpdate,
33
+ NoiseDetectedUpdate,
23
34
  RawEventUpdate,
24
35
  SettingsUpdate,
25
36
  ViewerInfo,
@@ -27,14 +38,27 @@ from .events import (
27
38
  ViewerLeftUpdate,
28
39
  parse_message,
29
40
  )
30
- from .exceptions import HarborCommandError
31
- from .mqtt import HarborMQTTClient
41
+ from .exceptions import HarborCommandError, HarborUnsupportedCommandError
42
+ from .mqtt import (
43
+ CLOCK_DISPLAY_PREFERENCE_KEY,
44
+ DEFAULT_NIGHT_MODE,
45
+ DEFAULT_TEMPERATURE_SCALE,
46
+ NIGHT_MODE_MODES,
47
+ NIGHT_MODE_PREFERENCE_KEY,
48
+ TEMPERATURE_SCALE_PREFERENCE_KEY,
49
+ TEMPERATURE_SCALES,
50
+ VIDEO_FLIP_PREFERENCE_KEY,
51
+ HarborMQTTClient,
52
+ NightMode,
53
+ TemperatureScale,
54
+ )
32
55
  from .state import HarborDeviceState, HarborEventState, HarborSourceType, HarborViewer
33
56
 
34
57
  __all__ = [
35
58
  "Harbor",
36
59
  "HarborCameraConfig",
37
60
  "HarborCommandError",
61
+ "HarborUnsupportedCommandError",
38
62
  "HarborMQTTClient",
39
63
  "HarborDevice",
40
64
  "HarborCamera",
@@ -50,19 +74,36 @@ __all__ = [
50
74
  "SettingsUpdate",
51
75
  "CameraEventUpdate",
52
76
  "MotionDetectedUpdate",
77
+ "NoiseDetectedUpdate",
53
78
  "ViewerInfo",
54
79
  "parse_message",
55
80
  "GetCameraSettingsRequest",
81
+ "UpdateCameraSettingsRequest",
56
82
  "HeartbeatEvent",
57
83
  "LocalLivekitHeartbeatEvent",
84
+ "Settings",
58
85
  "SettingsEvent",
86
+ "SettingsState",
59
87
  "ViewerJoinedEvent",
60
88
  "ViewerLeftEvent",
61
89
  "MotionDetectedEvent",
90
+ "NoiseDetectedEvent",
62
91
  "HarborSourceType",
63
92
  "HarborViewer",
64
93
  "HarborEventState",
65
94
  "HarborDeviceState",
95
+ "NightMode",
96
+ "NIGHT_MODE_MODES",
97
+ "NIGHT_MODE_PREFERENCE_KEY",
98
+ "NIGHT_MODE_PREFERENCES",
99
+ "DEFAULT_NIGHT_MODE",
100
+ "VIDEO_FLIP_PREFERENCE_KEY",
101
+ "CLOCK_DISPLAY_PREFERENCE_KEY",
102
+ "TemperatureScale",
103
+ "TEMPERATURE_SCALES",
104
+ "TEMPERATURE_SCALE_PREFERENCE_KEY",
105
+ "TEMPERATURE_SCALE_VALUES",
106
+ "DEFAULT_TEMPERATURE_SCALE",
66
107
  "SPEAKER_STATES",
67
108
  "STREAM_QUALITIES",
68
109
  ]