Asynchronous API Library to work with Elmax devices
Project description
Python Elmax API client
Asynchronous Python API client for interacting with the Elmax Cloud services, via HTTP apis.
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
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
elmax_api-0.0.2.tar.gz
(11.6 kB
view details)
Built Distribution
elmax_api-0.0.2-py3-none-any.whl
(15.3 kB
view details)
File details
Details for the file elmax_api-0.0.2.tar.gz
.
File metadata
- Download URL: elmax_api-0.0.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49c1ef80cb9389cb68f3393a57bbb39fe7d4344e71b6040ff8de535c1bf237d2 |
|
MD5 | 39f4f423a3e03231db1a15f401fd0ecb |
|
BLAKE2b-256 | 3066986dada7870cd0e213b44e3096c8d55ff60c97976fdfcc87b2a78f3d3840 |
File details
Details for the file elmax_api-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: elmax_api-0.0.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b38656199d90fbeddc94b34cddaf7904a7908d293d44fb5832e82a758fb35b |
|
MD5 | da4f14c733d9be96880cecd17475ea2e |
|
BLAKE2b-256 | b9e562387610b0665a5918f0b6d64d34ef8a56b2cc211480721cfd812b0deaaa |