Skip to content

seydx/tuya-ipc-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tuya IPC Terminal

License: MIT Go Version Build Status

A powerful CLI tool to connect Tuya Smart Cameras to RTSP clients through reverse-engineered Tuya browser client APIs. Stream your Tuya cameras directly to any RTSP-compatible media player or home automation system.

✨ Features

  • πŸ” Dual Authentication: QR code scanning OR email/password login
  • 🌍 Multi-Region Support: Support for all Tuya regions (EU, US, China, India)
  • πŸ‘₯ Multi-User Management: Handle multiple Tuya Smart accounts simultaneously
  • πŸ“‘ Session Persistence: Automatic session management with validation
  • πŸŽ₯ Camera Discovery: Automatic detection of all cameras from authenticated accounts
  • 🎬 RTSP Server: WebRTC-to-RTSP bridge for universal compatibility
  • πŸš€ Real-time Streaming: Direct camera access with minimal latency
  • πŸ”„ Multi-Client Support: Multiple RTSP clients per camera stream
  • 🎯 H265/HEVC Ready: Advanced codec support for optimal performance
  • 🎀 Two-Way Audio: Bidirectional audio for compatible cameras

πŸš€ Quick Start

Installation

git clone <repository-url>
cd tuya-ipc-terminal
chmod +x build.sh
./build.sh

1-Minute Setup

# 1. Add your Tuya account (interactive)
./tuya-ipc-terminal auth add eu-central user@example.com

# 2. Discover your cameras
./tuya-ipc-terminal cameras refresh

# 3. Start streaming
./tuya-ipc-terminal rtsp start --port 8554

# 4. Watch your cameras
ffplay rtsp://localhost:8554/MyCamera

πŸ“– Complete Documentation

πŸ” Authentication Management

Two Authentication Methods

🎯 QR Code

./tuya-ipc-terminal auth add eu-central user@example.com
# Scan QR code with Tuya Smart/Smart Life app

πŸ”‘ Email/Password

./tuya-ipc-terminal auth add eu-central user@example.com --password
# Enter password and select country code interactively

User Management Commands

# List all authenticated users
./tuya-ipc-terminal auth list

# Remove user authentication
./tuya-ipc-terminal auth remove eu-central user@example.com

# Refresh expired session
./tuya-ipc-terminal auth refresh eu-central user@example.com

# Test session validity
./tuya-ipc-terminal auth test eu-central user@example.com

🌍 Regional Information

# Show all available regions
./tuya-ipc-terminal auth show-regions

# Show country codes for password authentication
./tuya-ipc-terminal auth show-country-codes
./tuya-ipc-terminal auth show-country-codes --search germany

Available Regions:

Region Endpoint Description
eu-central protect-eu.ismartlife.me Central Europe
eu-east protect-we.ismartlife.me East Europe
us-west protect-us.ismartlife.me West America
us-east protect-ue.ismartlife.me East America
china protect.ismartlife.me China
india protect-in.ismartlife.me India

πŸ“Ή Camera Management

# List all discovered cameras
./tuya-ipc-terminal cameras list

# List cameras for specific user
./tuya-ipc-terminal cameras list --user eu-central_user_at_example_com

# Refresh camera discovery
./tuya-ipc-terminal cameras refresh

# Get detailed camera information
./tuya-ipc-terminal cameras info [camera-id-or-name]

πŸ“‘ RTSP Server Management

# Start RTSP server
./tuya-ipc-terminal rtsp start --port 8554

# Start as background daemon
./tuya-ipc-terminal rtsp start --port 8554 --daemon

# Stop RTSP server
./tuya-ipc-terminal rtsp stop

# Check server status
./tuya-ipc-terminal rtsp status

# List all available camera endpoints
./tuya-ipc-terminal rtsp list-endpoints

🎬 RTSP Streaming Guide

πŸ“Ί Connecting to Camera Streams

Camera streams are available at:

rtsp://localhost:[port]/[camera-name]
rtsp://localhost:[port]/[camera-name]/sd  # Sub-stream (lower quality)

🏠 Home Automation Integration

Home Assistant

camera:
  - platform: generic
    stream_source: rtsp://localhost:8554/LivingRoomCamera
    name: "Living Room Camera"
    
  - platform: generic
    stream_source: rtsp://localhost:8554/FrontDoor
    name: "Front Door Camera"

Go2RTC Integration

streams:
  living_room:
    - rtsp://localhost:8554/LivingRoomCamera
  front_door:
    - rtsp://localhost:8554/FrontDoor

πŸ—οΈ Advanced Usage

πŸ”§ Running as System Service

Create systemd service:

sudo tee /etc/systemd/system/tuya-rtsp.service > /dev/null <<EOF
[Unit]
Description=Tuya IPC Terminal RTSP Server
After=network.target

[Service]
Type=simple
User=$USER
WorkingDirectory=$PWD
ExecStart=$PWD/tuya-ipc-terminal rtsp start --port 8554
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl enable tuya-rtsp
sudo systemctl start tuya-rtsp

