Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple DPS #27

Closed
vvmichielvv opened this issue Jan 31, 2021 · 1 comment · Fixed by #228
Closed

Multiple DPS #27

vvmichielvv opened this issue Jan 31, 2021 · 1 comment · Fixed by #228

Comments

@vvmichielvv
Copy link

Hi,

I was wondering how to set multiple DPS in one request? F.e. i want to turn on a dimmer and set the dimming value in the same request. The devices support the following format i got from Googling around:

{multiple: true,data: {'1': true,'2': 50}}

Any thoughts?

Thanks!!

@jasonacox
Copy link
Owner

Great question! I think there may be a feature request here for a simple combined function call... hum...

You could use set_value(dps_index,value) but would need to do that for each DPS value (2 calls for your example). To send it in one packet, you can build the payload yourself and send it using this:

import tinytuya

# Connect to the device
d=tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY)
d.set_version(3.3)

# Generate the payload to send - add all the DPS values you want to change here
payload=d.generate_payload(tinytuya.CONTROL, {'1': True, '2': 50})

# Send the payload to the device
d._send_receive(payload)

NOTE: For some devices, it will not like this and you will get a timeout when you try to send the payload. Those devices require you to send two separate commands. My Gosund dimmer switch is one of those and requires that I send two commands, one for '1' for on/off and one for '3' for the dimmer. Also, keep in mind that the DPS value range for brightness may not be a 1-100, it could be 25-255 or 10-1000. At least that is the case for my devices (my Gosund is 25-255). The above code snip I ran against my smartbulbs without any problem (they accepted multiple DPS values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants