The House module for Linguflex is a sophisticated smart home solution that manages and controls various Tuya smart devices such as bulbs and outlets. It offers the capability to remotely control these devices, set bulb colors, and monitor their status, ensuring a seamless smart home experience.
- Functionality
- Examples
- Installation
- Configuration
- Connecting Devices to Tuya Cloud
- Fetching Device Parameters
The House module handles:
- Turning on/off smart bulbs and outlets.
- Setting colors for smart bulbs using hex color codes.
- Retrieving the current status and color of smart bulbs.
- Directly controlling Tuya smart devices over the local network without relying on internet-based cloud services.
- "Turn on the lights in the living room."
- "Set the bulb color in the bedroom to #FF4500."
- "Get the status of the ventilator outlet."
Before using the House module, ensure that Python is installed on your system along with the required dependencies. Clone the Linguflex repository and navigate to the House module directory.
The module requires the tinytuya
package for interacting with Tuya devices. Install it using pip:
pip install tinytuya
This file is essential for configuring your Tuya smart devices. Here's how to set it up:
-
Create a JSON file named
smart_home_devices.json
in thelingu/config
directory. -
Add your Tuya devices in the following format:
[ { "type": "Bulb", "name": "<Name of the Device>", "id": "<Device ID>", "ip": "<IP Address>", "key": "<Local Key>", "version": "<Version>" }, { "type": "Outlet", "name": "<Name of the Device>", ... } // Add more devices as needed ]
To control your Tuya devices locally, you first need to connect them to the Tuya cloud:
- Create a Tuya Account and log in.
- Create a cloud project, give a name and select "smart home" under industry and development method and select the data center for your region.
- Add the Device Status Notification API to the project
- After creating the project the next page should be "Overview" Tab from the "Cloud" menu. Remember Access ID/Client ID and Access Secret/Client Secret.
- From the tab bar where also "Overview" is located click on the right on "Devices"
- On the bar one line below that click "Link Tuya App Account", then click "Add App Account"
- Scan the displayed QR Code with your Tuya Application (Smart-Life App etc, there are many; the option for that is often under "profile" and sometimes a button on the top)
- Change the permissions to "Read, write and Manage"
- Now the devices will show up in the Tuya cloud.
- Open a console and run
python -m tinytuya
- Copy the output of the console into a text editor.
- Then run
python -m tinytuya wizard
- When asked "Enter API Key from tuya.com" enter the Access ID/Client ID from point 4. of the "Connect devices to tuya cloud" section
- When asked "Enter API Secret from tuya.com" enter the Access Secret/Client Secret from point 4. of the "Connect devices to tuya cloud" section
- When asked "Enter any Device ID" enter "scan"
- Enter region of tuya cloud project
- Copy the output of the console into a text editor.
- Search in the output for the values "id", "key", "version" and the ip adress of the devices you want to add from the output.
- Store these values into config/smart_home_devices.json
Once the smart_home_devices.json
is configured, restart the Linguflex application. Your House module should now be able to communicate with the specified Tuya smart devices on your local network.