# Python Elmax API client
![Elmax Logo](docs/elmax-logo.png?raw=true "Elmax Logo")
Asynchronous Python API client for interacting with the Elmax Cloud services, via HTTP apis.
![Release Build Status](https://github.com/albertogeniola/elmax-api/workflows/Release/badge.svg?branch=main)
![Testing Status](https://github.com/albertogeniola/elmax-api/workflows/Testing/badge.svg?branch=main)
![Documentation](https://github.com/albertogeniola/elmax-api/workflows/Publish%20Documentation/badge.svg?branch=main)
## Installation
Use the package manager pip to install Python Elmax API client:
```bash
$ pip3 install elmax-api --user
```
or, to install it globally, use the following command
```bash
$ pip3 install elmax-api
```
## Usage
```python
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](https://albertogeniola.github.io/elmax-api/).
Raw data
{
"_id": null,
"home_page": "https://github.com/albertogeniola/elmax-api",
"name": "elmax-api",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Alberto Geniola",
"author_email": "albertogeniola@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/82/99/bdb46020d1454cd2afd99ebb60358178f2a9df88d5bcbbdb3b0ba96453c5/elmax_api-0.0.6.3.tar.gz",
"platform": null,
"description": "# Python Elmax API client\n\n![Elmax Logo](docs/elmax-logo.png?raw=true \"Elmax Logo\")\n\nAsynchronous Python API client for interacting with the Elmax Cloud services, via HTTP apis.\n\n![Release Build Status](https://github.com/albertogeniola/elmax-api/workflows/Release/badge.svg?branch=main)\n![Testing Status](https://github.com/albertogeniola/elmax-api/workflows/Testing/badge.svg?branch=main)\n![Documentation](https://github.com/albertogeniola/elmax-api/workflows/Publish%20Documentation/badge.svg?branch=main)\n\n## Installation\n\nUse the package manager pip to install Python Elmax API client:\n\n```bash\n$ pip3 install elmax-api --user\n```\n\nor, to install it globally, use the following command\n\n```bash\n$ pip3 install elmax-api\n```\n\n## Usage\n\n```python\nimport asyncio\n\nfrom elmax_api.http import Elmax\nfrom elmax_api.model.command import SwitchCommand\n\nMY_USERNAME = 'TYPE_HERE_YOUR_ELMAX_EMAIL'\nMY_PASSWORD = 'TYPE_HERE_YOUR_ELMAX_PASSWORD'\n\n\nasync def main():\n # Instantiate the Elmax API client\n client = Elmax(username=MY_USERNAME, password=MY_PASSWORD)\n\n # List panels for your user\n panels = await client.list_control_panels()\n print(f\"Found {len(panels)} panels for user {client.get_authenticated_username()}\")\n\n # Get online panels only\n online_panels = []\n for p in panels:\n status = 'ONLINE' if p.online else 'OFFLINE'\n print(f\"+ {p.hash}: {status}\")\n if p.online:\n online_panels.append(p)\n\n if len(online_panels) == 0:\n print(\"Sorry, no panel to work with. Exiting.\")\n exit(0)\n\n # Fetch status of first panel\n p = online_panels[0]\n panel_status = await client.get_panel_status(control_panel_id=p.hash)\n\n # Print some zone status\n for z in panel_status.zones:\n print(f\"Zone '{z.name}' open: {z.opened}\")\n\n # Toggle some actuator\n actuator = panel_status.actuators[0]\n old_status = actuator.opened\n print(f\"Actuator {actuator.name} was {'ON' if old_status else 'OFF'}\")\n print(f\"Switching {'OFF' if old_status else 'ON'} actuator {actuator.name}\")\n await client.execute_command(endpoint_id=actuator.endpoint_id, command=SwitchCommand.TURN_ON if not old_status else SwitchCommand.TURN_OFF)\n\n print(\"Waiting a bit...\")\n await asyncio.sleep(5)\n\n print(\"Reverting back original actuator status\")\n await client.execute_command(endpoint_id=actuator.endpoint_id,\n command=SwitchCommand.TURN_ON if old_status else SwitchCommand.TURN_OFF)\n print(\"Done!\")\n\nif __name__ == '__main__':\n asyncio.run(main())\n```\n\n## Documentation\nFull API documentation is available on GitHub pages, [here](https://albertogeniola.github.io/elmax-api/).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Asynchronous API Library to work with Elmax devices",
"version": "0.0.6.3",
"project_urls": {
"Documentation": "https://github.com/albertogeniola/elmax-api",
"Homepage": "https://github.com/albertogeniola/elmax-api",
"Source": "https://github.com/albertogeniola/elmax-api",
"Tracker": "https://github.com/albertogeniola/elmax-api"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b7252de284d03582071b36bf3da30b2e7fc23d4ff8706d5a79ffe49224a4ae14",
"md5": "ac16f43ae2550bafa0944b081c980af8",
"sha256": "ffd52ac0f159e9734a5fcf4d2dd63f0aa9ec7703b163f78ab06611d18708c4bc"
},
"downloads": -1,
"filename": "elmax_api-0.0.6.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac16f43ae2550bafa0944b081c980af8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 19710,
"upload_time": "2024-11-29T23:25:09",
"upload_time_iso_8601": "2024-11-29T23:25:09.189108Z",
"url": "https://files.pythonhosted.org/packages/b7/25/2de284d03582071b36bf3da30b2e7fc23d4ff8706d5a79ffe49224a4ae14/elmax_api-0.0.6.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8299bdb46020d1454cd2afd99ebb60358178f2a9df88d5bcbbdb3b0ba96453c5",
"md5": "92cfbefbabf08a001dd47bb4ce137131",
"sha256": "6260b75df232b34cbbbf7ff45448df81173c952178a7574b719a6f259255379a"
},
"downloads": -1,
"filename": "elmax_api-0.0.6.3.tar.gz",
"has_sig": false,
"md5_digest": "92cfbefbabf08a001dd47bb4ce137131",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18712,
"upload_time": "2024-11-29T23:25:15",
"upload_time_iso_8601": "2024-11-29T23:25:15.968101Z",
"url": "https://files.pythonhosted.org/packages/82/99/bdb46020d1454cd2afd99ebb60358178f2a9df88d5bcbbdb3b0ba96453c5/elmax_api-0.0.6.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-29 23:25:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "albertogeniola",
"github_project": "elmax-api",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pyjwt",
"specs": [
[
">=",
"1.7.1"
]
]
},
{
"name": "httpx",
"specs": [
[
">=",
"0.18.0"
]
]
},
{
"name": "yarl",
"specs": [
[
">=",
"1.6.3"
]
]
},
{
"name": "websockets",
"specs": [
[
">=",
"13.0"
]
]
}
],
"lcname": "elmax-api"
}