Lightberry客户端库
lightberry-lib的Python项目详细描述
Lightberry客户端库
lightberry是一个开源的家庭自动化平台,与alexa集成。这个库允许简单的开发 在python语言中的客户端实现。
安装
要安装lightberry客户端库,请从终端运行以下命令:pip3 install lightberry-lib
用法
from lightberrylib import LightberryClient
device = Device(config.deviceId, config.deviceConfig)
client = LightberryClient(config.mqtt.host, config.mqtt.port)
client.set_device(device)
client.set_keys(config.deviceId, config.secret)
client.connect()
LightberryClient
构造函数接受两个参数:mqtt主机地址和端口(通常是1883)。Device
类是一个自定义类,对于您的实现是唯一的。它必须实现
lightberry-lib.device_protocols.IBaseDevice
协议,以及可选的
lightberry-lib.device_protocols.IAlexaEnabledDevice
启用alexa功能的协议。
传递给client.set_keys()
方法的密钥是通过
POST /api/developer/devices
终结点。
有关更多信息,请查看examples
目录中的引用实现。