跳转到主要内容

Python 3中的Deebot客户端库

项目描述

Deebot设备(吸尘器)客户端库

PyPI - Downloads Buy Me A Coffee

安装

如果您有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上使用。更多信息及解决方案请见此处

谢谢

衷心感谢

  • deebotozmo,毕竟这是一个debotozmo分支:)
  • sucks,deebotozmo是从它分支出来的:)
  • xmpppeek,一个用于检查XMPP流量流(是的,你的吸尘器使用Jabber!)的优秀库,
  • mitmproxy,一个用于分析HTTPS的神奇工具,
  • click,一个制作Python命令行界面的完美且富有创意的库,
  • requests,一个用于HTTP请求的精美Python库,
  • 在线反编译器,它在弄清楚Android应用做什么方面非常有帮助,
  • Albert Louw,他慷慨地发布了他在设备上自己实验的代码以及
  • 所有提供了有用反馈和贡献代码的用户!

项目详情


发布历史 发布通知 | RSS源

下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。

源代码分发

deebot_client-8.4.0.tar.gz (66.5 kB 查看散列值)

上传时间: 源代码

构建分发

deebot_client-8.4.0-py3-none-any.whl (142.1 kB 查看散列值)

上传时间: Python 3

由...