codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.05k stars 337 forks source link

Device with 4 outlets and usb #40

Closed jcf6288 closed 6 years ago

jcf6288 commented 6 years ago

Is there a way to control individual outlets on a power strip? I can with pytuya but no with tuyapi. Thanks

tomporter518 commented 6 years ago

I cannot be sure, but if you look at the method comments for set, starting at line 210 in index.js, there is an example for using the option, dps. I believe this is the 'index' for the outlets on the device. When not specified, it looks to default to 1, which makes sense in single outlet devices. I have no multi-outlet devices so I cannot confirm, but should be easy enough to try.

codetheweb commented 6 years ago

Yes, it's possible. First, you should get the schema of your device by calling get({schema: true}). Then, set the DPS index you want to change with set({dps: 2, set: true}). See the docs for more details.