jasonacox / tinytuya

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

Simple question about local key and device id #241

Closed Aadityajoshi151 closed 1 year ago

Aadityajoshi151 commented 1 year ago

Hi @jasonacox I recently purchased a smart plug and for controlling it through python, I am using your library. I followed the steps mentioned, got the local key and everything is working as expected. I had a couple of questions that I think you can answer:

**1. Would the local key and device id change if I connect my plug to a different network? (just like IP address changes) or would it be constant no matter where I go?

  1. My python will now take care of turning the plug on/off, so do I have to keep the Smart Life app installed on my phone and also the project that I created on cloud account for getting the local key?**

I also thank you for creating this library which is useful to me. I might post the my completed script that I am working on here once its done. Thank You

jasonacox commented 1 year ago

Hi @Aadityajoshi151 ! Thanks for the nice note and please do share any scripts you think others will find helpful. Some answers:

  1. The "device id" stays the same. The "local key" will update if you re-pair it with the SmartLife app. When you first pair the device, part of the paring process is to send the WiFi credentials to the device so it can connect to your WLAN network. If you move it to a new network, I believe the only way to change the WiFi settings is to re-pair it (resetting the local key). I could be wrong and there may be a way update the SSID details without the app, but I haven't explored that.
  2. The SmartLife app and the Tuya Cloud project are not required for TinyTuya to work once you have the local keys. However, as mentioned above, if the device has to be reset (or you want to add more Tuya devices), you will need the app and project again to get the keys.
Aadityajoshi151 commented 1 year ago

Hi @jasonacox Thank you for your reply. I guess for now I'll just uninstall the app but keep the cloud project in case I have to re-pair it in future. Regarding the script that I mentioned, I am writing just a simple script to start laptop charging (turn plug on) if battery percent is below certain level and stop charging (turn plug off) once it is above certain percent.

It might be slightly off-place here but nonetheless, I will still share it here and close the issue. Thank You.

Aadityajoshi151 commented 1 year ago

As promised, I have completed my script. I know it's very basic but just sharing it here just in case you or someone else needs it. https://github.com/Aadityajoshi151/Auto-Laptop-Charging Again, thank you for your help. Closing this issue for now. (It was never was an "issue")

jasonacox commented 1 year ago

Nice job @Aadityajoshi151 ! Thanks for sharing.