vinodsr / node-red-contrib-tuya-smart-device

a node-red module for managing tuya smart devices
https://flows.nodered.org/node/node-red-contrib-tuya-smart-device
MIT License
47 stars 15 forks source link

Manage all Tuya devices with node-red #139

Closed msillano closed 11 months ago

msillano commented 11 months ago

For the development of TuyaDAEMON I have collected a series of information that I believe may be of general interest.

1) Most Tuya-branded devices are controllable using the tuya-smart-device node. All you need is the deviceID, the localKey, and knowing the DPs and behavior of the device.

2) Some devices CANNOT be controlled locally with "tuya-smart-device" because they do not have a stable WiFi connection (typically battery-operated WiFi sensors). In these cases, you can use Tuya 'OpenAPI' via REST with node-red. Requires Tuya credentials and deviceID. Available as TuyaDAEMON extension and also as node-red library.

3) OpenAPI can be used only in polling. It is not possible to use it for asynchronous events generated by devices (e.g. alarms). One solution is the HW/SW trigger mechanism (designed for TuyaDAEMON), which allows bidirectional communications between SmarlLife Automation and node-red. Available as TuyaDAEMON extension and also in lite version.

4) Many WiFi products without the Tuya logo are built by various manufacturers (Ikea, Philips, Siemens...) with their own APP, but were developed using Tuya. Some of these products CAN be managed with SmartLife. Unfortunately, this needs to be verified on a case-by-case basis (Tuya communication).

5) Even some ZigBee devices produced without Tuya compatibility can be associated with a ZigBee-Tuya hub (e.g. thermometers for Xiaomi's HomeKit APP).

A) how to find deviceID, and localKey:

  1. deviceID only: in SmartLife, Device Info
  2. use Tuya IoT Development Platform for Tuya credentials
  3. use tuyapi_cli wizard
  4. use OpenAPI: 'Query Device Details' (preferred)

B) How to Find DPs. The simplest solution is to use the 'Send Properties' API (see here)

C) The study of the behavior and quirks of a device is greatly aided by the Log (max 7 days) present in 'Tuya Development Platform' (see here)

Caveat: Tuya OpenAPI and Automation are not very stable. Tuya occasionally changes the structure of Tuya Cloud; the latest change (June 20, 2023) made it necessary to update all Automation due to a change in the name of a condition. A change of deviceID also invalidates the Automation.

I hope this information helps someone ​

vinodsr commented 11 months ago

Thanks @msillano for the information