3735943886/tuya2mqtt

By 3735943886

Updated 7 months ago

Tuya Devices to MQTT Bridge

Image
Networking
Internet of things
0

2.8K

3735943886/tuya2mqtt repository overview

tuya2mqtt: Tuya Devices to MQTT Bridge

tuya2mqtt is a Python script that connects Tuya smart devices to an MQTT broker. It acts as a backend service that maintains a 24-hour TCP connection with registered Tuya devices. This allows it to instantly publish state changes to MQTT and enable device control via MQTT commands.


Docker Deployment

1. Standard Run (Default)

The simplest way to run tuya2mqtt. By default, it connects to a broker at localhost:1883 and starts the Web UI on port 8373.

-d, --restart=unless-stopped: to run the bridge as a background service.

--network=host: to communicate with Tuya devices.

docker run -d \
  --name tuya2mqtt \
  --restart=unless-stopped \
  --network=host \
  3735943886/tuya2mqtt:stable
  • Web UI: Accessible at http://<ip>:8373
2. Run with Custom MQTT Broker

Use this method if the MQTT broker requires authentication or is hosted on a different IP address.

docker run -d \
  --name tuya2mqtt \
  --restart=unless-stopped \
  --network=host \
  -e BROKER_HOSTNAME="192.168.0.100" \
  -e BROKER_PORT=1883 \
  -e BROKER_USERNAME="username" \
  -e BROKER_PASSWORD="password" \
  3735943886/tuya2mqtt:stable
3. Headless Run (UI Disabled)

To save system resources, the backend bridge service can run independently by disabling the Web UI. Set UI_PORT to 0 to prevent the UI from starting automatically.

docker run -d \
  --name tuya2mqtt \
  --restart=unless-stopped \
  --network=host \
  -e UI_PORT=0 \
  3735943886/tuya2mqtt:stable
4. Manual UI Execution (On-Demand)

When running in Headless mode (UI_PORT=0), the Web UI can still be launched temporarily for device addition or configuration.

Run the following command:

docker exec -it tuya2mqtt python3 tuya2mqtt_ui.py --ui-port 8373
  • Press Ctrl+C to stop the UI process. The bridge service will continue to run in the background.

Environment Variables
VariableDescriptionDefault
BROKER_HOSTNAMEMQTT Broker IP or Hostnamelocalhost
BROKER_PORTMQTT Broker Port1883
BROKER_USERNAMEMQTT Broker Username
BROKER_PASSWORDMQTT Broker Password
UI_PORTWeb UI Port (Set to 0 to disable auto-start)8373

For detailed usage instructions, please refer to the main repository.

GitHub Repository: https://github.com/3735943886/tuya2mqtt

Tag summary

Content type

Image

Digest

sha256:58d0dd8d2

Size

111.3 MB

Last updated

7 months ago

docker pull 3735943886/tuya2mqtt