codetheweb / tuyapi

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

Protocol 3.4 support #606

Closed Apollon77 closed 1 year ago

Apollon77 commented 1 year ago

I catched the code from @harryzz repoditory where he posted that protocol 3.4 was implemented (see https://github.com/codetheweb/tuyapi/issues/481#issuecomment-985988646). I adjusted code style to the project one and reworked the code a bit to be less clustered when it comes to the 3.4 changes. Additionally I added a deferred promise for the "longer connect flow" to resolve the connect promise when the connection is really established.

This is completely untested! I hope that I get such a device tomorrow/tuesday, but if someone wants to : install from my Fork (https://github.com/Apollon77/tuyapi) and give it a shot. Ideally start with DEBUG=TuyAPI* and post your log when you tested it (successfuly or not) :-)

@codetheweb I will do a Draft PR for now, but if you have time please already have a look and tell me if you would like somethings to be adjusted. I do not get any lint or tests running locally ... will try again, but if you have ideas....

fixes #234, fixes #481

Apollon77 commented 1 year ago

@codetheweb Ok, lint and tests work now ... (and I adjusted a lot lint stuff)

Apollon77 commented 1 year ago

According to https://github.com/codetheweb/tuyapi/issues/234 the 3.2 support should be working

codetheweb commented 1 year ago

Thanks for doing this! Just wanted to let you know I've been really busy the last few days but hope to take a look soon.

Apollon77 commented 1 year ago

@codetheweb In the meantime I should also have a 3.4 device ... So plan is to try the changes out myself today

Apollon77 commented 1 year ago

@codetheweb Works as expected ... @harryzz did great work! With my cleanups ... Ready for Review

Apollon77 commented 1 year ago

For testing: I have one device and tested with this,but in the end no" long time testing" so far. I have also one more user using it - he had one time an issue that the devices went into a "restart loop", but honestly ... This could mean something is not 100%, but considering the quelity sometimes it must not mean anything ;-) And also after restarting problem did not re-occured till now.

So I would consider as ok aka "best we can say for now" :-)

Apollon77 commented 1 year ago

@codetheweb Lets wait a day longer ... On user that tried this has oissues, so I now started a bit a "Long time test" ... lets see if it is stable for me

Apollon77 commented 1 year ago

@codetheweb Ok I would go and release this. In fact it works. I only have one device to verify and yes this device closes the connection every 2-3h, but a reconnect works after 30 or latest second try after 60s ... but from all the quality issues we know from Tuya devices this is not enough to proof it a "protocol implementation issue" (and also python lib do not have anything else). So best it can be right now

codetheweb commented 1 year ago

Published in v7.5.0.

Apollon77 commented 1 year ago

Thank you very much!