Skip to main content

Python interface to Tuya WiFi smart devices.

Project description

TuyaFace

Tuya client that allows you to locally communicate with tuya devices without the tuya-cloud.

Installation

pip install tuyaface

Public Interface

Request current device status

status(device: dict)
Returns dict

Update device dps state

set_state(device: dict, value: bool, idx: int = 1)
Returns dict

Update device status

set_status(device: dict, dps: dict)
Returns dict

TuyaClient

Initialize client

TuyaClient(device: dict, on_status: callable=None, on_connection: callable=None)

Request current device status

status()
Returns dict

Update device dps state

set_state(value: bool, idx: int = 1)
Returns dict

Close the connection and stop the worker thread

stop_client()

example

from tuyaface.tuyaclient import TuyaClient

def on_status(data:dict):
    print(data)

def on_connection(value: bool):
    print(value)

device = {
    'protocol': '3.3', # 3.1 | 3.3
    'deviceid': '34280100600194d17c96',
    'localkey': 'e7e9339aa82abe61',
    'ip': '192.168.1.101',            
}

client = TuyaClient(device, on_status, on_connection)
client.start()

data = client.status()
client.set_state(!data['dps']['1'], 1) #toggle
client.stop_client()

Data structure

Device dict

device = {
    'protocol': '3.3', # 3.1 | 3.3
    'deviceid': '34280100600194d17c96',
    'localkey': 'e7e9339aa82abe61',
    'ip': '192.168.1.101',            
}

DPS dict

dps = {
    '1': True,
    '2': False,
    '101': 255,
    '102': 128,
    ...etc...
}

Todo v1.1.8

  • validate/sanitize request

Changelog

v1.1.7

  • added tuyaclient
  • Correct message header generation
  • fix typo in decrypt

https://github.com/TradeFace/tuya/wiki

Implementations

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuyaface-1.1.7.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

tuyaface-1.1.7-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file tuyaface-1.1.7.tar.gz.

File metadata

  • Download URL: tuyaface-1.1.7.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for tuyaface-1.1.7.tar.gz
Algorithm Hash digest
SHA256 c6e6b365bfb53baf45b6d63044f739dbc854d22f3b584eb491cb10e1cfc0232b
MD5 49535056b3b7984f45c424ad747d19cb
BLAKE2b-256 7341c0263f661f44f32c95b77fbf73ccb43264d1e90b77671c652a9b5eb9ab9e

See more details on using hashes here.

File details

Details for the file tuyaface-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: tuyaface-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for tuyaface-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6975c57595f68f5d37c1be07486108507f1b0634931437faccc567372841c098
MD5 ae0492046cb8adac350f31e634159336
BLAKE2b-256 4b41dff0be3c88845b09ddf331269808e75992b43c32614567ba0adf99f0b7ce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page