Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

aioremootio - An asynchronous API client library for Remootio

aioremootio is an asynchronous API client library for Remootio written in Python 3 and based on asyncio and aiohttp.

Supported functionalities of the device

With this client library is currently possible to listen to state changes of a Remootio device, to listen to some events triggered by it, furthermore to operate the gate or garage door connected to it.

This client library supports currently the listening to following kind of events triggered by the device:

  • STATE_CHANGE which is triggered by the device when its state changes
  • RELAY_TRIGGER which is triggered by the device when its control output has been triggered to operate the connected gate or garage door
  • LEFT_OPEN which is triggered by the device when the connected gate or garage door has been left open
  • RESTART which is triggered by the device when it was restarted

Using the library

The following example demonstrates how you can use this library.

from typing import NoReturn
import logging
import asyncio
import aiohttp
import aioremootio


class ExampleStateListener(aioremootio.Listener[aioremootio.StateChange]):
    __logger: logging.Logger

    def __init__(self, logger: logging.Logger):
        self.__logger = logger

    async def execute(self, client: aioremootio.RemootioClient, subject: aioremootio.StateChange) -> NoReturn:
        self.__logger.info("State of the device has been changed. Host [%s] OldState [%s] NewState [%s]" %
                           (client.host, subject.old_state, subject.new_state))


async def main() -> NoReturn:
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)

    handler: logging.Handler = logging.StreamHandler()
    handler.setFormatter(logging.Formatter(fmt="%(asctime)s [%(levelname)s] %(message)s"))
    logger.addHandler(handler)

    connection_options: aioremootio.ConnectionOptions = \
        aioremootio.ConnectionOptions("192.168.0.1", "API_SECRET_KEY", "API_AUTH_KEY")

    state_change_listener: aioremootio.Listener[aioremootio.StateChange] = ExampleStateListener(logger)

    remootio_client: aioremootio.RemootioClient
    
    async with aiohttp.ClientSession() as client_session:
        try:
            remootio_client = await aioremootio.RemootioClient(
                connection_options,
                client_session,
                aioremootio.LoggerConfiguration(logger=logger),
                [state_change_listener]
            )
        except aioremootio.RemootioClientConnectionEstablishmentError:
            logger.exception("The client has failed to establish connection to the Remootio device.")
        except aioremootio.RemootioClientAuthenticationError:
            logger.exception("The client has failed to authenticate with the Remootio device.")
        except aioremootio.RemootioError:
            logger.exception("Failed to create client because of an error.")
        else:
            logger.info("State of the device: %s", remootio_client.state)
    
            if remootio_client.state == aioremootio.State.NO_SENSOR_INSTALLED:
                await remootio_client.trigger()
            else:
                await remootio_client.trigger_open()
                await remootio_client.trigger_close()
    
        while True:
            await asyncio.sleep(0.1)

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass

To get the API Secret Key and API Auth Key of your Remootio device you must enable the API on it according to the Remootio Websocket API documentation.

Running the bundled examples

The project source does also contain two examples.

The example example.py demonstrates how you can use the client as a Python object.

The example example_mc.py demonstrates how you can use the client as a Python object where it does not establish a connection to the Remootio device automatically during its initialization.

The example example_acm.py demonstrates how you can use the client as an asynchronous context manager.

To run the bundled examples you must

  1. also enable the API on your Remootio device to get the API Secret Key and API Auth Key of it, and
  2. add the source folder /src of the repository to your PYTHONPATH.

After the two steps described above you can run the bundled examples with the argument --help to show the usage information. E.g.:

python example.py --help

Running the bundled tests

To run the bundled tests you must create the .\remootio_device.configuration.json file with a content according to the following template.

{
    "host": "IP-ADDRESS-OR-HOST-NAME-OF-YOUR-DEVICE",
    "api_secret_key": "API-SECRET-KEY-OF-YOUR-DEVICE",
    "api_auth_key": "API-AUTH-KEY-OF-YOUR-DEVICE",
    "api_version": API-VERSION-OF-YOUR-DEVICE
}

Copyright © 2021 Gergö Gabor Ilyes-Veisz. Licensed under the Apache License, Version 2.0

Buy Me A Coffee

Metadata

Release files for aioremootio 1.0.0a21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aioremootio 1.0.0a21
File Size Uploaded Provenance Actions
aioremootio-1.0.0a21.tar.gz 25.7 kB Without provenance Details for aioremootio-1.0.0a21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aioremootio 1.0.0a21
File Interpreter ABI Platform Actions
aioremootio-1.0.0a21-py3-none-any.whl Python 3 none any Details for aioremootio-1.0.0a21-py3-none-any.whl

Total release size: 54.3 kB

Release files / aioremootio-1.0.0a21.tar.gz

Download URL aioremootio-1.0.0a21.tar.gz
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
89bb6e6edf47006006033c888a1e835b2acf6bf15f650fb4611dc20cbe3370b7
BLAKE2b-256 checksum
How to use checksums
5f3c0038bf58451c35c5a8e78e32fc125891260c6b940c9f80dd1145200c0c06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / aioremootio-1.0.0a21-py3-none-any.whl

Download URL aioremootio-1.0.0a21-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e88d3cc5b7f03dbf85c2f8b2f255124a1b2805275eeb2b25206368ccf7f8eaf
BLAKE2b-256 checksum
How to use checksums
83ed9a9f8adb054a463c29e3bf0a52c51f42d2422ee6fcc85f439695421f5049
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Security for aioremootio 1.0.0a21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page