Python 3中的Deebot客户端库
项目描述
Deebot设备(吸尘器)客户端库
安装
如果您有Python 3的最新版本,您应该可以使用 pip install deebot-client
命令来获取此版本的最新发布版本。
使用方法
要开始使用,您需要使用智能手机设置好EcoVacs账户。
您可以使用此作为Python库的其他功能尝试。一个简单的使用示例可能如下所示
import aiohttp
import asyncio
import logging
import time
from deebot_client.api_client import ApiClient
from deebot_client.authentication import Authenticator, create_rest_config
from deebot_client.commands.json.clean import CleanAction
from deebot_client.events import BatteryEvent
from deebot_client.mqtt_client import MqttClient, create_mqtt_config
from deebot_client.util import md5
from deebot_client.device import Device
device_id = md5(str(time.time()))
account_id = "your email or phonenumber (cn)"
password_hash = md5("yourPassword")
country = "DE"
async def main():
async with aiohttp.ClientSession() as session:
logging.basicConfig(level=logging.DEBUG)
rest_config = create_rest_config(session, device_id=device_id, alpha_2_country=country)
authenticator = Authenticator(rest_config, account_id, password_hash)
api_client = ApiClient(authenticator)
devices_ = await api_client.get_devices()
bot = Device(devices_[0], authenticator)
mqtt_config = create_mqtt_config(device_id=device_id, country=country)
mqtt = MqttClient(mqtt_config, authenticator)
await bot.initialize(mqtt)
async def on_battery(event: BatteryEvent):
# Do stuff on battery event
if event.value == 100:
# Battery full
pass
# Subscribe for events (more events available)
bot.events.subscribe(BatteryEvent, on_battery)
# Execute commands
await bot.execute_command(Clean(CleanAction.START))
await asyncio.sleep(900) # Wait for...
await bot.execute_command(Charge())
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
更高级的示例可以在 此处 找到。
针对Windows用户的说明
该库由于aiomqtt
的要求限制,无法直接在Windows上使用。更多信息及解决方案请见此处
谢谢
衷心感谢
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。
源代码分发
deebot_client-8.4.0.tar.gz (66.5 kB 查看散列值)
构建分发
deebot_client-8.4.0-py3-none-any.whl (142.1 kB 查看散列值)
关闭
deebot_client-8.4.0.tar.gz的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | 43c3821fbf8eec6e54c52c793520475b04762c9d445dc5ccffe055c686c31e60 |
|
MD5 | 39d4b58a97f9167cc2fddb8eb842b528 |
|
BLAKE2b-256 | 844397946deaf0b43323b68592c16e21450b17a09ab57462edbec732f8429636 |
关闭
deebot_client-8.4.0-py3-none-any.whl的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | b19840affecf8fd8324ee09e3cb9c50a46ab730e2041c3f3347010cff1c0886b |
|
MD5 | 76b770cb27b384f846600bb1c2a4660c |
|
BLAKE2b-256 | a1a9bb86be6027de700af447615ef2a1d3f14288293434daf4889bc3a67e269a |