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

Support for Multiple DataPoints (e.g. for wall switches) #14

Closed CZ1979 closed 6 years ago

CZ1979 commented 6 years ago

Hi ! Thanks for that grat project. Makes my new wall switch works together with my smarthome. I bought a Xenon / Jinvoo (Tuya based) Wall switch with two buttons. Like this one: https://de.aliexpress.com/item/Manufacturer-Xenon-Wall-Switch-110-240V-Smart-Wi-Fi-Switch-button-Glass-Panel-3-gang-Ivory/32774600013.html

I first tried to flash it with tasmota FW, without success. So after hours of research, i found this project. After some small code changes , i successfully integrate the switch into my smarthome environment (iobroker mainly).

Only problem with the tuyapi was, that it only supports one datapoint (Means one button). So i add that functionality to the getStatus and setStatus method. I like to share my changes here, maybe someone also has that requirement. I just tested it with my wall switch! Works fine for me.

` /**

/**

clach04 commented 6 years ago

I have a similar situation with a device with 5 switches - I handled this by returning the entire dps result to the caller (in Python).

See https://github.com/clach04/python-tuya/blob/master/pytuya/__init__.py#L222

E.g.:

data = d.status()
print('Dictionary %r' % data)
switch_state = data['dps']['1']
print('switch_state %r' % switch_state)
codetheweb commented 6 years ago

@CZ1979 @clach04 please check out v2.0, it should work for devices with multiple switches/properties/dpss.