jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
1.01k stars 177 forks source link

Support v1.1 of Tuya API #126

Closed fhempy closed 2 years ago

fhempy commented 2 years ago

Hi,

can you please support v1.1 of the Tuya API as well? e.g. GET https://openapi.tuyaeu.com/v1.1/devices/{device_id}/specifications

Would be great to have a separate parameter to specify the version in this function: def tuyaPlatform(apiRegion, apiKey, apiSecret, uri, token=None):

Thanks!

fhempy commented 2 years ago

I created a PR for this one: https://github.com/jasonacox/tinytuya/pull/127

jasonacox commented 2 years ago

Hi @dominikkarall ! Thanks for this and the PR! I noticed you are only making this change to the wizard. There is a _tuyaplatform() function that is used in the Tuya Cloud functions in init.py that already has the ver option:

def _tuyaplatform(self, uri, action='GET', post=None, ver='v1.0', recursive=False):

A "to-do" on my list is to update wizard to use the built-in TinyTuya cloud functions which would use this.

I don't have a problem accepting your pull request, but I'm wondering how that would help you? Do you have a case where you are calling tuyaPlatform() from the wizard? I'm more curious that anything. ;)

fhempy commented 2 years ago

Hi @jasonacox ! Oh, I was not aware of the Cloud class. I'm using tinytuya just to send commands to the cloud and used the tuyaPlatform method for this, as the tuyaplatform method mentioned above was marked with as internal.

I just saw that you have a getdps() method there as well, so I'm going to use that one. I think you can skip the PR in that case. Thanks for your work!