crow-security-ng 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crow_security_ng-0.1.0/LICENSE +21 -0
- crow_security_ng-0.1.0/PKG-INFO +290 -0
- crow_security_ng-0.1.0/README.md +254 -0
- crow_security_ng-0.1.0/crow_security_ng/__init__.py +42 -0
- crow_security_ng-0.1.0/crow_security_ng/client.py +571 -0
- crow_security_ng-0.1.0/crow_security_ng/exceptions.py +88 -0
- crow_security_ng-0.1.0/crow_security_ng/models.py +313 -0
- crow_security_ng-0.1.0/crow_security_ng/py.typed +0 -0
- crow_security_ng-0.1.0/crow_security_ng/session.py +145 -0
- crow_security_ng-0.1.0/crow_security_ng/utils.py +66 -0
- crow_security_ng-0.1.0/crow_security_ng.egg-info/PKG-INFO +290 -0
- crow_security_ng-0.1.0/crow_security_ng.egg-info/SOURCES.txt +18 -0
- crow_security_ng-0.1.0/crow_security_ng.egg-info/dependency_links.txt +1 -0
- crow_security_ng-0.1.0/crow_security_ng.egg-info/requires.txt +9 -0
- crow_security_ng-0.1.0/crow_security_ng.egg-info/top_level.txt +1 -0
- crow_security_ng-0.1.0/pyproject.toml +94 -0
- crow_security_ng-0.1.0/setup.cfg +4 -0
- crow_security_ng-0.1.0/tests/test_exceptions.py +105 -0
- crow_security_ng-0.1.0/tests/test_models.py +198 -0
- crow_security_ng-0.1.0/tests/test_utils.py +87 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Crow Security NG Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crow_security_ng
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A modern Python library for the Crow Cloud API - Next Generation
|
|
5
|
+
Author: Crow Security NG Contributors
|
|
6
|
+
Maintainer: Crow Security NG Contributors
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/crow-security-ng/crow-security-ng
|
|
9
|
+
Project-URL: Bug Reports, https://github.com/crow-security-ng/crow-security-ng/issues
|
|
10
|
+
Project-URL: Source, https://github.com/crow-security-ng/crow-security-ng
|
|
11
|
+
Keywords: crow,security,alarm,home-assistant,iot,smart-home,shepherd
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Home Automation
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: aioresponses>=0.7.4; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Crow Security NG
|
|
38
|
+
|
|
39
|
+
A modern, async Python library for the Crow Cloud API - Next Generation.
|
|
40
|
+
|
|
41
|
+
This library provides a clean, type-hinted interface for interacting with Crow Security alarm systems (Shepherd panels) through the Crow Cloud API.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **Fully async** - Built on `aiohttp` for efficient async I/O
|
|
46
|
+
- **Type hints** - Complete type annotations for better IDE support
|
|
47
|
+
- **Modern Python** - Requires Python 3.10+, uses dataclasses and enums
|
|
48
|
+
- **Proper error handling** - Dedicated exception classes for different error types
|
|
49
|
+
- **MAC address normalization** - Accepts any MAC format (with/without separators)
|
|
50
|
+
- **WebSocket support** - Real-time updates from your alarm panel
|
|
51
|
+
- **Backwards compatible** - Provides `Session` class compatible with original `crow_security`
|
|
52
|
+
- **Retry logic** - Automatic retries with exponential backoff
|
|
53
|
+
- **Context managers** - Proper resource cleanup with async context managers
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install crow_security_ng
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
### Basic Usage
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
from crow_security_ng import Session
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
# Create a session
|
|
71
|
+
session = Session("your-email@example.com", "your-password")
|
|
72
|
+
|
|
73
|
+
# Get your panel (MAC address can be in any format)
|
|
74
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
75
|
+
# or: await session.get_panel("AA:BB:CC:DD:EE:FF")
|
|
76
|
+
# or: await session.get_panel("aa-bb-cc-dd-ee-ff")
|
|
77
|
+
|
|
78
|
+
print(f"Panel: {panel.name}")
|
|
79
|
+
|
|
80
|
+
# Get alarm areas
|
|
81
|
+
areas = await panel.get_areas()
|
|
82
|
+
for area in areas:
|
|
83
|
+
print(f"Area: {area.name}, State: {area.state}")
|
|
84
|
+
|
|
85
|
+
# Arm the alarm
|
|
86
|
+
await panel.set_area_state(areas[0].id, "arm")
|
|
87
|
+
|
|
88
|
+
# Get zones
|
|
89
|
+
zones = await panel.get_zones()
|
|
90
|
+
for zone in zones:
|
|
91
|
+
print(f"Zone: {zone.name}, Open: {zone.is_open}")
|
|
92
|
+
|
|
93
|
+
# Clean up
|
|
94
|
+
await session.close()
|
|
95
|
+
|
|
96
|
+
asyncio.run(main())
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Using Context Manager
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import asyncio
|
|
103
|
+
from crow_security_ng import Session
|
|
104
|
+
|
|
105
|
+
async def main():
|
|
106
|
+
async with Session("email@example.com", "password") as session:
|
|
107
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
108
|
+
areas = await panel.get_areas()
|
|
109
|
+
print(areas)
|
|
110
|
+
|
|
111
|
+
asyncio.run(main())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Advanced Client Usage
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
import asyncio
|
|
118
|
+
from crow_security_ng import CrowClient
|
|
119
|
+
|
|
120
|
+
async def main():
|
|
121
|
+
async with CrowClient(
|
|
122
|
+
email="email@example.com",
|
|
123
|
+
password="password",
|
|
124
|
+
timeout=60,
|
|
125
|
+
retry_count=5,
|
|
126
|
+
) as client:
|
|
127
|
+
# Get all panels
|
|
128
|
+
panels = await client.get_panels()
|
|
129
|
+
|
|
130
|
+
# Work with a specific panel
|
|
131
|
+
panel = await client.get_panel("AABBCCDDEEFF")
|
|
132
|
+
|
|
133
|
+
# Control outputs
|
|
134
|
+
outputs = await client.get_outputs(panel.mac)
|
|
135
|
+
await client.set_output_state(panel.mac, outputs[0].id, True)
|
|
136
|
+
|
|
137
|
+
# Get measurements (temperature, humidity, etc.)
|
|
138
|
+
measurements = await client.get_measurements(panel.mac)
|
|
139
|
+
for m in measurements:
|
|
140
|
+
print(f"{m.name}: {m.value} {m.unit}")
|
|
141
|
+
|
|
142
|
+
asyncio.run(main())
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### WebSocket Real-time Updates
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
import asyncio
|
|
149
|
+
from crow_security_ng import Session
|
|
150
|
+
|
|
151
|
+
async def handle_message(msg: dict):
|
|
152
|
+
print(f"Received: {msg}")
|
|
153
|
+
|
|
154
|
+
async def main():
|
|
155
|
+
session = Session("email@example.com", "password")
|
|
156
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
157
|
+
|
|
158
|
+
# This will run indefinitely, receiving real-time updates
|
|
159
|
+
await session.ws_connect(panel.mac, handle_message)
|
|
160
|
+
|
|
161
|
+
asyncio.run(main())
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## API Reference
|
|
165
|
+
|
|
166
|
+
### Session
|
|
167
|
+
|
|
168
|
+
The `Session` class provides a simple interface compatible with the original `crow_security` library.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
session = Session(email, password)
|
|
172
|
+
panel = await session.get_panel(mac)
|
|
173
|
+
await session.close()
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### CrowClient
|
|
177
|
+
|
|
178
|
+
The `CrowClient` class provides full access to all API features.
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
client = CrowClient(
|
|
182
|
+
email="...",
|
|
183
|
+
password="...",
|
|
184
|
+
api_base="https://api.crowcloud.com", # optional
|
|
185
|
+
timeout=30, # optional
|
|
186
|
+
retry_count=3, # optional
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Models
|
|
191
|
+
|
|
192
|
+
#### Panel
|
|
193
|
+
```python
|
|
194
|
+
panel.mac # MAC address
|
|
195
|
+
panel.name # Panel name
|
|
196
|
+
panel.model # Panel model
|
|
197
|
+
panel.firmware_version # Firmware version
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Area
|
|
201
|
+
```python
|
|
202
|
+
area.id # Area ID
|
|
203
|
+
area.name # Area name
|
|
204
|
+
area.state # AreaState enum
|
|
205
|
+
area.is_armed # True if armed
|
|
206
|
+
area.is_arming # True if arming in progress
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Zone
|
|
210
|
+
```python
|
|
211
|
+
zone.id # Zone ID
|
|
212
|
+
zone.name # Zone name
|
|
213
|
+
zone.state # Zone state string
|
|
214
|
+
zone.zone_type # Zone type
|
|
215
|
+
zone.is_open # True if triggered/open
|
|
216
|
+
zone.battery # Battery level (0-100)
|
|
217
|
+
zone.has_low_battery # True if battery < 20%
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Output
|
|
221
|
+
```python
|
|
222
|
+
output.id # Output ID
|
|
223
|
+
output.name # Output name
|
|
224
|
+
output.state # True if on
|
|
225
|
+
output.output_type # Output type
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Measurement
|
|
229
|
+
```python
|
|
230
|
+
measurement.id # Measurement ID
|
|
231
|
+
measurement.name # Measurement name
|
|
232
|
+
measurement.value # Current value
|
|
233
|
+
measurement.unit # Unit (°C, %, etc.)
|
|
234
|
+
measurement.measurement_type # Type (temperature, humidity, etc.)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Exceptions
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
from crow_security_ng import (
|
|
241
|
+
CrowError, # Base exception
|
|
242
|
+
AuthenticationError, # Invalid credentials
|
|
243
|
+
ConnectionError, # Connection failed
|
|
244
|
+
ResponseError, # API error response
|
|
245
|
+
PanelNotFoundError, # Panel not found
|
|
246
|
+
RateLimitError, # Rate limit exceeded
|
|
247
|
+
TimeoutError, # Request timeout
|
|
248
|
+
)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Migrating from crow_security
|
|
252
|
+
|
|
253
|
+
This library is designed to be a drop-in replacement for `crow_security`. Simply change your import:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
# Before
|
|
257
|
+
import crow_security as crow
|
|
258
|
+
session = crow.Session(email, password)
|
|
259
|
+
|
|
260
|
+
# After
|
|
261
|
+
from crow_security_ng import Session
|
|
262
|
+
session = Session(email, password)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Key improvements over crow_security
|
|
266
|
+
|
|
267
|
+
1. **Better exception handling** - Specific exception classes instead of generic `ResponseError`
|
|
268
|
+
2. **MAC address normalization** - No need to manually format MAC addresses
|
|
269
|
+
3. **Type hints** - Full type annotations for better IDE support
|
|
270
|
+
4. **Dataclass models** - Structured data models instead of raw dictionaries
|
|
271
|
+
5. **Resource cleanup** - Proper async context manager support
|
|
272
|
+
6. **Retry logic** - Automatic retries with configurable backoff
|
|
273
|
+
7. **Modern Python** - Uses Python 3.10+ features
|
|
274
|
+
|
|
275
|
+
## Home Assistant Integration
|
|
276
|
+
|
|
277
|
+
This library is designed to work with the Crow Shepherd Home Assistant integration. See the integration documentation for setup instructions.
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
286
|
+
|
|
287
|
+
## Credits
|
|
288
|
+
|
|
289
|
+
- Inspired by the original [crow_security](https://pypi.org/project/crow-security/) library by Shprota
|
|
290
|
+
- Thanks to the Crow Group for the Shepherd alarm system
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Crow Security NG
|
|
2
|
+
|
|
3
|
+
A modern, async Python library for the Crow Cloud API - Next Generation.
|
|
4
|
+
|
|
5
|
+
This library provides a clean, type-hinted interface for interacting with Crow Security alarm systems (Shepherd panels) through the Crow Cloud API.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Fully async** - Built on `aiohttp` for efficient async I/O
|
|
10
|
+
- **Type hints** - Complete type annotations for better IDE support
|
|
11
|
+
- **Modern Python** - Requires Python 3.10+, uses dataclasses and enums
|
|
12
|
+
- **Proper error handling** - Dedicated exception classes for different error types
|
|
13
|
+
- **MAC address normalization** - Accepts any MAC format (with/without separators)
|
|
14
|
+
- **WebSocket support** - Real-time updates from your alarm panel
|
|
15
|
+
- **Backwards compatible** - Provides `Session` class compatible with original `crow_security`
|
|
16
|
+
- **Retry logic** - Automatic retries with exponential backoff
|
|
17
|
+
- **Context managers** - Proper resource cleanup with async context managers
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install crow_security_ng
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Basic Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import asyncio
|
|
31
|
+
from crow_security_ng import Session
|
|
32
|
+
|
|
33
|
+
async def main():
|
|
34
|
+
# Create a session
|
|
35
|
+
session = Session("your-email@example.com", "your-password")
|
|
36
|
+
|
|
37
|
+
# Get your panel (MAC address can be in any format)
|
|
38
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
39
|
+
# or: await session.get_panel("AA:BB:CC:DD:EE:FF")
|
|
40
|
+
# or: await session.get_panel("aa-bb-cc-dd-ee-ff")
|
|
41
|
+
|
|
42
|
+
print(f"Panel: {panel.name}")
|
|
43
|
+
|
|
44
|
+
# Get alarm areas
|
|
45
|
+
areas = await panel.get_areas()
|
|
46
|
+
for area in areas:
|
|
47
|
+
print(f"Area: {area.name}, State: {area.state}")
|
|
48
|
+
|
|
49
|
+
# Arm the alarm
|
|
50
|
+
await panel.set_area_state(areas[0].id, "arm")
|
|
51
|
+
|
|
52
|
+
# Get zones
|
|
53
|
+
zones = await panel.get_zones()
|
|
54
|
+
for zone in zones:
|
|
55
|
+
print(f"Zone: {zone.name}, Open: {zone.is_open}")
|
|
56
|
+
|
|
57
|
+
# Clean up
|
|
58
|
+
await session.close()
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Using Context Manager
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
from crow_security_ng import Session
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
async with Session("email@example.com", "password") as session:
|
|
71
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
72
|
+
areas = await panel.get_areas()
|
|
73
|
+
print(areas)
|
|
74
|
+
|
|
75
|
+
asyncio.run(main())
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Advanced Client Usage
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import asyncio
|
|
82
|
+
from crow_security_ng import CrowClient
|
|
83
|
+
|
|
84
|
+
async def main():
|
|
85
|
+
async with CrowClient(
|
|
86
|
+
email="email@example.com",
|
|
87
|
+
password="password",
|
|
88
|
+
timeout=60,
|
|
89
|
+
retry_count=5,
|
|
90
|
+
) as client:
|
|
91
|
+
# Get all panels
|
|
92
|
+
panels = await client.get_panels()
|
|
93
|
+
|
|
94
|
+
# Work with a specific panel
|
|
95
|
+
panel = await client.get_panel("AABBCCDDEEFF")
|
|
96
|
+
|
|
97
|
+
# Control outputs
|
|
98
|
+
outputs = await client.get_outputs(panel.mac)
|
|
99
|
+
await client.set_output_state(panel.mac, outputs[0].id, True)
|
|
100
|
+
|
|
101
|
+
# Get measurements (temperature, humidity, etc.)
|
|
102
|
+
measurements = await client.get_measurements(panel.mac)
|
|
103
|
+
for m in measurements:
|
|
104
|
+
print(f"{m.name}: {m.value} {m.unit}")
|
|
105
|
+
|
|
106
|
+
asyncio.run(main())
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### WebSocket Real-time Updates
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import asyncio
|
|
113
|
+
from crow_security_ng import Session
|
|
114
|
+
|
|
115
|
+
async def handle_message(msg: dict):
|
|
116
|
+
print(f"Received: {msg}")
|
|
117
|
+
|
|
118
|
+
async def main():
|
|
119
|
+
session = Session("email@example.com", "password")
|
|
120
|
+
panel = await session.get_panel("AABBCCDDEEFF")
|
|
121
|
+
|
|
122
|
+
# This will run indefinitely, receiving real-time updates
|
|
123
|
+
await session.ws_connect(panel.mac, handle_message)
|
|
124
|
+
|
|
125
|
+
asyncio.run(main())
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## API Reference
|
|
129
|
+
|
|
130
|
+
### Session
|
|
131
|
+
|
|
132
|
+
The `Session` class provides a simple interface compatible with the original `crow_security` library.
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
session = Session(email, password)
|
|
136
|
+
panel = await session.get_panel(mac)
|
|
137
|
+
await session.close()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### CrowClient
|
|
141
|
+
|
|
142
|
+
The `CrowClient` class provides full access to all API features.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
client = CrowClient(
|
|
146
|
+
email="...",
|
|
147
|
+
password="...",
|
|
148
|
+
api_base="https://api.crowcloud.com", # optional
|
|
149
|
+
timeout=30, # optional
|
|
150
|
+
retry_count=3, # optional
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Models
|
|
155
|
+
|
|
156
|
+
#### Panel
|
|
157
|
+
```python
|
|
158
|
+
panel.mac # MAC address
|
|
159
|
+
panel.name # Panel name
|
|
160
|
+
panel.model # Panel model
|
|
161
|
+
panel.firmware_version # Firmware version
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Area
|
|
165
|
+
```python
|
|
166
|
+
area.id # Area ID
|
|
167
|
+
area.name # Area name
|
|
168
|
+
area.state # AreaState enum
|
|
169
|
+
area.is_armed # True if armed
|
|
170
|
+
area.is_arming # True if arming in progress
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Zone
|
|
174
|
+
```python
|
|
175
|
+
zone.id # Zone ID
|
|
176
|
+
zone.name # Zone name
|
|
177
|
+
zone.state # Zone state string
|
|
178
|
+
zone.zone_type # Zone type
|
|
179
|
+
zone.is_open # True if triggered/open
|
|
180
|
+
zone.battery # Battery level (0-100)
|
|
181
|
+
zone.has_low_battery # True if battery < 20%
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Output
|
|
185
|
+
```python
|
|
186
|
+
output.id # Output ID
|
|
187
|
+
output.name # Output name
|
|
188
|
+
output.state # True if on
|
|
189
|
+
output.output_type # Output type
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Measurement
|
|
193
|
+
```python
|
|
194
|
+
measurement.id # Measurement ID
|
|
195
|
+
measurement.name # Measurement name
|
|
196
|
+
measurement.value # Current value
|
|
197
|
+
measurement.unit # Unit (°C, %, etc.)
|
|
198
|
+
measurement.measurement_type # Type (temperature, humidity, etc.)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Exceptions
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from crow_security_ng import (
|
|
205
|
+
CrowError, # Base exception
|
|
206
|
+
AuthenticationError, # Invalid credentials
|
|
207
|
+
ConnectionError, # Connection failed
|
|
208
|
+
ResponseError, # API error response
|
|
209
|
+
PanelNotFoundError, # Panel not found
|
|
210
|
+
RateLimitError, # Rate limit exceeded
|
|
211
|
+
TimeoutError, # Request timeout
|
|
212
|
+
)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Migrating from crow_security
|
|
216
|
+
|
|
217
|
+
This library is designed to be a drop-in replacement for `crow_security`. Simply change your import:
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
# Before
|
|
221
|
+
import crow_security as crow
|
|
222
|
+
session = crow.Session(email, password)
|
|
223
|
+
|
|
224
|
+
# After
|
|
225
|
+
from crow_security_ng import Session
|
|
226
|
+
session = Session(email, password)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Key improvements over crow_security
|
|
230
|
+
|
|
231
|
+
1. **Better exception handling** - Specific exception classes instead of generic `ResponseError`
|
|
232
|
+
2. **MAC address normalization** - No need to manually format MAC addresses
|
|
233
|
+
3. **Type hints** - Full type annotations for better IDE support
|
|
234
|
+
4. **Dataclass models** - Structured data models instead of raw dictionaries
|
|
235
|
+
5. **Resource cleanup** - Proper async context manager support
|
|
236
|
+
6. **Retry logic** - Automatic retries with configurable backoff
|
|
237
|
+
7. **Modern Python** - Uses Python 3.10+ features
|
|
238
|
+
|
|
239
|
+
## Home Assistant Integration
|
|
240
|
+
|
|
241
|
+
This library is designed to work with the Crow Shepherd Home Assistant integration. See the integration documentation for setup instructions.
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
246
|
+
|
|
247
|
+
## Contributing
|
|
248
|
+
|
|
249
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
250
|
+
|
|
251
|
+
## Credits
|
|
252
|
+
|
|
253
|
+
- Inspired by the original [crow_security](https://pypi.org/project/crow-security/) library by Shprota
|
|
254
|
+
- Thanks to the Crow Group for the Shepherd alarm system
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Crow Security NG - A modern Python library for the Crow Cloud API.
|
|
3
|
+
|
|
4
|
+
This library provides async access to Crow Cloud security systems,
|
|
5
|
+
including the Shepherd alarm panel series.
|
|
6
|
+
"""
|
|
7
|
+
from .client import CrowClient
|
|
8
|
+
from .models import Panel, Area, Zone, Output, Measurement
|
|
9
|
+
from .exceptions import (
|
|
10
|
+
CrowError,
|
|
11
|
+
AuthenticationError,
|
|
12
|
+
ConnectionError,
|
|
13
|
+
ResponseError,
|
|
14
|
+
PanelNotFoundError,
|
|
15
|
+
RateLimitError,
|
|
16
|
+
TimeoutError,
|
|
17
|
+
)
|
|
18
|
+
from .session import Session
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
__author__ = "Crow Security NG Contributors"
|
|
22
|
+
__license__ = "MIT"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
# Main classes
|
|
26
|
+
"CrowClient",
|
|
27
|
+
"Session",
|
|
28
|
+
"Panel",
|
|
29
|
+
# Models
|
|
30
|
+
"Area",
|
|
31
|
+
"Zone",
|
|
32
|
+
"Output",
|
|
33
|
+
"Measurement",
|
|
34
|
+
# Exceptions
|
|
35
|
+
"CrowError",
|
|
36
|
+
"AuthenticationError",
|
|
37
|
+
"ConnectionError",
|
|
38
|
+
"ResponseError",
|
|
39
|
+
"PanelNotFoundError",
|
|
40
|
+
"RateLimitError",
|
|
41
|
+
"TimeoutError",
|
|
42
|
+
]
|