scrypted-tuya 0.1.2-beta → 2.1.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.
package/.clangd ADDED
@@ -0,0 +1,6 @@
1
+ CompileFlags:
2
+ CompilationDatabase: bridge/apps/native/build
3
+ Add:
4
+ - -Ibridge/apps/native/src
5
+ - -Ibridge/apps/native/build/_deps/glaze-src/include
6
+ - -std=c++23
package/CHANGELOG.md CHANGED
@@ -1,166 +1,119 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.2-beta
4
-
5
- - Accurately declare `codec: "hevc"`, `audio: { codec: "pcm_alaw" }`, `prebuffer: 4000`, and `oobCodecParameters: false` in `getVideoStreamOptions`.
6
- - Enables Scrypted stream router to automatically trigger the H.264 / AAC transcoding pipeline for HomeKit HAP compliance.
7
-
8
- ## 0.1.1-beta
9
-
10
- - Tuya RTSP Bridge port 8600 default across full stack.
11
- - Smart Life P2P HD RTSP stream integration with online auto-status, dynamic UI naming, and unconstrained HEVC/H.264 FFmpeg negotiation for Rebroadcast and snapshots.
12
-
13
- ## 0.1.0-beta.17
14
-
15
- - Initialize `online: true` in `TuyaCamera` constructor when P2P RTSP URL is configured.
16
- - Remove hardcoded `codec: "h264"` constraint in `getVideoStreamOptions` to support HEVC/H.265 streams from Tuya RTSP Bridge without parsing errors.
17
-
18
- ## 0.1.0-beta.16
19
-
20
- - Set stream display name to `Smart Life P2P HD` dynamically when P2P RTSP is configured.
21
- - Bypass Tuya Cloud offline check when P2P RTSP URL is present and mark camera online locally.
22
- - Remove hardcoded audio codec requirement to allow FFmpeg dynamic audio negotiation.
23
-
24
- ## 0.1.0-beta.15
25
-
26
- - Restore stable `cloud-rtsp` stream ID and `MediaStreamUrl` output to fix Rebroadcast stream bindings.
27
- - Let Scrypted's standard FFmpeg Camera mixin handle snapshot extraction from the P2P RTSP stream.
28
- - Set `source: "local"` when P2P RTSP is configured so Scrypted enables unthrottled local rebroadcast and prebuffering.
29
-
30
- ## 0.1.0-beta.14
31
-
32
- - Return `ScryptedMimeTypes.FFmpegInput` with `-rtsp_transport tcp` in `getVideoStream` for reliable Rebroadcast and FFmpeg streaming.
33
- - Convert video streams to JPEG image buffers in `takePicture` for working snapshot generation.
34
- - Dynamically label stream as `Smart Life P2P HD RTSP` (`id: p2p-hd-rtsp`) when P2P RTSP is configured.
35
-
36
- ## 0.1.0-beta.13
37
-
38
- - Implement `Camera` interface (`takePicture` & `getPictureOptions`) using the active video stream (P2P HD RTSP or Cloud RTSP) for snapshots.
39
- - Dynamic stream source classification (`local` when P2P RTSP is configured, `cloud` otherwise).
40
- - Advertise all standard stream destinations (`local`, `remote`, `local-recorder`, `remote-recorder`, etc.) for seamless Scrypted stream auto-routing.
41
- - Fire `onDeviceEvent` on P2P RTSP URL setting change to immediately re-route streams and snapshots.
42
-
43
- ## 0.1.0-beta.12
44
-
45
- - Switch Tuya RTSP Bridge default RTSP port to 8600 across the engine, backend, and Web UI.
46
- - Cleanly patch upstream bridge code during Docker build and startup.
47
- - Update RTSP URL documentation and camera placeholder to port 8600.
3
+ ## 2.1.0
48
4
 
49
- ## 0.1.0-beta.11
5
+ > [!WARNING]
6
+ > ⚠️ **Experimental Feature / Work in Progress**:
7
+ > Two-Way Audio (Talkback / Intercom) is currently in active development and considered experimental. While the complete end-to-end streaming architecture (WebRTC / RTMP) and 8 kHz / 40 ms timing synchronization are implemented, the audio delivered to the camera speaker may still sound distorted or robotic on various Tuya hardware DAC implementations and has not yet been fully resolved.
50
8
 