πŸ”€ Multiple Server Instances

# Different ports for different purposes
./tuya-ipc-terminal rtsp start --port 8554 --daemon  # Main cameras
./tuya-ipc-terminal rtsp start --port 8555 --daemon  # Backup/secondary

πŸ‘₯ Multi-User Setup Example

# Add accounts from different regions
./tuya-ipc-terminal auth add eu-central home@example.com      # European account
./tuya-ipc-terminal auth add --password us-west work@company.com  # US business account
./tuya-ipc-terminal auth add china personal@example.cn        # Chinese account

# Discover all cameras
./tuya-ipc-terminal cameras refresh

# List everything
./tuya-ipc-terminal auth list
./tuya-ipc-terminal cameras list

πŸ”„ Data Flow

  1. Authentication β†’ Tuya Cloud API
  2. Discovery β†’ MQTT + Tuya API
  3. WebRTC Connection β†’ Direct camera stream
  4. RTP Processing β†’ Video/audio packet handling
  5. RTSP Server β†’ Standard protocol output

πŸ’Ύ Data Storage

.tuya-data/
β”œβ”€β”€ user_eu-central_user_at_example_com.json    # User sessions
β”œβ”€β”€ user_us-west_business_at_company_com.json   # Multiple accounts
└── cameras.json                                # Camera registry

πŸ› οΈ Technical Details

πŸŽ₯ Supported Features

Feature Status Notes
H.264 Video βœ… Universal support
H.265/HEVC βœ… Better compression
PCMU Audio βœ… Standard quality
PCMA Audio βœ… Alternative codec
HD Streams βœ… Main camera stream
SD Streams βœ… Sub-stream, lower bandwidth
Multi-client βœ… Multiple viewers per camera
Two-way Audio βœ… Camera dependent

🎯 Supported Camera Types

Category Description Compatibility
sp Smart cameras βœ… Full support
dghsxj Additional camera type βœ… Full support
Others Generic Tuya cameras ⚠️ May work

πŸ› Troubleshooting

πŸ” Authentication Issues

Problem: Login fails

# 1. Check session status
./tuya-ipc-terminal auth test eu-central user@example.com

# 2. Try refreshing
./tuya-ipc-terminal auth refresh eu-central user@example.com

# 3. Re-authenticate if needed
./tuya-ipc-terminal auth remove eu-central user@example.com
./tuya-ipc-terminal auth add eu-central user@example.com

Problem: Country code not found (password login)

# Search for your country
./tuya-ipc-terminal auth show-country-codes --search germany
./tuya-ipc-terminal auth show-country-codes --search "united states"

πŸ“Ή Camera Discovery Issues

Problem: No cameras found

# 1. Verify authentication
./tuya-ipc-terminal auth list

# 2. Force refresh
./tuya-ipc-terminal cameras refresh

# 3. Check if cameras are online in Tuya Smart app
./tuya-ipc-terminal cameras list --verbose

πŸ“‘ RTSP Connection Issues

Problem: Can't connect to stream

# 1. Check server status
./tuya-ipc-terminal rtsp status

# 2. List available streams
./tuya-ipc-terminal rtsp list-endpoints

# 3. Test with simple player
ffplay rtsp://localhost:8554/CameraName

Problem: Poor stream quality

# Try sub-stream for lower bandwidth
ffplay rtsp://localhost:8554/CameraName/sd

# Check camera capabilities
./tuya-ipc-terminal cameras info "Camera Name"

Development Setup

git clone <repository-url>
cd tuya-ipc-terminal
go mod download
go run main.go --help

⚠️ Limitations & Considerations

Technical Limitations

  • 🌐 Requires active internet connection to Tuya servers
  • ☁️ Dependent on Tuya Cloud availability
  • πŸ“± QR authentication requires mobile app
  • πŸ”§ Some advanced camera features may not be supported

Security Considerations

  • πŸ”’ Sessions stored locally in JSON files
  • πŸ›‘οΈ No additional encryption beyond Tuya's implementation
  • πŸ”₯ Firewall configuration recommended for external access
  • πŸ” Consider network security for RTSP streams

πŸ“„ License

MIT License - See LICENSE for details.

⚠️ Disclaimer

This tool is created through reverse engineering of Tuya's web client APIs. Use responsibly and ensure compliance with:

  • Tuya's Terms of Service
  • Local privacy laws and regulations
  • Camera usage regulations in your jurisdiction

The authors are not responsible for any issues arising from the use of this software.

πŸ†˜ Support

Having issues? Here's how to get help:

  1. πŸ“– Check this README for common solutions
  2. πŸ› Search existing GitHub Issues
  3. πŸ’¬ Create a new issue with:
    • Your operating system
    • Go version (go version)
    • Error messages
    • Steps to reproduce

⭐ If this project helps you, please consider giving it a star on GitHub!

About

CLI tool to stream Tuya Smart Cameras via RTSP

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published