Skip to main content

Access API for echorobotics robot lawn mowers

Project description

pyechorobotics

Echorobotics Logo

Allows control and reads status of robot lawn mowers by echorobotics.

Used by Home Assistant Echorobotics integration.

Example:

import sys

import echoroboticsapi
import aiohttp
import asyncio
import logging


async def main():
    async with aiohttp.ClientSession(cookies=echoroboticsapi.create_cookies(user_id="your-user-id", user_token="user-user-token")) as session:
        api = echoroboticsapi.Api(session, robot_ids=["your-robot-id"])
        print(await api.last_statuses())
        print(await api.set_mode("chargeAndWork"))


if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

Unfortunately, the API doesn't tell is which mode ("chargeAndWork", "work" or "chargeAndStay") the robot is in. We can make an educated guess though, depending on what we set ourselves, history events and the status. This is what SmartMode does:

import sys

import echoroboticsapi
import aiohttp
import asyncio
import logging


async def main():
    async with aiohttp.ClientSession(cookies=echoroboticsapi.create_cookies(user_id="your-user-id", user_token="user-user-token")) as session:
        api = echoroboticsapi.Api(session, robot_ids=["your-robot-id"])
        smartmode = echoroboticsapi.SmartMode("your-robot-id")
        api.register_smart_mode(smartmode)
        
        print(await api.history_list())
        print(await api.last_statuses())
        print(smartmode.get_robot_mode())


if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

See also src/main.py

SmartFetch

While calling last_statuses() and history_list() regularly (suggestion every 2min and 15min), this is somewhat wasteful of bandwidth. Especially history_list() uses some 60KiB of data volume. If calling this every 15mins is an issue for you, you may be interested in SmartFetch.

import sys

import echoroboticsapi
import aiohttp
import asyncio
import logging


async def main():
    async with aiohttp.ClientSession(cookies=echoroboticsapi.create_cookies(user_id="your-user-id", user_token="user-user-token")) as session:
        api = echoroboticsapi.Api(session, robot_ids=["your-robot-id"])
        smartmode = echoroboticsapi.SmartMode("your-robot-id")
        api.register_smart_mode(smartmode)
        smartfetch = echoroboticsapi.SmartFetch(api)
        
        last_statuses = await smartfetch.smart_fetch()
        print(last_statuses)
        print(smartmode.get_robot_mode())


if __name__ == "__main__":
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

Dev notes

To make a new release, use GitHub website and draft a release manually. Make sure the version number in pyproject.toml matches the new tag. GitHub Actions will publish it to pypi.

Adding a new state

If a new state is found, it must be added to models.py. Also check notify_laststatuses_received() in smart_mode.py if it should be recognized as a specific Mode.

Finally, in home-assistant-echorobotics-integration, increment the version number in the manifest.json. Also check the translations in echorobotics/translations, and any custom dashboard code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyechorobotics-1.1.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyechorobotics-1.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file pyechorobotics-1.1.0.tar.gz.

File metadata

  • Download URL: pyechorobotics-1.1.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pyechorobotics-1.1.0.tar.gz
Algorithm Hash digest
SHA256 22487414d7c59d29e59c6fbddd6ec6f5180abb6fdfc31d2f2ae882a9da888caa
MD5 cd7759ef30eacb31f977b64634556dae
BLAKE2b-256 a4f1fc5a938d2b1da19157706d93c768fefac0e48e9b54e08c54a9bffa2f4c04

See more details on using hashes here.

File details

Details for the file pyechorobotics-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyechorobotics-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for pyechorobotics-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c12e9267ed5acfb6976db208622feded44f5b3a1e94c3af8eaa92251b7e6110
MD5 91aa98cb2a38fc820ccd70ce6e08e8ea
BLAKE2b-256 ce2eacbe9e130cf866e4bc8c7b9d1f7dd7501133305b0eb3169c30b472e313ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page