How zalviandyr/homebridge-tuya works
Homebridge Tuya is a plugin that exposes Tuya Cloud devices as HomeKit accessories. The principal flow is platform configuration and authentication, device discovery through either Custom assets or Smart Home homes, then accessory creation and state/command translation. The README also documents broad device-category support, Tap-to-Run scenes, device overrides, infrared control, and camera streaming. Several relationships are grounded in excerpts or SOURCE INDEX references; unsampled feature wiring is shown only where the README documents it.
Main entry points: TuyaDeviceManager.ts Device operations · platform.ts Platform lifecycle · BaseAccessory.ts Accessory state and commands · TuyaOpenAPI.ts Tuya HTTP API
Components 23
Homebridge Platform
- Platform lifecycle
src/platform.ts - Config and overrides
src/config.ts - Accessory factory
src/accessory/AccessoryFactory.ts
Tuya Discovery
- Smart Home discovery
src/device/TuyaHomeDeviceManager.ts - Custom asset discovery
src/device/TuyaCustomDeviceManager.ts - Device operations
src/device/TuyaDeviceManager.ts - Device and DP model
src/device/TuyaDevice.ts
HomeKit Accessories
- Accessory state and commands
src/accessory/BaseAccessory.ts - Device category handlers
src/accessory - HomeKit characteristic mapping
src/accessory/characteristic - Tap-to-Run scenes
src/accessory/SceneAccessory.ts - Camera accessory
src/accessory/CameraAccessory.ts
Cloud Connectivity
- Tuya HTTP API
src/core/TuyaOpenAPI.ts - Tuya event MQTT
src/core/TuyaOpenMQ.ts - Logging
src/util/Logger.ts
Media and IR
- Camera streaming
src/util/TuyaStreamDelegate.ts - Recording delegate
src/util/TuyaRecordingDelegate.ts - FFmpeg process
src/util/FfmpegStreamingProcess.ts - Infrared accessories
src/accessory/IRControlHubAccessory.ts - Infrared utilities
src/util/InfraredTool.ts
Other components
- Homebridge user
- Tuya Cloud
- HomeKit
Connections 30
- Homebridge user → Platform lifecycle: configures
README.md - Platform lifecycle → Config and overrides: validates
src/platform.ts - Platform lifecycle → Tuya HTTP API: creates
src/platform.ts - Platform lifecycle → Custom asset discovery: selects Custom
src/platform.ts - Platform lifecycle → Smart Home discovery: selects Smart Home
src/platform.ts - Platform lifecycle → Accessory factory: creates handlers
src/platform.ts - Smart Home discovery → Device operations: extends
src/device/TuyaHomeDeviceManager.ts - Custom asset discovery → Device operations: extends
src/device/TuyaCustomDeviceManager.ts - Custom asset discovery → Tuya HTTP API: queries assets
src/device/TuyaCustomDeviceManager.ts - Device operations → Tuya HTTP API: requests device data
src/device/TuyaDeviceManager.ts - Device operations → Tuya event MQTT: uses events
src/device/TuyaDeviceManager.ts - Device operations → Device and DP model: builds devices
src/device/TuyaCustomDeviceManager.ts - Tuya HTTP API → Tuya Cloud: sends HTTP
README.md - Tuya event MQTT → Tuya Cloud: connects MQTT
README.md - Accessory factory → Accessory state and commands: creates handlers
src/accessory/AccessoryFactory.ts - Accessory factory → Device category handlers: dispatches categories
src/accessory/AccessoryFactory.ts - Accessory state and commands → Device operations: sends commands
src/accessory/BaseAccessory.ts - Device category handlers → Accessory state and commands: specializes
src/accessory/GarageDoorAccessory.ts - Device category handlers → HomeKit characteristic mapping: configures
src/accessory/AirConditionerAccessory.ts - Accessory state and commands → HomeKit: updates state
- HomeKit → Accessory state and commands: sets characteristics
- Platform lifecycle → Tap-to-Run scenes: supports scenes
README.md - Camera accessory → Camera streaming: creates stream delegate
src/accessory/CameraAccessory.ts - Camera streaming → Recording delegate: uses
src/util/TuyaStreamDelegate.ts - Camera streaming → FFmpeg process: starts process
src/util/TuyaStreamDelegate.ts - Camera streaming → Tuya Cloud: requests video stream
README.md - Infrared accessories → Device operations: sends IR commands
- Infrared utilities → Infrared accessories: supports control
- Tuya HTTP API → Logging: logs
src/core/TuyaOpenAPI.ts - Device operations → Logging: logs
src/device/TuyaDeviceManager.ts