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
43 stars 15 forks source link

how to connect to sub-devices that are managed by a tuya gateway? #132

Closed MrCO0OL closed 7 months ago

MrCO0OL commented 10 months ago

Hello,

Thanks for this awesome Tuya Node-Red nodes .... it made our life much easier. I managed to use these nodes to connect to multiple Tuya devices smoothly. However, I am facing a challenge to control and inquire data from the sub-devices connected to my DALI gateway. I can connect to the gateway itself, using gateway deviceID and gateway local_key ..... but it does not pass any commands to the sub devices. I tried to connect to the sub-device directly, by using the device id of the sub device, but the subdevice does not have a local key or ip ... because it is managed by the gateway.

so can anyone help me on how to communicate to the sub-device, what I need to fill in device node settings ... and example commands to control my sub-devices

below is my gateway properties: { "result": { "properties": [ { "code": "master_mode", "custom_name": "", "dp_id": 1, "time": 1693735217668, "value": "disarmed" } ] }, "success": true, "t": 1694083727645, "tid": "fdsgsadgfsad" }

and here is sub-device properties: { "result": { "properties": [ { "code": "switch_led", "custom_name": "", "dp_id": 20, "time": 1694082622234, "value": false }, { "code": "work_mode", "custom_name": "", "dp_id": 21, "time": 1694080337996, "value": "white" }, { "code": "bright_value", "custom_name": "", "dp_id": 22, "time": 1694080337996, "value": 1000 }, { "code": "countdown", "custom_name": "", "dp_id": 26, "time": 1694080337996, "value": 0 }, { "code": "control_data", "custom_name": "", "dp_id": 28, "time": 1693735235304, "value": "" }, { "code": "power_memory", "custom_name": "", "dp_id": 101, "time": 1693744187441, "value": "AAEAAAAAAAAD6APo" }, { "code": "rhythm_mode", "custom_name": "", "dp_id": 102, "time": 1693735235304 } ] }, "success": true, "t": 1694085474702, "tid": "sdfdsfaadsf" }

thanks in advance for the help

kind regards

msillano commented 7 months ago

For subdevices do not add a new node. You must send commands to DALI gateway, adding the CID of the target subdevice.

SET example:

                  {
                  "payload": {
                     "cid": "**MASKED**",        
                     "dps": "used-DP",
                     "set": num-Value|"str-Value"                                  
                   } }

The CID can be found using 'tuya-cli' in 'wizard ' mode. For more info see here Gateways-and-sensors. It should be kept in mind that subdevices (generally) have few DPs.

MrCO0OL commented 7 months ago

For subdevices do not add a new node. You must send commands to DALI gateway, adding the CID of the target subdevice.

SET example:

                  {
                  "payload": {
                     "cid": "**MASKED**",        
                     "dps": "used-DP",
                     "set": num-Value|"str-Value"                                  
                   } }

The CID can be found using 'tuya-cli' in 'wizard ' mode. For more info see here Gateways-and-sensors. It should be kept in mind that subdevices (generally) have few DPs.

Many thanks for the help … I could not find your guidance to use cid anywhere else in internet I tried it and it worked like magic

thanks again