HOW TO - Get All Local Tuya Keys (ALL KEYS, SIMPLE, NO SOLDERING)
Table of Contents
Introduction
In this tutorial, we will guide you through the process of extracting local Tuya keys from your Smart Life devices utilizing a rooted Android device and Bluestacks. This method circumvents the recent changes to Tuya Developer Tools, allowing you to successfully retrieve your local keys for integration with Home Assistant.
Chapter 1: Understanding the Need for Local Keys
- Local keys are essential for integrating Tuya devices with Home Assistant, allowing for local control without relying on cloud services.
- Recent updates to the Tuya Developer Tools have made it difficult for users to link their devices, especially for accounts created after March 24th.
- This tutorial focuses on a new method that does not depend on the Developer Tools.
Chapter 2: Requirements for the Tutorial
Before starting, ensure you have the following:
- Bluestacks: An Android emulator for running the Smart Life app.
- BS Tweaker: A tool for managing Bluestacks and extracting configuration files.
- Smart Life APK (v3.6.1): An older version of the Smart Life app, necessary for this method. Download it from APK Mirror.
- Home Assistant: Ensure you have a working version with HACS installed.
Optional
- C# Script: A console application for easier key extraction, available on GitHub.
Chapter 3: Setting Up the Emulator
-
Download and Extract BS Tweaker:
- Use a file archiver like WinRAR to extract the BS Tweaker files to a folder on your desktop.
-
Install Bluestacks:
- Run the Bluestacks installer and accept the license agreement to complete the installation.
-
Install Smart Life APK:
- Drag the downloaded Smart Life APK into the Bluestacks window to install it.
-
Log into Smart Life:
- Open the Smart Life app, agree to the terms, and log in to your account to generate the necessary configuration files.
Chapter 4: Extracting the Preference File with BS Tweaker
-
Open BS Tweaker:
- Launch the BS Tweaker application you extracted earlier.
-
Access File Manager:
- In BS Tweaker, select the File Manager option.
-
Navigate to the Config File:
- Go to
data
>data
>com.tuya.smartlife
>shared_prefs
. - Locate the file named
preference_global.xml
.
- Go to
-
Copy the Config File:
- Drag the
preference_global.xml
file to your desktop for easy access.
- Drag the
Chapter 5: Extracting Keys from the XML File
-
Open the XML File:
- Use a text editor (e.g., Notepad, WordPad) to open
preference_global.xml
.
- Use a text editor (e.g., Notepad, WordPad) to open
-
Find Local Keys:
- Press
Ctrl + F
to open the search function. - Search for "local_key" to locate the local keys and associated device IDs.
- Note the device name next to each local key for reference.
- Press
Using the C# Script (Optional)
- Run the Key Extraction Tool:
- Open the command prompt and navigate to where the extraction tool is located.
- Set the config file path by selecting the appropriate option in the tool.
- Execute the tool to display all devices with their local keys and IDs.
Chapter 6: Setting Up Local Tuya in Home Assistant
-
Install Local Tuya Integration:
- In Home Assistant, go to Configuration > Integrations and add Local Tuya.
-
Enter Local Keys:
- Use the extracted local keys to configure each device in Home Assistant.
- Provide names and device IDs as prompted during the setup.
-
Finalize Integration:
- Complete the setup process and verify that your devices appear in Home Assistant.
Conclusion
In this tutorial, you learned how to extract your local Tuya keys using Bluestacks and BS Tweaker, providing a reliable method for integrating your devices with Home Assistant. Remember to keep your Smart Life app updated and follow the provided links for further setup assistance. If you have any questions or need further clarification, feel free to reach out in the comments. Happy automating!