Skip to main content

API adapter used to control programmatically an Elmo alarm system.

Project description

Elmo

CircleCI codecov

Elmo is an API adapter used to control programmatically an Elmo alarm system. Through a generic configuration, the client allows:

  • Retrieving access tokens to make API calls
  • Obtaining/releasing the system Lock() to have exclusive control of the system
  • Arm/disarm all the alarms registered in the system

This project is a Work in Progress and the following functionalities are part of the roadmap:

  • Retrieve alarm status (armed/disarmed) via read-only API
  • Arm/disarm a single alarm or a subset
  • REST stateless API on top of the ElmoClient to expose these functionalities via Google Cloud Functions

Requirements

  • Python 3.5+
  • requests

Getting Started

Elmo is not available on PyPI so installation from this repository is required:

$ pip install git+https://github.com/palazzem/elmo-alerting.git

Arm/disarm the System

from elmo.api.client import ElmoClient

# Initialize the client with an API endpoint and a vendor and
# authenticate your connection to retrieve the access token
client = ElmoClient("https://example.com", "vendor")
client.auth("username", "password")

# To arm/disarm the system you must gain the exclusive Lock()
with client.lock("secret-code") as c:
    c.arm()     # Arms all alarms
    c.disarm()  # Disarms all alarms

The access token is valid for 10 minutes after that you need to authenticate again to refresh the token. Obtaining the lock via client.lock("code") is mandatory to arm or disarm the alert, otherwise the API returns 403.

Once the lock is obtained, other clients cannot connect to the alarm system and only a manual override on the terminal is allowed. Outside the context manager, the lock is automatically released.

Development

We accept external contributions even though the project is mostly designed for personal needs. If you think some parts can be exposed with a more generic interface, feel free to open a GitHub issue and to discuss your suggestion.

Coding Guidelines

We use flake8 as a style guide enforcement. That said, we also use black to reformat our code, keeping a well defined style even for quotes, multi-lines blocks and other.

Before submitting your code, be sure to launch black to reformat your PR.

Testing

tox is used to execute the following test matrix:

  • lint: launches flake8 and black --check to be sure the code honors our style guideline
  • py{35,36,37,38}: launches py.test to execute all tests under Python 3.5, 3.6, 3.7 and 3.8.

To launch the full test matrix, just:

$ tox

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

econnect-python-0.3.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

econnect_python-0.3.0-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file econnect-python-0.3.0.tar.gz.

File metadata

  • Download URL: econnect-python-0.3.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for econnect-python-0.3.0.tar.gz
Algorithm Hash digest
SHA256 155b970da8ef8de64d5a8cc5635a232b17bafc8bb2e17cc9e1a687ca94cbe39e
MD5 d53db3e27cf10756965097561f8d9273
BLAKE2b-256 ea6b793f54a08820e34a6bec489195be775c77466dd7f269242c89f43b14ac7f

See more details on using hashes here.

File details

Details for the file econnect_python-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: econnect_python-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for econnect_python-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2602190ae0e3c8a4988a2b04a2cd47306647db480115bf5183c71b4c79e130c7
MD5 ae7bd4ebc735d1d5ad7560f603988c0b
BLAKE2b-256 c4cbef99f513ab6cfce4ef13eed0817f5ead6d8957b2f44ffe3dac968bc925dc

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