Tuya Device not connect

Hi there,

I want to evaluate and control a Duya thermostat via Node Red.
It works via the APP. I have created a project on the Tuya platform and can find the thermostat and control it (e.g. temperature).
I installed a Tuya Node in Node Red. Unfortunately I can't get a connection to the thermostat. I do not understand which ID or IP address I have to enter. Do services or similar have to be activated on the Tuya platform. I've already read. Unfortunately the descriptions are apparently out of date or I don't understand them. For example, you have to enter the internal IP address or the address of the Tuya platform.
Can someone help how to configure the node?

Many Thanks

Thoralf

1 Like

Not sure which Tuya node you are using as there is more than 1. I use node-red-contrib-tuya-smart-device which works well

The instructions for setting it up are here node-red-contrib-tuya-smart-device (node) - Node-RED (nodered.org)

but as described in these instructions you need to create a new account on iot.tuya.com and then follow the setup as shown here
tuyapi/SETUP.md at master · codetheweb/tuyapi · GitHub

This allows you to get the device id and the key which are required to access your device. The only tricky bit is creating a developer account on iot.tuya.com but if you follow the instructions you should be OK

Hi there,

thank you so much for your information. It works for me now. From my point of view, the decisive hint was the installation of "npm i @ tuyapi / cli -g" on my Raspberry (via command line). Then I started the tuya-cli wizard and at the end received the "ID" and the "Key". For me it was a bit confusing what kind of data I should enter. The names weren't unique. In the end, however, the wizard recognized the device. Then I knew that the entries were correct. I wrote this data into the node mentioned and the node went "online".
If I now change the temperature on the device or the APP, I get values displayed in Node Red. Even small controls are transferred to the device via Node Red. There are already some templates.
So thank you very much. I had already given up hope.

Thoralf :laughing: :laughing:

No problem, glad you got it all sorted out.

Since you both seem to have gotten this working recently,..
I tried using the instructions to set up a developer account and register my Tuya devices using the Smartlife App. All went well except that when it came to adding my Devices, the only option was to download and use the "IoT Device Management App", which downloads as a .APK file. Others seemed to indicate that as soon as I linked my Smartlike Account to the Project, my devices would just appear, but they didn't. Unfortunately when I run the App installed from the .APK it crashes on my Galaxy S21, in fact it seems to crash the S21 itself!
Since I have a project (Access Client) code and an Access Secret code, I tried using these plus a VirtualID from the Smartlife App in the wizard, but I got the "Device(s) failed to be registered! Error". Any clues would be much appreciated.
Thanks.

Smartlife & Smartlink are 2 completely different things. Have you followed the steps in tuyapi/SETUP.md at master · codetheweb/tuyapi · GitHub

You have to link your devices to the Smartlife app then create the account with Smartlink, I didn't have to download anything. Check that you followed the steps as described.

Thanks for replying. I believe I followed the instructions as per the link. I did it a few times, starting from scratch each time. I will wait a month or two and try again. Hopefully they will move beyond installing an APK which crashes my phone.

Why are you installing an APK on your phone. Smartlife is installed on the phone, everything else is installed on the Pi (or other) that Node-red is running on

I have a Raspberry Pi 4B, 8GB RAM. I recently set up Docker using IOTstack with the following containers: NodeRed, Mosquitto, InfluxDB, Grafana, and Portainer.

I followed the instructions (actually from a different website) to add the node-red-contrib-tuya-smart-device node to NodeRed through Manage Palette. All of my devices were transferred in from the Smart Life app. I do have a different issue, but let me see if I can help you get your devices added first.

@tonylane26 , on iot.tuya.com, please go to Cloud, My Services, Subscribed Services. Which services are listed there?

I have 5 subscribed services: IoT Core, Authorization, Smart Home Scene Linkage, Data Dashboard Service, and Device Status Notification. That last one, I believe was because I followed instructions from a different website. Not sure if you are missing that service, if it will help. But at least a place to start.

https://www.home-assistant.io/integrations/tuya

These are the instructions that I used when set up my Tuya account and linked devices from Smart Life app. Just stop when it gets into the Home Assist specific stuff. I abandoned Home Assistant and am using the node-red-contrib-tuya-smart-devicenode directly in NodeRed now.

Thanks for your input. I think authorizing the extra service "Device Status Notification" has helped, and the screenshots from the Home Assistant instructions confirmed the method I was using. I now get the same obstacle as before, but with some notifications.
After I scan the QR code and hit confirm on the Smartlife App on my phone, I get this pop-up on my browser:


regardless of which options I choose, when I hit OK I get these two error messages at the top of the browser screen:
Screenshot 2022-03-26 10.44.03 AM

I've tried this using the Smartlife App and the Tuya App (different accounts), and get the same result.

Any ideas are welcome. I feel I'm getting close! Thanks.

