深圳氙气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如何使用从PreparedStatement返回的RowId。getGeneratedKeys()?   selenium chrome驱动程序中下一个网站url的java空白页   java如何将参数化匿名类转换为lambda?   java JUnit在AfterClass上获取测试结果   java将动态XML/JSON内容与静态标记化负载进行比较,并检索标记值   java共享一个需要数据持久性的项目[数据库]   java在调用方法时获取意外的参数类型。getParameterTypes()   java如何用jdbc在swing中用另一个字段替换外键?   需要java Jersey Tomcat CDI依赖项解释   java如何生成UML图   java如何编写Jersey rest服务可以通过给定的spring代码访问   SpringMaven存储库管理器Nexus与Java依赖项的Artifactory   java将包从另一个项目导入eclipse中的当前项目   加密Java使用密码加密文件