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

How handle subdevices #101

Closed balucio closed 1 year ago

balucio commented 1 year ago

Hi I have this kind of device, with some subdevices, but I don't know how to handle it

[
  {
    name: 'Remote',
    id: '......',
    key: '......',
    subDevices: [
      {
        name: 'DIY',
        id: '......',
        cid: '......'
      },
      {
        name: 'Dolby',
        id: '......',
        cid: '......'
      },
      {
        name: 'TV',
        id: '......',
        cid: '......'
      }
    ]
  },

Can you help me? Thanks

OtagIt commented 1 year ago

Project called TinyTuya can handle sending IR signals with such devices. Look at Universal IR Controller with optional Temp/Humidity More info here IR REMOTE CONTROL issue

Maybe @vinodsr could let us know whether it is possible to do the same in node-red with node-red-contrib-tuya-smart-device

It would be very useful. Thanks.

vinodsr commented 1 year ago

Any documentations on sub devices ?

On Tue, 20 Dec 2022 at 2:39 PM, OtagIt @.***> wrote:

Project called TinyTuya can handle sending IR signals with such devices. Look at Universal IR Controller with optional Temp/Humidity https://github.com/jasonacox/tinytuya#version-33---universal-ir-controller-with-optional-temphumidity

Maybe @vinodsr https://github.com/vinodsr could let us know whether it is possible to do the same in node-red with node-red-contrib-tuya-smart-device https://github.com/vinodsr/node-red-contrib-tuya-smart-device

It would be very useful. Thanks.

— Reply to this email directly, view it on GitHub https://github.com/vinodsr/node-red-contrib-tuya-smart-device/issues/101#issuecomment-1359042630, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQ6OBVOI6ZWMC4AMRBPH3WOFZURANCNFSM6AAAAAASS3YCSA . You are receiving this because you were mentioned.Message ID: @.*** com>

-- Vinod Surendran R vinodsr.dev

OtagIt commented 1 year ago

Hi @vinodsr , thank you very much for your time.

I believe originator of this issue @balucio is owner of device similar to Infra Red transmitters described in discussion I linked before ( describing post there ) You can control your TV, DVD player, Air-condition etc. with that tuya IR device. Therefore user defines "Remote control" for every device (TV, DVD player, Air-condition) in Tuya Smart application. These Remote controls can be completely custom. User defines names and buttons (even IR signal learning mode can be used to define "buttons" on these Remote controls). In @balucio 's example, he defined Remote controls with names DYI, Dolby, TV. Therefore there is no documentation about that concrete subDevices.

I linked the post which is describing how to handle sending IR signals with such tuya IR device (because sending defined IR signals is the purpose of that device) - IR REMOTE CONTROL issue solved

Basically, user needs to link his tuya IR device from Tuya Smart application to Tuya IoT Platform. User can grab head and key1 attributes using debug logs of Tuya IoT Platform because these attributes describes IR signal to be sent. ![debug logs]() Finally, user can send the same payload to his tuya IR device. For TinyTuya project it is documented here Universal IR Controller with optional Temp/Humidity

In summary, node-red-contrib-tuya-smart-device must be able to send payload similar to this (from TinyTuya)

command = {
    "control": "send_ir",
    "head": "",
    "key1": "[[TO_BE_REPLACED]]",
    "type": 0,
    "delay": 300,
}

payload = d.generate_payload(tinytuya.CONTROL, {"201": json.dumps(command)})

I did not study how TinyTuya is processing that control command and whether there is some limitation in TuyAPI which would not allow to implement the same in node-red-contrib-tuya-smart-device easily. It would be very useful to have that possibility.

OtagIt commented 1 year ago

Finally, I had a chance to test IR signal sending with real tuya IR device similar to this . It is working properly with node-red-contrib-tuya-smart-device e.g.

var command =
{
    control: "send_ir",
    head: "010ea600000000000700150040015a005600ad062d0e74",
    key1: "001$^002002FD7887@&$%@*",
    type: 0,
    delay: 300
}

msg.payload = {
    operation: "SET",
    dps: 201,
    shouldWaitForResponse: false,
    set: JSON.stringify( command )
}
return msg;

Command is properly delivered to tuya IR device and tuya IR device transmit correct IR signal immediately. Do not forget shouldWaitForResponse parameter. Otherwise there is an Error after 5-6 seconds: message: "Timeout waiting for status response from device id:****************

I would say that there is not any response for logical purpose. If user is controlling some device (e.g. TV) by IR signal, user can see whether it is working immediately on the device itself (volume on TV was added). If user will tap on Volume button 10 times in a row quickly and expects immediate action, there is no time to await response for each command.

@vinodsr , I would like to suggest adding note about shouldWaitForResponse parameter to documentation of node-red-contrib-tuya-smart-device here The parameter is supported by TuyAPI and it is very important in this case. Thank you for node-red-contrib-tuya-smart-device !

balucio commented 1 year ago

Oh... thanks... ithat's exactly what I was looking for..

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

Auto closing the issue