Skip to content

How to Develop a New Driver

Hugo-tuya edited this page Jul 16, 2021 · 2 revisions

TESTTEST

How to implement plugins

Plugin development

Pay attention to several JSON files

  • The entry file index.js. Add your desired accessory type to the addAccessory() function and create the xx_accessy.js file.
JSON file
  • The xx_accessory.js file. In this file, traverse your newly created function in refreshAccessoryServiceIfNeed() and get the Characteristic corresponding to a service.
JSON file
  • The tuyaopenapi.js file contains device related APIs.
  • The tuyamqttapi.js file supports the MQTT service.

Common issues

For more information about Homebridge installation, see the Common Issues in the Homebridge repo.

Tuya Open API

  • login(username, password): Login to the Tuya IoT Platform.
  • getDeviceList(): Gets all the devices under an account's asset. (Devices correspond to accessories)
  • get_assets(): Gets the available assets.
  • getDeviceIDList(assetID): Queries the list of device IDs under an asset.
  • getDeviceFunctions(deviceID): Gets the instruction set.
  • getDeviceInfo(deviceID): Gets the information of single device.
  • getDeviceListInfo(devIds = []): Gets the information of multiple devices.
  • getDeviceStatus(deviceID): Gets the status of single device.
  • getDeviceListStatus(devIds = []): Gets the status of multiple devices.
  • sendCommand(deviceID, params): Sends commands to a device.

For more info, please check the Tuya Open API docs.

MQTT

  • start(): Starts MQTT.
  • stop(): Stops MQTT.
  • addMessageListener(listener): Adds callbacks.
  • removeMessageListener(listener): Removes callbacks.