palazzem / econnect-python

API adapter used to control programmatically an Elmo alarm system
BSD 3-Clause "New" or "Revised" License
8 stars 5 forks source link

Add `check()` API to retrieve the status of the system #40

Closed palazzem closed 4 years ago

palazzem commented 4 years ago

Overview

Closes #36

Adds a new public method to ElmoClient to make calls to multiple pages and endpoints to retrieve the global status of the system. It retrieves:

Calling the method returns a Python dict with the following data:

{
  "areas_armed": [{"id": 0, "name": "Entryway"}, ...],
  "areas_disarmed": [{"id": 1, "name": "Kitchen"}, ...],
  "inputs_alerted": [{"id": 0, "name": "Door"}, ...],
  "inputs_wait": [{"id": 1, "name": "Window"}, ...],
}

# Check if any system input is in alerted state (so it will be excluded when the Alarm is ON)
assert len(status["inputs_alerted"]) == 0

# The Alarm is OFF
assert len(status["areas_armed"]) == 0

# The Alarm is ON
assert len(status["areas_armed"]) > 0