Skip to main content

Asynchronous API Library to work with Elmax devices

Project description

Python Elmax API client

Elmax Logo

Asynchronous Python API client for interacting with the Elmax Cloud services, via HTTP apis.

Release Build Status Testing Status Documentation

Installation

Use the package manager pip to install Python Elmax API client:

$ pip3 install elmax-api --user

or, to install it globally, use the following command

$ pip3 install elmax-api

Usage

import asyncio

from elmax_api.http import Elmax
from elmax_api.model.command import SwitchCommand

MY_USERNAME = 'TYPE_HERE_YOUR_ELMAX_EMAIL'
MY_PASSWORD = 'TYPE_HERE_YOUR_ELMAX_PASSWORD'


async def main():
    # Instantiate the Elmax API client
    client = Elmax(username=MY_USERNAME, password=MY_PASSWORD)

    # List panels for your user
    panels = await client.list_control_panels()
    print(f"Found {len(panels)} panels for user {client.get_authenticated_username()}")

    # Get online panels only
    online_panels = []
    for p in panels:
        status = 'ONLINE' if p.online else 'OFFLINE'
        print(f"+ {p.hash}: {status}")
        if p.online:
            online_panels.append(p)

    if len(online_panels) == 0:
        print("Sorry, no panel to work with. Exiting.")
        exit(0)

    # Fetch status of first panel
    p = online_panels[0]
    panel_status = await client.get_panel_status(control_panel_id=p.hash)

    # Print some zone status
    for z in panel_status.zones:
        print(f"Zone '{z.name}' open: {z.opened}")

    # Toggle some actuator
    actuator = panel_status.actuators[0]
    old_status = actuator.opened
    print(f"Actuator {actuator.name} was {'ON' if old_status else 'OFF'}")
    print(f"Switching {'OFF' if old_status else 'ON'} actuator {actuator.name}")
    await client.execute_command(endpoint_id=actuator.endpoint_id, command=SwitchCommand.TURN_ON if not old_status else SwitchCommand.TURN_OFF)

    print("Waiting a bit...")
    await asyncio.sleep(5)

    print("Reverting back original actuator status")
    await client.execute_command(endpoint_id=actuator.endpoint_id,
                                 command=SwitchCommand.TURN_ON if old_status else SwitchCommand.TURN_OFF)
    print("Done!")

if __name__ == '__main__':
    asyncio.run(main())

Documentation

Full API documentation is available on GitHub pages, here.

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

elmax_api-0.0.3rc1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

elmax_api-0.0.3rc1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file elmax_api-0.0.3rc1.tar.gz.

File metadata

  • Download URL: elmax_api-0.0.3rc1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for elmax_api-0.0.3rc1.tar.gz
Algorithm Hash digest
SHA256 8da5afcca007a3c5d50966bb7e3b2eb0923f9146caf1a8d223127454bde4894b
MD5 d4856fef197a9425066624199d6f98f1
BLAKE2b-256 c09f45212cd90fd2a2772fe3f34bd79dfb42574dce0321b6536942a75d76754d

See more details on using hashes here.

File details

Details for the file elmax_api-0.0.3rc1-py3-none-any.whl.

File metadata

  • Download URL: elmax_api-0.0.3rc1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for elmax_api-0.0.3rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 29977cdef88fdbdc2a22f8f81f195c5f72a8b0bb3496a873f628e3b74320d8b7
MD5 93e34f6ef47d93b2209fb0f01a22bf63
BLAKE2b-256 90d10ec9d6a119c8ad7a35f218ffabf0d78f0661750333530d022eb514e1abcf

See more details on using hashes here.

Supported by

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