Skip to content

Python interface to ESP8266MOD WiFi smart devices from Shenzhen Xenon

License

Notifications You must be signed in to change notification settings

thugseus/python-tuya

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-tuya

Python 2.7 and Python 3.6.1 interface to ESP8266MOD WiFi smart devices from Shenzhen Xenon. If you are using the Jinvoo Smart App, this allows local control over the LAN. NOTE requires the devices to have already been activated by Jinvoo Smart App.

https://github.com/clach04/python-tuya/wiki has background innformation. See https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md for how to get device id and local key. (the device id can be seen in Jinvoo Smart App, under "Device Info").

Known to work with:

Demo:

import pytuya

d = pytuya.OutletDevice('DEVICE_ID_HERE', 'IP_ADDRESS_HERE', 'LOCAL_KEY_HERE')
data = d.status()  # NOTE this does NOT require a valid key
print('Dictionary %r' % data)
print('state (bool, true is ON) %r' % data['dps']['1'])  # Show status of first controlled switch on device

# Toggle switch state
switch_state = data['dps']['1']
data = d.set_status(not switch_state)  # This requires a valid key
if data:
    print('set_status() result %r' % data)

# on a switch that has 4 controllable ports, turn the fourth OFF (1 is the first)
data = d.set_status(False, 4)
if data:
    print('set_status() result %r' % data)
    print('set_status() extrat %r' % data[20:-8])

TODO demo timer (with comment not all devices support this, one way to check, is to check Jinvoo Smart App and see if there is a clock icon that is not dimmed out).

Related Projects

Acknowledgements

  • Major breakthroughs on protocol work came from https://github.com/codetheweb/tuyapi from the reverse engineering time and skills of codetheweb and blackrozes, additional protocol reverse engineering from jepsonrob and clach04.
  • nijave pycryptodome support and testing
  • Exilit for unittests and docstrings

About

Python interface to ESP8266MOD WiFi smart devices from Shenzhen Xenon

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%