51
- - Add ingress and webui support to Tuya RTSP Bridge add-on (sidebar integration + Open Web UI button).
52
- - Add ffprobe resolution hint and camera stream URL logging in getVideoStream.
53
- - Add qualityToResolution() mapping for stream options hint.
54
- - 1.5s delay between quality command and RTSP allocation.
55
- - Improved logging for quality command acceptance/rejection.
56
- - Rename tuya_rtsp_bridge to bridge.
57
- - Remove chat.json from repo.
9
+ - **Two-Way Audio (Talkback / Intercom) Support**:
10
+ - Full talkback pipeline enabling two-way voice communication through Tuya / Smart Life cameras from Scrypted, HomeKit, and the Web UI.
11
+ - **Scrypted Intercom Integration**: Implemented Scrypted `Intercom` interface routing two-way audio through the companion Bridge RTMP ingest endpoint with real-time FFmpeg resampling.
12
+ - **Tuya WebRTC Audio Protocol**: Converted outbound voice stream to 8000 Hz mono G.711 μ-law with Tuya DAC signed-magnitude transformation in 40 ms frames, fixing 2× slowdown and pitch drop issues.
13
+ - **Native Engine Talkback Channel**: Added dedicated UDP ingestion and monotonic RTP timestamp sequencing (+320 per 160-byte payload) for the camera's WebRTC audio send track in `tuya-streamer`.
14
+ - **Web UI Controls**: Added interactive push-to-talk (PTT) and toggle talkback controls in the camera live player modal and camera cards.
15
+ - **Audio & Video Stream Improvements**:
16
+ - Fixed audio codec declaration in Scrypted stream options (`h264` video, `aac` / `pcm_alaw` audio).
17
+ - Cleaned up talkback audio filtering and buffering for ultra-low latency.
58
18
 
59
- ## 0.1.0-beta.10
60
-
61
- - Add per-camera Smart Life P2P HD RTSP override while preserving Tuya events and controls.
62
- - Add a Home Assistant add-on definition for QR-authenticated Smart Life WebRTC/P2P to RTSP bridging.
63
- - Pin the bridge backend to `DanEng1982/tuya-rtsp-bridge` v1.2.4.
64
- - Fix the add-on startup log command outside the Supervisor bashio shell and add an HTTP health check.
65
-
66
- ## 0.1.0-beta.9
67
-
68
- - Request the highest recognised writable quality advertised by the camera schema before RTSP allocation.
69
- - Safely fall back to Tuya's server-selected quality.
70
-
71
- ## 0.1.0-beta.7
72
-
73
- fix: fix setTimeout undefined function
74
- bump version
75
-
76
- ## 0.1.0-beta.6
77
-
78
- chore: update changelog
79
- fix: ensure timeout is actually correct and bound correctly
80
- chore: bump version
81
-
82
- ## 0.1.0-beta.5
83
-
84
- chore: update changelog
85
- fix: use correct property for checking connection state
86
- chore: bump version
87
-
88
- ## 0.1.0-beta.4
89
-
90
- fix: resolve mqtt connection issues
91
- bump version
19
+ ## 2.0.5
92
20
 
93
- ## 0.1.0-beta.3
21
+ - **Fix H.264 RTSP relay 404 error & expose correct public stream URL**:
22
+ - Migrate legacy `rtspPort=8554` DB entries to `RTSP_BASE_PORT` (8655) on startup (port 8554 is occupied by another service in HAOS environments, causing relay bind failure and HTTP 404 from ffmpeg DESCRIBE).
23
+ - Changed `camera.entity.ts` default `rtspPort` from `8554` to `8655` to match `RTSP_BASE_PORT`.
24
+ - Public RTSP URLs now show the actual host IP (resolved via HA Supervisor API in `run.sh`) instead of `127.0.0.1`.
94
25
 
95
- fixchangelog
96
- changelog
97
- quick fix
98
- bump to beta 3
26
+ ## 2.0.4
99
27
 
