A modern Python library for the Crow Cloud API - Next Generation
Project description
Crow Security NG
A modern, async Python library for the Crow Cloud API - Next Generation.
This library provides a clean, type-hinted interface for interacting with Crow Security alarm systems (Shepherd panels) through the Crow Cloud API.
Features
- Fully async - Built on
aiohttpfor efficient async I/O - Type hints - Complete type annotations for better IDE support
- Modern Python - Requires Python 3.10+, uses dataclasses and enums
- Proper error handling - Dedicated exception classes for different error types
- MAC address normalization - Accepts any MAC format (with/without separators)
- WebSocket support - Real-time updates from your alarm panel
- Backwards compatible - Provides
Sessionclass compatible with originalcrow_security - Retry logic - Automatic retries with exponential backoff
- Context managers - Proper resource cleanup with async context managers
Installation
pip install crow_security_ng
Quick Start
Basic Usage
import asyncio
from crow_security_ng import Session
async def main():
# Create a session
session = Session("your-email@example.com", "your-password")
# Get your panel (MAC address can be in any format)
panel = await session.get_panel("AABBCCDDEEFF")
# or: await session.get_panel("AA:BB:CC:DD:EE:FF")
# or: await session.get_panel("aa-bb-cc-dd-ee-ff")
print(f"Panel: {panel.name}")
# Get alarm areas
areas = await panel.get_areas()
for area in areas:
print(f"Area: {area.name}, State: {area.state}")
# Arm the alarm
await panel.set_area_state(areas[0].id, "arm")
# Get zones
zones = await panel.get_zones()
for zone in zones:
print(f"Zone: {zone.name}, Open: {zone.is_open}")
# Clean up
await session.close()
asyncio.run(main())
Using Context Manager
import asyncio
from crow_security_ng import Session
async def main():
async with Session("email@example.com", "password") as session:
panel = await session.get_panel("AABBCCDDEEFF")
areas = await panel.get_areas()
print(areas)
asyncio.run(main())
Advanced Client Usage
import asyncio
from crow_security_ng import CrowClient
async def main():
async with CrowClient(
email="email@example.com",
password="password",
timeout=60,
retry_count=5,
) as client:
# Get all panels
panels = await client.get_panels()
# Work with a specific panel
panel = await client.get_panel("AABBCCDDEEFF")
# Control outputs
outputs = await client.get_outputs(panel.mac)
await client.set_output_state(panel.mac, outputs[0].id, True)
# Get measurements (temperature, humidity, etc.)
measurements = await client.get_measurements(panel.mac)
for m in measurements:
print(f"{m.name}: {m.value} {m.unit}")
asyncio.run(main())
WebSocket Real-time Updates
import asyncio
from crow_security_ng import Session
async def handle_message(msg: dict):
print(f"Received: {msg}")
async def main():
session = Session("email@example.com", "password")
panel = await session.get_panel("AABBCCDDEEFF")
# This will run indefinitely, receiving real-time updates
await session.ws_connect(panel.mac, handle_message)
asyncio.run(main())
API Reference
Session
The Session class provides a simple interface compatible with the original crow_security library.
session = Session(email, password)
panel = await session.get_panel(mac)
await session.close()
CrowClient
The CrowClient class provides full access to all API features.
client = CrowClient(
email="...",
password="...",
api_base="https://api.crowcloud.com", # optional
timeout=30, # optional
retry_count=3, # optional
)
Models
Panel
panel.mac # MAC address
panel.name # Panel name
panel.model # Panel model
panel.firmware_version # Firmware version
Area
area.id # Area ID
area.name # Area name
area.state # AreaState enum
area.is_armed # True if armed
area.is_arming # True if arming in progress
Zone
zone.id # Zone ID
zone.name # Zone name
zone.state # Zone state string
zone.zone_type # Zone type
zone.is_open # True if triggered/open
zone.battery # Battery level (0-100)
zone.has_low_battery # True if battery < 20%
Output
output.id # Output ID
output.name # Output name
output.state # True if on
output.output_type # Output type
Measurement
measurement.id # Measurement ID
measurement.name # Measurement name
measurement.value # Current value
measurement.unit # Unit (°C, %, etc.)
measurement.measurement_type # Type (temperature, humidity, etc.)
Exceptions
from crow_security_ng import (
CrowError, # Base exception
AuthenticationError, # Invalid credentials
ConnectionError, # Connection failed
ResponseError, # API error response
PanelNotFoundError, # Panel not found
RateLimitError, # Rate limit exceeded
TimeoutError, # Request timeout
)
Migrating from crow_security
This library is designed to be a drop-in replacement for crow_security. Simply change your import:
# Before
import crow_security as crow
session = crow.Session(email, password)
# After
from crow_security_ng import Session
session = Session(email, password)
Key improvements over crow_security
- Better exception handling - Specific exception classes instead of generic
ResponseError - MAC address normalization - No need to manually format MAC addresses
- Type hints - Full type annotations for better IDE support
- Dataclass models - Structured data models instead of raw dictionaries
- Resource cleanup - Proper async context manager support
- Retry logic - Automatic retries with configurable backoff
- Modern Python - Uses Python 3.10+ features
Home Assistant Integration
This library is designed to work with the Crow Shepherd Home Assistant integration. See the integration documentation for setup instructions.
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Credits
- Inspired by the original crow_security library by Shprota
- Thanks to the Crow Group for the Shepherd alarm system
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crow_security_ng-0.1.7.tar.gz.
File metadata
- Download URL: crow_security_ng-0.1.7.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
825b098ddc00192e046a38fba8c4d108ed69dfcc302e97cadaa7771dde4cff3c
|
|
| MD5 |
f0146062daed61860d8e806a3e2ff37b
|
|
| BLAKE2b-256 |
3dcae4463ea6480d87d168d105712a7593f5239c4e6cbb63389ea5ab8a5c36f4
|
File details
Details for the file crow_security_ng-0.1.7-py3-none-any.whl.
File metadata
- Download URL: crow_security_ng-0.1.7-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32e7a974faab6e1a4945a7a985a461d535e713fb333f35519c6c09f7a979b887
|
|
| MD5 |
7647d366a8f8c3e3ed103d76a86ca8fc
|
|
| BLAKE2b-256 |
b2f2f0d79f01c5f4da76c634eba86a7069ae77809fd449c309d1eb777ef8dd52
|