Skip to main content

module to communicate to Husqvarna Automower API

Project description

Aioautomower

Asynchronous library to communicate with the Automower Connect API

This library is under development.

from aioautomower import GetAccessToken, GetMowerData, Return
from aiohttp import ClientError
from aiohttp.client_exceptions import ClientConnectorError
import asyncio

api_key = "12345678-abcd-1234-a1a1-efghijklmnop" ## Your API-Key
username = "username" ## Your username
password = "password" ## Your password


class Example_Token:
    """Returns the access token as dict."""
    def __init__(self, api_key, username, password):
        self.api_key = api_key
        self.username = username
        self.password = password

    async def token(self):
        try:
            get_token = GetAccessToken(
                self.api_key,
                self.username,
                self.password,
            )
            access_token_raw = await get_token.async_get_access_token()
        except (ClientConnectorError, ClientError):
            raise KeyError
        return access_token_raw

class Mower_Data:
    """Returns the data of all mowers as dict."""
    def __init__(self, api_key, access_token, provider, token_type):
        self.api_key = api_key
        self.access_token = access_token
        self.provider = provider
        self.token_type = token_type

    async def mowers(self):
        try:
            get_mower_data = GetMowerData(
                self.api_key,
                self.access_token,
                self.provider,
                self.token_type,
            )
            mower_data = await get_mower_data.async_mower_state()
        except (ClientConnectorError, ClientError):
            return "Make sure, you are connected to the Authentication API and the Automower API"
        return mower_data

class SendingCommand:
    """Returns the data of all mowers as dict."""
    def __init__(self, api_key, access_token, provider, token_type, mower_id, payload):
        self.api_key = api_key
        self.access_token = access_token
        self.provider = provider
        self.token_type = token_type
        self.mower_id = mower_id
        self.payload = payload

    async def mowers(self):
        try:
            send = Return(
                self.api_key,
                self.access_token,
                self.provider,
                self.token_type,
                self.mower_id ,
            )
            send = await send.async_mower_command()
        except Exception:
            return "Something went wrong"
        return send


example = Example_Token(api_key, username, password)
token_output = asyncio.run(example.token())
print(token_output)

access_token = token_output["access_token"]
provider = token_output["provider"]
token_type = token_output["token_type"]

example2 = Mower_Data(api_key, access_token, provider, token_type)
mower_output = asyncio.run(example2.mowers())
print(mower_output)

mower_id = mower_output["data"][0]["id"] ## '0' is your first mower
print (mower_id)
payload = '{"data": {"type": "ResumeSchedule"}}'  ## For more commands see: https://developer.husqvarnagroup.cloud/apis/Automower+Connect+API#/swagger
SendingCommand(api_key, access_token, provider, token_type, mower_id, payload)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

aioautomower-2021.8.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

aioautomower-2021.8.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file aioautomower-2021.8.0.tar.gz.

File metadata

  • Download URL: aioautomower-2021.8.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for aioautomower-2021.8.0.tar.gz
Algorithm Hash digest
SHA256 833f7f086d97b6ff55442b84f21cf28c5bf933de82f3bea8f30394339c831aef
MD5 f7085d31f1aa9e0cd59738cfedeaee12
BLAKE2b-256 928f38bcbd047c3d790ba14235b49c4c3c1f9ff818c85baad5be4ccc8d23de7f

See more details on using hashes here.

File details

Details for the file aioautomower-2021.8.0-py3-none-any.whl.

File metadata

  • Download URL: aioautomower-2021.8.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for aioautomower-2021.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 372289169d381256a107b62e78d752ae00680f1eca6d34d57d94bf907c1496fc
MD5 c3b701ab1b75f31051748c455bce17e2
BLAKE2b-256 f8199381c34630270e27655add2079f5333bc3285a289280a5eeab0d9b4a1555

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