100
- ## 0.1.0-beta.2
28
+ - **Fix `spawn ffmpeg ENOENT` runtime error in Home Assistant Add-on**:
29
+ - Added `ffmpeg` package to the final production container (`Stage 3`), restoring live camera snapshots, card previews, and WebRTC-to-browser H.264 transcoding.
101
30
 
102
- update commit
103
- bump version
31
+ ## 2.0.3
104
32
 
105
- ## 0.1.0-beta.1
33
+ - **Fix Docker container build hang on Raspberry Pi (`pnpm prune --prod`)**:
34
+ - Replaced runtime `pnpm prune --prod` step with `pnpm --filter @tuya-bridge/server --legacy --prod deploy` in the build stage.
35
+ - Generates an isolated, production-only `node_modules` tree with prebuilt native `better-sqlite3` bindings in the build stage.
36
+ - Removed `pnpm` from the final runtime container for faster, deterministic image creation.
106
37
 
107
- improve mqtt reconnect, also update status
108
- wip: prevent setting motion if device has no motion detection
109
- fix: resolve indicator not updating
110
- feat: add support for light accessory in camera
111
- wip: fetch rtsp from Tuya Sharing SDK
38
+ ## 2.0.2
112
39
 
113
- ## 0.1.0
40
+ - **Fix `better-sqlite3` native bindings loading in Home Assistant add-on (`Could not locate the bindings file`)**:
41
+ - Registered `better-sqlite3` in `onlyBuiltDependencies` in `pnpm-workspace.yaml` to authorize native lifecycle compilation under pnpm v10.
42
+ - Multi-stage Docker optimization: installed `build-essential` & `python3` in `node-builder`, compiled native `.node` addons, and copied prebuilt modules directly into production container with `pnpm prune --prod`.
114
43
 
115
- wip: allow changing between different login methods
116
- wip: remove websocket for cameras since they are not supported
44
+ ## 2.0.1
117
45
 
118
- ## 0.0.9
46
+ - **Fix Docker container startup errors**:
47
+ - Approve `better-sqlite3` native build via `onlyBuiltDependencies` in `pnpm-workspace.yaml` (pnpm v10 lifecycle scripts approval).
48
+ - Precompile `better-sqlite3` native bindings in build stage and copy into production runtime container.
49
+ - Removed obsolete committed `tsconfig.build.tsbuildinfo` cache file that caused `tsc` to skip building server entrypoint `dist/main.js`.
50
+ - Added clean step to remove `.tsbuildinfo` before building and added `*.tsbuildinfo` to `.gitignore`.
51
+ - **Home Assistant Web UI in new tab**:
52
+ - Replaced `ingress: true` with `webui: "http://[HOST]:[PORT:6767]"` in `config.yaml` so the dashboard opens cleanly in its own browser tab.
53
+ - **Compiler warning cleanup**:
54
+ - Fixed integer signedness comparison in `AVIOReassembler`.
55
+ - Fixed missing struct field initializers in `IpcServer`.
119
56
 
120
- wip: update components
57
+ ## 2.0.0
121
58
 
122
- ## 0.0.8
59
+ ### Scrypted Plugin
123
60
 
124
- format code
125
- replace tool to use `ffmpeg` and bump v0.0.8
61
+ - Bump to stable `2.0.0` — no longer beta.
62
+ - Full end-to-end testing and validation completed.
63
+ - Improved Smart Life P2P HD RTSP integration via the companion Tuya Camera Bridge add-on.
64
+ - Stream options correctly declare `codec: "hevc"`, `audio: { codec: "pcm_alaw" }`, `prebuffer: 4000`, and `oobCodecParameters: false`.
65
+ - Quality selection requests the highest advertised writable quality enum (`hd`, `2k`, `4k`, etc.) before RTSP allocation, with safe fallback.
126
66
 
127
- ## 0.0.7
67
+ ### Tuya Camera Bridge (Home Assistant Add-on)
128
68
 
