Control Tuya devices with MQTT over LAN.
Project description
local-tuya
Control Tuya devices with MQTT over LAN.
Features
- fully asynchronous
- persistent and robust communication to the device and to MQTT
- MQTT discovery
- automatic remote device state updates (remotes can still be used)
- configurable buffering for subsequent updates
- constraints between device commands
[!IMPORTANT] For now, only v3.3 is supported as I only own devices using this version.
Supported devices
Installation
The easiest way is to use the Docker image:
docker run -v {PATH_TO_CONFIG}:/app/conf.yaml:ro gpajot/local-tuya
Alternatively, you can use the python package and run directly: CONFIG=path/to/config python -m local-tuya.manager
Configuration
The minimal config is:
mqtt:
discovery_prefix: {YOUR_PREFIX_HERE}
hostname: 127.0.0.1
devices:
- name: My AC
model: Airton AC
config:
tuya:
id_: {DEVICE_ID_HERE}
address: {DEVICE_IP_HERE}
key: {DEVICE_KEY_HERE}
To control a device you will need these 3 things:
- the device ID
- the device local IP address
- the device local key (encryption key generated upon pairing)
[!IMPORTANT] This library does not provide support for getting these. See how to do that using any of those projects:
Generous thanks to the maintainers of those tools for details on interfacing with Tuya devices.
[!WARNING] Keep in mind that:
- After pairing the devices, it's recommended to assign static IPs in your router.
- If you reset or re-pair devices the local key will change.
- You can delete your tuya IOT account but not the SmartLife one and devices should be kept there.
- It looks like you can block the device access to internet from your router and still have it working.
Architecture
This library is composed of three main components:
- the Tuya protocol
- the device
- the MQTT client
Tuya protocol
The Tuya protocol is responsible for handling communication details with the Tuya device. Its interface consists of an asynchronous method to update the device and exposes state changes via events.
See protocol module.
Device
The device handles higher level functional logic such as buffering, constraints and specific device commands.
See device module.
MQTT client
Communication with home hubs through MQTT, supporting auto discovery.
See mqtt module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file local_tuya-4.1.0.tar.gz.
File metadata
- Download URL: local_tuya-4.1.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a33f6815cbbe4a17924031a5c6d032f2d1f15f520611ef72aa24d689944089
|
|
| MD5 |
b39672c691d19bfac653c4bb6c898ac9
|
|
| BLAKE2b-256 |
96f89eb8418174d5a782e6529233a33fb247580b5eeb8daa855cd42be45fa3fb
|
Provenance
The following attestation bundles were made for local_tuya-4.1.0.tar.gz:
Publisher:
publish.yml on gpajot/local-tuya
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
local_tuya-4.1.0.tar.gz -
Subject digest:
d9a33f6815cbbe4a17924031a5c6d032f2d1f15f520611ef72aa24d689944089 - Sigstore transparency entry: 545457581
- Sigstore integration time:
-
Permalink:
gpajot/local-tuya@5e43c93f56e2ad90682eb4e2bac02246eeaf1f95 -
Branch / Tag:
refs/tags/4.1.0 - Owner: https://github.com/gpajot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e43c93f56e2ad90682eb4e2bac02246eeaf1f95 -
Trigger Event:
release
-
Statement type:
File details
Details for the file local_tuya-4.1.0-py3-none-any.whl.
File metadata
- Download URL: local_tuya-4.1.0-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45c7fc67ff239caa56a4d6b2749425d278a5a10f62fcf93390b046da0a03d4d6
|
|
| MD5 |
38ea12e6b47cf72632a11b42040299a5
|
|
| BLAKE2b-256 |
463c6b1d15e5978e147e471763bb2a7c2c869275bfd095f63db5f6282361b3bf
|
Provenance
The following attestation bundles were made for local_tuya-4.1.0-py3-none-any.whl:
Publisher:
publish.yml on gpajot/local-tuya
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
local_tuya-4.1.0-py3-none-any.whl -
Subject digest:
45c7fc67ff239caa56a4d6b2749425d278a5a10f62fcf93390b046da0a03d4d6 - Sigstore transparency entry: 545457584
- Sigstore integration time:
-
Permalink:
gpajot/local-tuya@5e43c93f56e2ad90682eb4e2bac02246eeaf1f95 -
Branch / Tag:
refs/tags/4.1.0 - Owner: https://github.com/gpajot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e43c93f56e2ad90682eb4e2bac02246eeaf1f95 -
Trigger Event:
release
-
Statement type: