深圳氙气ESP8266mod WiFi智能设备的Python接口

pytuya的Python项目详细描述


[![Build Status](https://travis-ci.org/clach04/python-tuya.svg?branch=master)](https://travis-ci.org/clach04/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 (or similar).

## Key extraction

https://github.com/clach04/python-tuya/wiki has background information 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:

演示:

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)

#在有4个可控制端口的交换机上,关闭第四个(第一个为1)

数据=D.SET U状态(假,4)

如果数据:

print(‘set_status() result %r’ % data)

print(‘set_status() extrat %r’ % data[20:-8])

todo demo timer(带注释并非所有设备都支持此功能,一种检查方法是检查jinvoo智能应用程序,查看是否有时钟图标未变暗)。

###加密说明

这些设备使用aes加密,这在python标准库中不可用,有三个选项:

  1. PyCrypto
  2. PyCryptodome
  3. pyaes (note Python 2.x support requires https://github.com/ricmoo/pyaes/pull/13)

###相关项目

###致谢

  • 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
  • mike-gracia for improved Python version support
  • samuscherer for RGB Bulb support
  • magneticflux- for improved Python version support
  • sean6541 - for initial PyPi package and Home Assistant support <https://github.com/sean6541/tuya-homeassistant>

关键词:家庭自动化 平台:任意 分类器:开发状态::4-测试版 分类器:目标受众::开发人员 分类器:主题::家庭自动化 分类器:许可证::OSI批准::MIT许可证 分类器:编程语言::python 分类器:编程语言::python::2 分类器:编程语言::python::3 分类器:编程语言::python::3.6 分类器:主题::家庭自动化

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java接口中的每个方法都是抽象的,但在抽象类中,我们也只能使用抽象方法   初始化Java中声明的、未初始化的变量会发生什么情况?   java BouncyCastle openPGP将字节[]数组加密为csv文件   在Java中将类A(和所有子类)映射到类B的实例的字典   RSA公钥编码,在Java和Android中,代码相同,结果不同   java在安卓中实现数字检测语音识别   java取消选择复选框   java如何在其他配置中重用Maven配置XML片段   java有没有一种有效的方法来检查HashMap是否包含映射到相同值的键?   spring处理程序调度失败;嵌套的例外是java。lang.NoClassDefFoundError:org/apache/http/client/HttpClient   带有ehcache的java多层缓存   java如何访问chromium(或任何其他浏览器)cookie   java通过将两个集合与spring data mongodb data中的条件合并来获取计数   安卓中R.java的语法错误