129
- plugins: update tsconfig.json
130
- Updated Tuya to v0.0.7 (#408)
69
+ Complete rewrite of the bridge add-on. The legacy Go/Python engine (originally based on **[DanEng1982/tuya-rtsp-bridge](https://github.com/DanEng1982/tuya-rtsp-bridge)**, to whom we are grateful) has been replaced with:
131
70
 
132
- ## 0.0.7-beta.2
71
+ - **Custom C++ RTSP engine** (`tuya-streamer`):
72
+ - Full RTSP/1.0 SDP compliance — `a=range:npt=0-`, `Content-Base`, complete `RTP-Info` with `seq`/`rtptime` anchors → VLC clock ticks correctly.
73
+ - Per-client monotonic RTP timestamp normalization via `std::chrono::steady_clock` — no more backward-jumping timestamps.
74
+ - Cached IDR/GOP priming → instant decode on connect.
75
+ - HEVC (H.265) and H.264; G.711 PCMU and AAC audio.
76
+ - **NestJS + Fastify backend** for camera management and Tuya QR-login flow.
77
+ - **React + HeroUI frontend** with:
78
+ - Live RTSP preview with play-on-hover overlay.
79
+ - Add-camera modal with themed QR code (foreground-only, less-rounded dots).
80
+ - Auto-open modal when no profiles exist.
81
+ - Snapshot age display, camera status, RTSP link copy.
82
+ - Ports: `6766` (API), `6767` (Web UI / ingress), `8655+` (RTSP per camera).
133
83
 
134
- tuya: fix crlf in candidate, fix empty stream name in rebroadcast, webrtc logging
135
- remove null candidate
84
+ ---
136
85
 
137
- ## 0.0.7-beta.1
86
+ ## 0.1.2-beta
138
87
 
139
- Fix issue not being able to select your prebuffer
88
+ - Accurately declare `codec: "hevc"`, `audio: { codec: "pcm_alaw" }`, `prebuffer: 4000`, and `oobCodecParameters: false` in `getVideoStreamOptions`.
89
+ - Enables Scrypted stream router to automatically trigger the H.264 / AAC transcoding pipeline for HomeKit HAP compliance.
140
90
 
141
- ## 0.0.7-beta.0
91
+ ## 0.1.1-beta
142
92
 
143
- Added support for webrtc, testing needed
93
+ - Tuya RTSP Bridge port 8600 default across full stack.
94
+ - Smart Life P2P HD RTSP stream integration with online auto-status, dynamic UI naming, and unconstrained HEVC/H.264 FFmpeg negotiation for Rebroadcast and snapshots.
144
95
 
145
- ## 0.0.6
96
+ ## 0.1.0-beta.17
146
97
 
147
- Improvements in WebRTC
148
- add initial support for webrtc
149
- allow triggering doorbell (#361)
98
+ - Initialize `online: true` in `TuyaCamera` constructor when P2P RTSP URL is configured.
99
+ - Remove hardcoded `codec: "h264"` constraint in `getVideoStreamOptions`.
150
100
 
151
- ## 0.0.5
101
+ ## 0.1.0-beta.16
152
102
 
153
- [Tuya Plugin] Fixed issue with devices not loading (#355)
103
+ - Set stream display name to `Smart Life P2P HD` dynamically when P2P RTSP is configured.
104
+ - Bypass Tuya Cloud offline check when P2P RTSP URL is present.
154
105
 
155
- ## 0.0.4
106
+ ## 0.1.0-beta.10
156
107
 
157
- Fix race condition for Tuya Devices (#351)
108
+ - Add per-camera Smart Life P2P HD RTSP override.
109
+ - Add Home Assistant add-on based on DanEng1982/tuya-rtsp-bridge v1.2.4.
158
110
 
159
- ## 0.0.3
111
+ ## 0.1.0-beta.9
160
112
 
161
- tuya: publish
113
+ - Request highest recognised writable quality advertised by camera schema before RTSP allocation.
114
+ - Safe fallback to Tuya's server-selected quality.
162
115
 
163
116
  ## 0.0.1
164
117
 
165
- tuya: project cleanups, remove unnecessary dependencies
166
- Add Tuya Camera (and Doorbell Cameras) Support (#350)
118
+ - Initial Tuya camera plugin extraction from Scrypted monorepo.
119
+ - Camera discovery, cloud RTSP streaming, doorbell events, motion detection.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrii Vynohradov (resonaura)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,93 +1,160 @@
1
- # scrypted-tuya
1
+ <img src="icon.png" width="64" height="64" alt="Tuya Bridge Icon" />
2
2
 
3
- Unofficial standalone fork of the Tuya plugin from the [Scrypted repository](https://github.com/koush/scrypted), extracted from [`plugins/tuya`](https://github.com/koush/scrypted/tree/main/plugins/tuya).
3
+ # scrypted-tuya & Tuya Camera Bridge
4
4
 
5
- The standalone extraction is based on upstream commit [`abd37e416dba4e36bcf9768ab6bbf1e82a206dd9`](https://github.com/koush/scrypted/commit/abd37e416dba4e36bcf9768ab6bbf1e82a206dd9). This repository contains only the Tuya plugin and does not include the rest of the Scrypted monorepository.
5
+ [![Version](https://img.shields.io/badge/Version-2.1.0-blue.svg)](CHANGELOG.md)
6
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+ [![Build & Publish](https://github.com/resonaura/scrypted-tuya/actions/workflows/publish.yaml/badge.svg)](https://github.com/resonaura/scrypted-tuya/actions/workflows/publish.yaml)
8
+ [![Home Assistant](https://img.shields.io/badge/Home%20Assistant-Add--on-orange.svg)](https://www.home-assistant.io/)
9
+ [![C++23 Engine](https://img.shields.io/badge/Native%20Engine-C%2B%2B23-00599C.svg)](bridge/apps/native)
10
+ [![Scrypted](https://img.shields.io/badge/Scrypted-Plugin-8A2BE2.svg)](https://scrypted.app)
11
+ [![Docker](https://img.shields.io/badge/Docker-GHCR-2496ED?logo=docker&logoColor=white)](https://github.com/resonaura/scrypted-tuya/pkgs/container/tuya-rtsp-bridge)
6
12
 
7
- This project is unofficial and is not affiliated with or endorsed by Scrypted or Tuya.
13
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/resonaura)
8
14
 
9
- ## What changed
15
+ Unofficial standalone Scrypted Tuya / Smart Life camera plugin & companion Home Assistant WebRTC-to-RTSP bridge.
10
16
 
11
- The upstream plugin requests a cloud RTSP stream from Tuya. For some cameras, Tuya returns the SD profile even when the camera also supports HD.
17
+ Extracted from [`plugins/tuya`](https://github.com/koush/scrypted/tree/main/plugins/tuya) and significantly extended with:
12
18
 
13
- This fork checks the writable device capabilities advertised through the Tuya Sharing API before allocating the RTSP stream. If the camera exposes a video `quality`, `resolution`, `clarity`, `definition`, or `stream_quality` enum, the plugin requests the highest recognised value advertised by that camera.
19
+ - **Maximum quality selection** requests the highest writable quality advertised by each camera before RTSP allocation.
20
+ - **Smart Life P2P bridge** — companion Home Assistant add-on with a custom C++ WebRTC-to-RTSP streaming engine.
14
21
 
15
- Recognised values include common profiles such as:
22
+ > This project is unofficial and is not affiliated with or endorsed by Scrypted or Tuya.
16
23
 
17
- - `hd`, `high`, `1080p`, and Tuya clarity value `4`;
18
- - `2k`, `ultra`, `uhd`, and `4k`;
19
- - lower profiles such as `sd`, `standard`, `720p`, and Tuya clarity value `2` are used only when no higher advertised option exists.
24
+ <p align="center">
25
+ <img src="media/tuya-bridge-dashboard.png" width="800" alt="Tuya Bridge Dashboard" />
26
+ </p>
20
27
 
21
- Unknown data points and values are not guessed. If the camera does not advertise a writable quality capability, or rejects the command, the plugin safely falls back to the RTSP quality selected by Tuya.
22
-
23
- ## Important limitation
24
-
25
- Tuya's documented cloud RTSP allocation endpoint exposes the stream transport, such as RTSP or HLS, but does not expose a documented quality selector. Consequently, this fork can request maximum quality only on cameras that advertise a writable quality-related data point through the Sharing API.
26
-
27
- Some models control HD exclusively through Tuya's P2P IPC SDK. Those cameras may still return an SD cloud RTSP stream. Check the actual stream resolution on the target camera after installation.
28
+ ---
28
29
 
29
30
  ## Features
30
31
 
31
- - Tuya and Smart Life camera discovery.
32
+ - Tuya and Smart Life camera discovery via MQTT.
32
33
  - Cloud RTSP camera streaming.
33
34
  - Maximum advertised video-quality selection with safe fallback.
34
35
  - Tuya doorbell ring notifications.
35
36
  - Motion events on supported devices.
36
37
  - Camera indicator and floodlight controls when exposed by the device.
38
+ - QR-code login flow (Tuya / Smart Life app — no developer keys required).
37
39
 
38
- ## Authentication
40
+ ---
39
41
 
40
- The recommended login method is the QR-code flow using the Tuya or Smart Life application. The legacy Tuya Developer Account login remains available for existing configurations.
42
+ ## Home Assistant Tuya Camera Bridge Add-on
41
43
 
42
- ## Development
44
+ For cameras that stream at low resolution via Tuya Cloud RTSP (or not at all), use the companion add-on in the `bridge/` folder. It runs a custom C++ streaming engine that:
45
+
46
+ 1. Authenticates via Smart Life QR code (scanned once from the Web UI).
47
+ 2. Opens a WebRTC P2P session to the camera using the Tuya protocol.
48
+ 3. Re-streams it as a standard RTSP feed on your local network.
49
+
50
+ ### 1-Click Install via Home Assistant
51
+
52
+ [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fresonaura%2Fscrypted-tuya)
53
+
54
+ ### Manual Install (Home Assistant)
43
55
 
44
- Requirements:
56
+ 1. **Settings → Add-ons → Add-on Store → ⋮ → Repositories**
57
+ 2. Add `https://github.com/resonaura/scrypted-tuya`
58
+ 3. Install **Tuya Camera Bridge** → Start
59
+ 4. Open the Web UI (ingress or `http://<ha-host>:6767`)
60
+ 5. Create a profile → scan the QR code in Smart Life
61
+ 6. Copy the RTSP URL shown on the camera card, e.g. `rtsp://<ha-host>:8655/<CameraName>`
62
+ 7. In Scrypted → camera settings → **Smart Life P2P HD RTSP URL** → paste URL
45
63
 
46
- - Node.js
47
- - npm
48
- - a Scrypted server for deployment and runtime testing
64
+ The Scrypted plugin continues handling discovery, motion, doorbell events and controls. Video comes from the P2P bridge.
49
65
 
50
- Install dependencies and verify the project:
66
+ ---
67
+
68
+ ## Standalone Docker (without Home Assistant)
69
+
70
+ You can run the Tuya Camera Bridge on any Linux/macOS machine with Docker:
71
+
72
+ ### Using Docker Compose (Recommended)
73
+
74
+ Clone the repository and run:
51
75
 
52
76
  ```bash
53
- npm ci
54
- npm run typecheck
55
- npm run build
77
+ git clone https://github.com/resonaura/scrypted-tuya.git
78
+ cd scrypted-tuya/bridge
79
+ docker compose up -d --build
56
80
  ```
57
81
 
58
- The Scrypted plugin archive is generated at:
59
-
60
- ```text
61
- out/plugin.zip
82
+ Example `docker-compose.yml`:
83
+
84
+ ```yaml
85
+ services:
86
+ tuya-bridge:
87
+ build:
88
+ context: .
89
+ dockerfile: Dockerfile
90
+ container_name: tuya-bridge
91
+ restart: unless-stopped
92
+ # CRITICAL: host network mode is required for camera P2P WebRTC / UDP discovery
93
+ network_mode: host
94
+ environment:
95
+ - PORT=6766
96
+ - WEB_PORT=6767
97
+ - RTSP_BASE_PORT=8655
98
+ # Optional: set LAN IP explicitly if auto-detection fails:
99
+ # - RTSP_HOST=192.168.1.50
100
+ - LOG_LEVEL=info
101
+ volumes:
102
+ - ./data:/data/tuya-bridge
103
+ - ./config:/config/tuya-bridge
62
104
  ```
63
105
 
64
- Quality-selection tests are located in `tests/quality.test.ts` and can be run with Bun:
106
+ ### Using `docker run`
65
107
 
66
108
  ```bash
67
- bun test tests/quality.test.ts
109
+ docker run -d \
110
+ --name tuya-bridge \
111
+ --restart unless-stopped \
112
+ --network host \
113
+ -v $(pwd)/data:/data/tuya-bridge \
114
+ -v $(pwd)/config:/config/tuya-bridge \
115
+ ghcr.io/resonaura/tuya-rtsp-bridge:latest
68
116
  ```
69
117
 
70
- ## Repository history
118
+ After starting, open `http://<host-ip>:6767` in your browser.
119
+
120
+ ### Network Ports
121
+
122
+ | Port | Protocol | Purpose |
123
+ |------|----------|---------|
124
+ | `6766` | TCP | REST / WebSocket API |
125
+ | `6767` | TCP | Web UI dashboard |
126
+ | `8655+` | TCP/UDP | RTSP streams (one per camera, starting at 8655) |
127
+
128
+ ---
71
129
 
72
- This repository is a standalone extraction rather than a GitHub network fork because GitHub cannot fork a single subdirectory of a monorepository. Upstream provenance is recorded in `STANDALONE-NOTICE.md` and `UPSTREAM-LICENSE-NOTICE.md`.
130
+ ## Authentication (Scrypted plugin)
131
+
132
+ The recommended login method is the QR-code flow from the Tuya or Smart Life application. The legacy Tuya Developer Account login remains available for existing configurations.
133
+
134
+ ---
135
+
136
+ ## Development
137
+
138
+ Requirements: Node.js, npm, a Scrypted server for deployment.
139
+
140
+ ```bash
141
+ npm ci
142
+ npm run typecheck
143
+ npm run build
144
+ ```
73
145
 
74
- ## License and attribution
146
+ The plugin archive is generated at `out/plugin.zip`.
75
147
 
76
- The upstream Scrypted repository uses directory-specific licensing and does not declare a conventional SPDX license specifically for `plugins/tuya`. The original upstream notice is preserved in `UPSTREAM-LICENSE-NOTICE.md`.
148
+ ---
77
149
 
78
- Review the upstream terms and obtain any required permission before redistributing this fork or publishing derived packages. Copyright remains with the original contributors.
150
+ ## Attribution
79
151
 
80
- ## Smart Life P2P HD through the Home Assistant add-on
152
+ The original Tuya plugin was written by the [Scrypted](https://github.com/koush/scrypted) contributors. This standalone fork is based on upstream commit [`abd37e4`](https://github.com/koush/scrypted/commit/abd37e416dba4e36bcf9768ab6bbf1e82a206dd9).
81
153
 
82
- For cameras that remain in **Smart Life**, Tuya Cloud RTSP may be fixed at 640×360. This repository therefore also exposes a Home Assistant add-on based on [DanEng1982/tuya-rtsp-bridge](https://github.com/DanEng1982/tuya-rtsp-bridge), which uses the MIT-licensed [seydx/tuya-ipc-terminal](https://github.com/seydx/tuya-ipc-terminal) WebRTC/P2P engine.
154
+ The bridge add-on was originally inspired by **[DanEng1982/tuya-rtsp-bridge](https://github.com/DanEng1982/tuya-rtsp-bridge)**. We are grateful for their pioneering work. The current add-on is a full from-scratch rewrite with a custom C++ engine, NestJS backend, and React frontend.
83
155
 
84
- 1. In Home Assistant, open **Settings → Add-ons → Add-on Store → Repositories**.
85
- 2. Add `https://github.com/resonaura/scrypted-tuya`.
86
- 3. Install and start **Tuya RTSP Bridge**.
87
- 4. Open `http://HOME_ASSISTANT_IP:8787`, create a QR code, then scan and confirm it in Smart Life.
88
- 5. Copy the camera HD URL. It has the form `rtsp://HOME_ASSISTANT_IP:8600/CameraName/hd`.
89
- 6. In Scrypted, open the matching camera created by this Tuya plugin and set **Smart Life P2P HD RTSP URL** to that URL.
156
+ ---
90
157
 
91
- The Tuya plugin will keep handling discovery, online state, motion, doorbell events, and controls. Video will come from the P2P/WebRTC bridge using the camera's main/HD stream. Removing the override restores the Tuya Cloud RTSP fallback.
158
+ ## License
92
159
 
93
- The add-on is pinned to Tuya RTSP Bridge `v1.2.4` rather than an unversioned branch.
160
+ See `UPSTREAM-LICENSE-NOTICE.md`. Review upstream terms before redistributing.
package/audio/baby.wav ADDED
Binary file
Binary file
package/audio/plop.wav ADDED
Binary file
@@ -0,0 +1,68 @@
1
+ [
2
+ {
3
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
4
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/crypto/aes.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/crypto/aes.cpp",
5
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/crypto/aes.cpp",
6
+ "output": "CMakeFiles/tuya-streamer.dir/src/crypto/aes.cpp.o"
7
+ },
8
+ {
9
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
10
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/media/reassembler.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/media/reassembler.cpp",
11
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/media/reassembler.cpp",
12
+ "output": "CMakeFiles/tuya-streamer.dir/src/media/reassembler.cpp.o"
13
+ },
14
+ {
15
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
16
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/rtsp/server.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/rtsp/server.cpp",
17
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/rtsp/server.cpp",
18
+ "output": "CMakeFiles/tuya-streamer.dir/src/rtsp/server.cpp.o"
19
+ },
20
+ {
21
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
22
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/p2p/cipher.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/p2p/cipher.cpp",
23
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/p2p/cipher.cpp",
24
+ "output": "CMakeFiles/tuya-streamer.dir/src/p2p/cipher.cpp.o"
25
+ },
26
+ {
27
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
28
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/p2p/client.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/p2p/client.cpp",
29
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/p2p/client.cpp",
30
+ "output": "CMakeFiles/tuya-streamer.dir/src/p2p/client.cpp.o"
31
+ },
32
+ {
33
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
34
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/ipc/server.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/ipc/server.cpp",
35
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/ipc/server.cpp",
36
+ "output": "CMakeFiles/tuya-streamer.dir/src/ipc/server.cpp.o"
37
+ },
38
+ {
39
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
40
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/session.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/session.cpp",
41
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/session.cpp",
42
+ "output": "CMakeFiles/tuya-streamer.dir/src/session.cpp.o"
43
+ },
44
+ {
45
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
46
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -isystem /Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -Wno-missing-braces -o CMakeFiles/tuya-streamer.dir/src/main.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/main.cpp",
47
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/main.cpp",
48
+ "output": "CMakeFiles/tuya-streamer.dir/src/main.cpp.o"
49
+ },
50
+ {
51
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
52
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -I/Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -o CMakeFiles/tuya-reassembler-test.dir/tests/reassembler_test.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/tests/reassembler_test.cpp",
53
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/tests/reassembler_test.cpp",
54
+ "output": "CMakeFiles/tuya-reassembler-test.dir/tests/reassembler_test.cpp.o"
55
+ },
56
+ {
57
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
58
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -I/Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -o CMakeFiles/tuya-reassembler-test.dir/src/crypto/aes.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/crypto/aes.cpp",
59
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/crypto/aes.cpp",
60
+ "output": "CMakeFiles/tuya-reassembler-test.dir/src/crypto/aes.cpp.o"
61
+ },
62
+ {
63
+ "directory": "/Users/resonaura/scrypted-tuya/bridge/apps/native/build",
64
+ "command": "/Library/Developer/CommandLineTools/usr/bin/c++ -I/Users/resonaura/scrypted-tuya/bridge/apps/native/src -I/Users/resonaura/scrypted-tuya/bridge/apps/native/build/_deps/glaze-src/include -std=c++2b -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk -O3 -Wall -Wextra -Wpedantic -pthread -o CMakeFiles/tuya-reassembler-test.dir/src/media/reassembler.cpp.o -c /Users/resonaura/scrypted-tuya/bridge/apps/native/src/media/reassembler.cpp",
65
+ "file": "/Users/resonaura/scrypted-tuya/bridge/apps/native/src/media/reassembler.cpp",
66
+ "output": "CMakeFiles/tuya-reassembler-test.dir/src/media/reassembler.cpp.o"
67
+ }
68
+ ]