深圳氙气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使用servlet的正确方法是什么?   java Android ListView选中所有复选框(自定义ResourceCursorAdapter)   java如何在一个活动中正确处理多个片段交互侦听器?   java jUnit和忽略继承的测试   具有多个权限的java ActivityResultLauncher   Java:我可以通过应用程序将客户端重定向到loadbalancer后面的同一个会话/节点吗?   java如何使用Hibernate保存具有一对一关系的两个类?   java JEditorPane字体大小设置不准确   java为什么JUnit4导入不被识别,即使JUnit4在我的有效pom中。xml?   多次使用流后的java空映射   JavaSwing中AccessibleContext的用途是什么?   java指定使用T的类   java查找twitter4j转发速率限制   枚举的Java数组(类)   java通过Maven build排除了一些类