Hello,
sorry i was offline for a while. I would like to revisit my problem.
My thermostat works because the device is constantly online, i.e. it is present in the network with an IP address. The node also requires an IP address in the input field. In contrast, the smoke detector is not always online. I assigned it a fixed IP address in my router. But that's no use because he's not always there. The node tries to address the IP address. The result is: "not connect". When I unplug my thermostat, I got the same error message (IP address then also not available).
My conclusion for the smoke detector is that I have to fetch the data directly from the Tuya cloud. You would theoretically have to use a different node. Does anyone have experience or can confirm my theory?
For evidence, I would be very grateful!!!

Thoralf

In order to get a Smartplug working in my Domoticz/Nodered setup, I installed node-red-contrib-tuya-smart.
Using tuya-cli, I created a list of all my devices (9 lamps, 1 panel heater, 3 smartplugs).
I then created nodes for the 3 plugs, and inserted the local IP, device ID, and device key.
This does not work.... when I deploy, it changes status to "connecting", but after a few seconds goes to "disconnected".
I checked IP, ID and key. Also made sure the plugs are online.
What can be wrong?

You rigth: some devices cannot be seen by tuyapi.

I developped a IOT project to overcoming this limit (see tuyaDAEMON) and an example is exacly a smoke.detector node-red integration.

It is possible to integrate in tuyaDAEMON any tuya device and any custom device (MQTT, 433 Mhz, USB-serial etc..).

I believe that you could find interesting ideas in the documentation.

In the hope that this will help you, cordially

m..s.

You only require either the Device IP or Device Virtual ID (Don't use both). I use the Device Virtual ID and the Device Key. Ensure you only have ONE node connected to each device (on any flow)

Apologies, I got the node wrong as I use node-red-contrib-tuya-smart-device although the use of the tuyapi is the same

Right. WHen I try to omit either the local IP or the device ID, the "smart" node throws an error.

Meanwhile, I got the tuyapi to work, more or less. It gives me an object with several values that I can trace back to match the Tuya app, but there are a lot of other values that I don't recognize.
Is there a list or explanaition somewhere? I tried to find it on the Tuya developers site, but no luck...

In the configuration of the node I used all: local IP, ID and key.

Try the node-red-contrib-tuya-smart-device the node-red-contrib-tuya-smart has not been updated for a while. I couldn't get it to work either

Thanks, but that did not make it easier. I think I will try to get node-red-contrib-tuya-local to work. For now, I am getting a reliable response. I can switch the device on/off, and I get readings for status, current, power, voltage, IP, name. Plus a number of other values that I cannot place...

The values come out of the raw.dps object, and are labeled by numbers. I found the values mentioned above by comparing the values in the Tuya app on my Android phone with the output from a debug node, but there are still several that I don't recognize in the debug output. Also there are some values that I see in the Tuya app, but not in the debug output.
Is there a list somewhere to decypher the dps.raw object?

edit: I found a list on developer.tuya.com, but there are values missing. For instance, the kWh Today value that I can see in the Tuya app is not there.
list

This is my device output

{"1":true,"9":0,"18":0,"19":0,"20":2423,"21":1,"22":726,"23":30333,"24":20639,"25":1010}

and this is what they mean

DPS	Identifier				Description				Output			Step	Scale	Range		Unit	Data Type
1  	switch_1				On or Off 				- true or false										Command, Report
9  	countdown_1				Countdown				- 0				1		0		0-86400		s		Command, Report
18 	cur_current (current)	Current					- 0				1		1		0-30000		mA		Report
19 	cur_power (power)		Power					- 0				1		1		0-50000		W		Report
20	cur_voltage (voltage)	Voltage					- 2321			1		1		0-5000		V		Report

Factory Set and of no interest. All Report only
21	test_bit			Test flag					- 1				1		0		0-5					Report				(For factory use)
22	voltage_coe			Voltage coefficient			- 726			1		0		0-1000000			Report				(Set by factory for voltage measurement)
23	electric_coe		Current coefficient			- 30333			1		0		0-1000000			Report				(Set by factory for current measurement)
24	power_coe			Power coefficient			- 20639			1		0		0-1000000			Report				(Set by factory for power measurement)
25	electricity_coe		Statistics coefficient		- 1010			1		0		0-1000000			Report				(Set by factory for voltage statistic measurement)

Note that the output of a device are selected by the manufacturer so may or may not include values on the developer web site. I am guessing that if your device is outputting 21 - 25 that these are NOT included in the app

This is the list I am getting in the raw.dps object:

1: true
9: 0
17: 112
18: 0
19: 0
20: 2393
21: 1
22: 556
23: 28222
24: 15267
25: 2730
26: 0
38: "memory"
39: false
40: "relay"
41: false
42: ""
43: ""
44: ""

I understand that the device manufacturer decides which fields to return. What puzzles me is the fact that I can see some fields in the Tuya app, which donot show up in the raw.dps object!