A Python library for interacting with the Sector Alarm API.
Project description
Sector Alarm API Data Retrieval Script
This Python script authenticates with the Sector Alarm API and retrieves various sensor data, including temperature, humidity, doors and windows status, smoke detectors, and leakage detectors. The results are consolidated and output as a JSON object.
Prerequisites
- Python 3.6+: Make sure Python is installed on your system.
- Environment Variables: Set the following environment variables:
SA_EMAIL
: Your Sector Alarm account email.SA_PASSWORD
: Your Sector Alarm account password.SA_PANELID
: The ID of the panel you wish to retrieve data from.
Dependencies
Install the required dependencies using pip
:
pip install requests
Configuration
The script relies on the following environment variables for authentication and panel identification:
SA_EMAIL
: Sector Alarm account email.SA_PASSWORD
: Sector Alarm account password.SA_PANELID
: Sector Alarm panel ID. You can set these in your shell session:
export SA_EMAIL="your_email@example.com"
export SA_PASSWORD="your_password"
export SA_PANELID="your_panel_id"
Alternatively, you can create a .env file and load it before running the script.
Usage
Run the script as follows:
python sector_alarm.py
Upon successful authentication, the script will attempt to retrieve data from multiple endpoints and output it in JSON format.
Script Structure
login()
: Authenticates with the Sector Alarm API and retrieves an authorization token.try_panel_endpoints()
: Fetches data from various /api/panel endpoints, includingGetPanelStatus
,GetSmartplugStatus
,GetLockStatus
andGetLogs
.try_housecheck_endpoints()
: Fetches data from various/api/housecheck
and/api/v2/housecheck
endpoints, including:Humidity
: Retrieves humidity levels.Doors and Windows
: Retrieves the status of doors and windows.Leakage Detectors
: Retrieves data on any leakage detectors.Smoke Detectors
: Retrieves smoke detector statuses.Cameras
: Retrieves camera statuses.Persons
: Retrieves person information.Temperatures
: Retrieves temperature levels.get_consolidated_data()
: Combines all retrieved data and outputs it as a JSON-formatted string.
Example Output
After running the script, you should see JSON output similar to the following:
{
"Humidity": [
{"Label": "Laundry Room", "Humidity": "45%"}
],
"Doors and Windows": [
{"Label": "Front Door", "Status": "Closed"},
{"Label": "Back Door", "Status": "Open"}
],
"Smoke Detectors": [
{"Label": "Hallway", "Status": "No Smoke Detected"}
]
}
Logging
The script uses Python’s logging
module to log success or error messages for each endpoint call. Adjust the logging level if needed.
Troubleshooting
- Invalid Credentials: Ensure that your
SA_EMAIL
andSA_PASSWORD
values are correct. - API Version Issues: The script is set to use
API-Version: 5
, which may need updating if the API changes. - Endpoint Failures: If specific endpoints fail, confirm they are available and your panel supports them.
License
This script is for personal and educational use. Please ensure you have permission to access the Sector Alarm API.
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
Built Distribution
File details
Details for the file sectoralarm-1.1.0.tar.gz
.
File metadata
- Download URL: sectoralarm-1.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2e57be9b5277afabf02eebda1bfd2445a07d9498d5685b5daf1c78ffb6bdacf |
|
MD5 | d972b1ada32789d4eb19ee7cf0a7e41f |
|
BLAKE2b-256 | 07f22779df4dc6d8d73dc7bd7aabae98543829ef807dcd4ffc37a1dbe90c8894 |
File details
Details for the file sectoralarm-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: sectoralarm-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c4dd24f4bdc4ec1e1bb109e2046b394f4f1490a018f5b232d3a3b92cbd27e07 |
|
MD5 | 306d48c2a8465378907c1330d488fd41 |
|
BLAKE2b-256 | 78400649825e81febad1a63aae0a971b88eff08d68ee68ce29d66a96da955a48 |