open-ialarm-mk-local-api 1.0.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.
- open_ialarm_mk_local_api-1.0.0/LICENSE +21 -0
- open_ialarm_mk_local_api-1.0.0/PKG-INFO +271 -0
- open_ialarm_mk_local_api-1.0.0/README.md +226 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/__init__.py +24 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/_internal/__init__.py +0 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/_internal/meian_client.py +571 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/_internal/meian_push_client.py +172 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/enums/__init__.py +4 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/enums/alarm_status_enum.py +12 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/enums/zone_status_enum.py +11 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/exceptions/__init__.py +5 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/exceptions/alarm_error.py +2 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/exceptions/connection_error.py +2 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/exceptions/login_error.py +2 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/ialarmmk_client.py +214 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/ialarmmk_push_client.py +73 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/models/__init__.py +5 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/models/alarm_status_model.py +8 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/models/network_info_model.py +16 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api/models/zone_model.py +27 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api.egg-info/PKG-INFO +271 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api.egg-info/SOURCES.txt +28 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api.egg-info/dependency_links.txt +1 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api.egg-info/requires.txt +5 -0
- open_ialarm_mk_local_api-1.0.0/open_ialarm_mk_local_api.egg-info/top_level.txt +1 -0
- open_ialarm_mk_local_api-1.0.0/pyproject.toml +38 -0
- open_ialarm_mk_local_api-1.0.0/setup.cfg +4 -0
- open_ialarm_mk_local_api-1.0.0/tests/test_client.py +334 -0
- open_ialarm_mk_local_api-1.0.0/tests/test_internal.py +375 -0
- open_ialarm_mk_local_api-1.0.0/tests/test_models.py +111 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Luca
|
|
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,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-ialarm-mk-local-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Async Python library to interface with iAlarm-MK alarm panels locally
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2026 Luca
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Project-URL: Homepage, https://github.com/VoidElle/open-ialarm-mk-local-api
|
|
28
|
+
Project-URL: Source, https://github.com/VoidElle/open-ialarm-mk-local-api
|
|
29
|
+
Project-URL: Bug Tracker, https://github.com/VoidElle/open-ialarm-mk-local-api/issues
|
|
30
|
+
Keywords: ialarm,alarm,security,iot,asyncio,home-assistant
|
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Framework :: AsyncIO
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Requires-Dist: lxml>=5.0
|
|
41
|
+
Requires-Dist: xmltodict>=0.13
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# 🚨 Open iAlarm-MK Local API
|
|
47
|
+
|
|
48
|
+
> *Asynchronous Python library for iAlarm-MK alarm panels via the local Meian protocol*
|
|
49
|
+
|
|
50
|
+
[](https://www.python.org/downloads/)
|
|
51
|
+
[](LICENSE)
|
|
52
|
+
[](https://github.com/VoidElle/open-ialarm-mk-local-api/releases)
|
|
53
|
+
[](https://github.com/VoidElle/open-ialarm-mk-local-api/actions/workflows/tests.yml)
|
|
54
|
+
|
|
55
|
+
**[Features](#features) • [Installation](#installation) • [Quick Start](#quick-start) • [Documentation](#documentation) • [Examples](#examples) • [Testing](#testing)**
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Features
|
|
60
|
+
|
|
61
|
+
### Performance
|
|
62
|
+
- Built with **asyncio** for non-blocking operations
|
|
63
|
+
- Efficient TCP communication over the Meian binary protocol
|
|
64
|
+
- TCP keep-alive to prevent idle connection drops
|
|
65
|
+
|
|
66
|
+
### Reliability
|
|
67
|
+
- Framed two-phase read: large MK7 responses (>1024 bytes) always received in full
|
|
68
|
+
- Graceful error propagation with full detail preserved
|
|
69
|
+
- Auto-close socket on connection failure
|
|
70
|
+
- Auto-reconnect: each command retries once on connection drop
|
|
71
|
+
- Concurrent-safe: internal `asyncio.Lock` serializes all commands (Home Assistant coordinator safe)
|
|
72
|
+
- Application-level keepalive: polls status every 30 s to prevent panel idle timeouts
|
|
73
|
+
|
|
74
|
+
### Developer Friendly
|
|
75
|
+
- Type-safe dataclasses: `AlarmStatusModel`, `ZoneModel`, `NetworkInfoModel`
|
|
76
|
+
- Async context manager support
|
|
77
|
+
- Comprehensive logging at every step
|
|
78
|
+
|
|
79
|
+
### Full Control
|
|
80
|
+
- Arm Away, Arm Stay, Arm Partial, Disarm, Cancel Alarm
|
|
81
|
+
- Read all zones with status (open, bypassed, low battery, signal loss)
|
|
82
|
+
- Read network info (name, MAC, IP)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/VoidElle/open-ialarm-mk-local-api
|
|
90
|
+
cd open-ialarm-mk-local-api
|
|
91
|
+
pip install -e .
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import asyncio
|
|
100
|
+
from open_ialarm_mk_local_api import IAlarmMkClient
|
|
101
|
+
|
|
102
|
+
async def main():
|
|
103
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "secret") as client:
|
|
104
|
+
status = await client.get_status()
|
|
105
|
+
print(f"Status: {status.status.name}")
|
|
106
|
+
|
|
107
|
+
zones = await client.get_zones()
|
|
108
|
+
for zone in zones:
|
|
109
|
+
print(f" [{zone.index:3d}] {zone.name} - {'OPEN' if zone.is_open else 'ok'}")
|
|
110
|
+
|
|
111
|
+
asyncio.run(main())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Panel Port
|
|
117
|
+
|
|
118
|
+
| Model | Default TCP port |
|
|
119
|
+
|-------|:----------------:|
|
|
120
|
+
| iAlarm **MK7** | **8000** |
|
|
121
|
+
| iAlarm **MK2** | **18034** |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Documentation
|
|
126
|
+
|
|
127
|
+
- [Configuration](#configuration)
|
|
128
|
+
- [Connection Management](#connection-management)
|
|
129
|
+
- [Alarm Control](#alarm-control)
|
|
130
|
+
- [Data Models](#data-models)
|
|
131
|
+
- [Error Handling](#error-handling)
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
### Constructor Parameters: `IAlarmMkClient`
|
|
138
|
+
|
|
139
|
+
| Parameter | Type | Default | Description |
|
|
140
|
+
|-----------|:----:|:-------:|-------------|
|
|
141
|
+
| **`host`** | `str` | *required* | IP address of the panel |
|
|
142
|
+
| **`port`** | `int` | *required* | TCP port (8000 for MK7, 18034 for MK2) |
|
|
143
|
+
| **`username`** | `str` | *required* | Login username |
|
|
144
|
+
| **`password`** | `str` | *required* | Login password |
|
|
145
|
+
| `timeout` | `float` | `10.0` | Socket timeout in seconds |
|
|
146
|
+
| `keepalive_interval` | `int \| None` | `30` | Seconds between keepalive polls; `None` to disable |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Connection Management
|
|
151
|
+
|
|
152
|
+
### Connect / Disconnect
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
await client.connect()
|
|
156
|
+
await client.disconnect()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Context Manager (recommended)
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "pass") as client:
|
|
163
|
+
status = await client.get_status()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Alarm Control
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
await client.arm_away() # Arm all zones
|
|
172
|
+
await client.arm_stay() # Perimeter zones only
|
|
173
|
+
await client.arm_partial() # Partial arm
|
|
174
|
+
await client.disarm() # Disarm
|
|
175
|
+
await client.cancel_alarm() # Cancel active alarm
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Data Models
|
|
181
|
+
|
|
182
|
+
### `AlarmStatusModel`
|
|
183
|
+
|
|
184
|
+
| Field | Type | Description |
|
|
185
|
+
|-------|------|-------------|
|
|
186
|
+
| `status` | `AlarmStatusEnum` | Current panel status |
|
|
187
|
+
|
|
188
|
+
### `AlarmStatusEnum`
|
|
189
|
+
|
|
190
|
+
| Value | Name | Description |
|
|
191
|
+
|:-----:|------|-------------|
|
|
192
|
+
| `0` | `ARMED_AWAY` | Armed, all zones |
|
|
193
|
+
| `1` | `DISARMED` | Disarmed |
|
|
194
|
+
| `2` | `ARMED_STAY` | Armed, stay mode |
|
|
195
|
+
| `3` | `CANCEL` | Alarm cancelled |
|
|
196
|
+
| `4` | `TRIGGERED` | Alarm triggered |
|
|
197
|
+
| `5` | `ALARM_ARMING` | Arming in progress |
|
|
198
|
+
| `6` | `UNAVAILABLE` | Status unknown |
|
|
199
|
+
| `8` | `ARMED_PARTIAL` | Armed, partial |
|
|
200
|
+
|
|
201
|
+
### `ZoneModel`
|
|
202
|
+
|
|
203
|
+
| Field / Property | Type | Description |
|
|
204
|
+
|------------------|------|-------------|
|
|
205
|
+
| `index` | `int` | Zone index |
|
|
206
|
+
| `name` | `str` | Zone name |
|
|
207
|
+
| `zone_type` | `int` | Zone type code |
|
|
208
|
+
| `status` | `ZoneStatusEnum` | Raw status bitmask |
|
|
209
|
+
| `is_open` | `bool` | Zone is faulted / open |
|
|
210
|
+
| `is_bypassed` | `bool` | Zone is bypassed |
|
|
211
|
+
| `low_battery` | `bool` | Low battery detected |
|
|
212
|
+
| `signal_loss` | `bool` | Wireless signal lost |
|
|
213
|
+
|
|
214
|
+
### `NetworkInfoModel`
|
|
215
|
+
|
|
216
|
+
| Field | Type | Description |
|
|
217
|
+
|-------|------|-------------|
|
|
218
|
+
| `name` | `str` | Panel device name |
|
|
219
|
+
| `mac` | `str` | MAC address |
|
|
220
|
+
| `ip` | `str` | IP address |
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Error Handling
|
|
225
|
+
|
|
226
|
+
| Exception | When raised |
|
|
227
|
+
|-----------|-------------|
|
|
228
|
+
| `IAlarmMkConnectionError` | TCP failure, timeout, or unexpected error during login |
|
|
229
|
+
| `IAlarmMkLoginError` | Panel rejected credentials |
|
|
230
|
+
| `IAlarmMkAlarmError` | Panel returned a non-zero error code for a command |
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from open_ialarm_mk_local_api import IAlarmMkConnectionError, IAlarmMkLoginError
|
|
234
|
+
|
|
235
|
+
try:
|
|
236
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "pass") as client:
|
|
237
|
+
await client.arm_away()
|
|
238
|
+
except IAlarmMkLoginError:
|
|
239
|
+
print("Wrong credentials")
|
|
240
|
+
except IAlarmMkConnectionError as e:
|
|
241
|
+
print(f"Connection failed: {e}")
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Examples
|
|
247
|
+
|
|
248
|
+
Run any example directly from the repo root (no install needed):
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
python3 examples/get_status.py --host 192.168.1.100 --user admin --password password
|
|
252
|
+
python3 examples/arm_away.py --host 192.168.1.100 --user admin --password password arm-partial
|
|
253
|
+
python3 examples/subscribe_events.py --host 192.168.1.100 --user admin
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Integration test against a real panel
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
python3 examples/integration_test.py --host 192.168.1.100 --user admin --password password
|
|
260
|
+
# skip arm/disarm on a live production panel:
|
|
261
|
+
python3 examples/integration_test.py --host 192.168.1.100 --user admin --password password --skip-arm
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Testing
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
python -m pytest tests/
|
|
270
|
+
```
|
|
271
|
+
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# 🚨 Open iAlarm-MK Local API
|
|
2
|
+
|
|
3
|
+
> *Asynchronous Python library for iAlarm-MK alarm panels via the local Meian protocol*
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/VoidElle/open-ialarm-mk-local-api/releases)
|
|
8
|
+
[](https://github.com/VoidElle/open-ialarm-mk-local-api/actions/workflows/tests.yml)
|
|
9
|
+
|
|
10
|
+
**[Features](#features) • [Installation](#installation) • [Quick Start](#quick-start) • [Documentation](#documentation) • [Examples](#examples) • [Testing](#testing)**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
### Performance
|
|
17
|
+
- Built with **asyncio** for non-blocking operations
|
|
18
|
+
- Efficient TCP communication over the Meian binary protocol
|
|
19
|
+
- TCP keep-alive to prevent idle connection drops
|
|
20
|
+
|
|
21
|
+
### Reliability
|
|
22
|
+
- Framed two-phase read: large MK7 responses (>1024 bytes) always received in full
|
|
23
|
+
- Graceful error propagation with full detail preserved
|
|
24
|
+
- Auto-close socket on connection failure
|
|
25
|
+
- Auto-reconnect: each command retries once on connection drop
|
|
26
|
+
- Concurrent-safe: internal `asyncio.Lock` serializes all commands (Home Assistant coordinator safe)
|
|
27
|
+
- Application-level keepalive: polls status every 30 s to prevent panel idle timeouts
|
|
28
|
+
|
|
29
|
+
### Developer Friendly
|
|
30
|
+
- Type-safe dataclasses: `AlarmStatusModel`, `ZoneModel`, `NetworkInfoModel`
|
|
31
|
+
- Async context manager support
|
|
32
|
+
- Comprehensive logging at every step
|
|
33
|
+
|
|
34
|
+
### Full Control
|
|
35
|
+
- Arm Away, Arm Stay, Arm Partial, Disarm, Cancel Alarm
|
|
36
|
+
- Read all zones with status (open, bypassed, low battery, signal loss)
|
|
37
|
+
- Read network info (name, MAC, IP)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/VoidElle/open-ialarm-mk-local-api
|
|
45
|
+
cd open-ialarm-mk-local-api
|
|
46
|
+
pip install -e .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import asyncio
|
|
55
|
+
from open_ialarm_mk_local_api import IAlarmMkClient
|
|
56
|
+
|
|
57
|
+
async def main():
|
|
58
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "secret") as client:
|
|
59
|
+
status = await client.get_status()
|
|
60
|
+
print(f"Status: {status.status.name}")
|
|
61
|
+
|
|
62
|
+
zones = await client.get_zones()
|
|
63
|
+
for zone in zones:
|
|
64
|
+
print(f" [{zone.index:3d}] {zone.name} - {'OPEN' if zone.is_open else 'ok'}")
|
|
65
|
+
|
|
66
|
+
asyncio.run(main())
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Panel Port
|
|
72
|
+
|
|
73
|
+
| Model | Default TCP port |
|
|
74
|
+
|-------|:----------------:|
|
|
75
|
+
| iAlarm **MK7** | **8000** |
|
|
76
|
+
| iAlarm **MK2** | **18034** |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
- [Configuration](#configuration)
|
|
83
|
+
- [Connection Management](#connection-management)
|
|
84
|
+
- [Alarm Control](#alarm-control)
|
|
85
|
+
- [Data Models](#data-models)
|
|
86
|
+
- [Error Handling](#error-handling)
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Configuration
|
|
91
|
+
|
|
92
|
+
### Constructor Parameters: `IAlarmMkClient`
|
|
93
|
+
|
|
94
|
+
| Parameter | Type | Default | Description |
|
|
95
|
+
|-----------|:----:|:-------:|-------------|
|
|
96
|
+
| **`host`** | `str` | *required* | IP address of the panel |
|
|
97
|
+
| **`port`** | `int` | *required* | TCP port (8000 for MK7, 18034 for MK2) |
|
|
98
|
+
| **`username`** | `str` | *required* | Login username |
|
|
99
|
+
| **`password`** | `str` | *required* | Login password |
|
|
100
|
+
| `timeout` | `float` | `10.0` | Socket timeout in seconds |
|
|
101
|
+
| `keepalive_interval` | `int \| None` | `30` | Seconds between keepalive polls; `None` to disable |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Connection Management
|
|
106
|
+
|
|
107
|
+
### Connect / Disconnect
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
await client.connect()
|
|
111
|
+
await client.disconnect()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Context Manager (recommended)
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "pass") as client:
|
|
118
|
+
status = await client.get_status()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Alarm Control
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
await client.arm_away() # Arm all zones
|
|
127
|
+
await client.arm_stay() # Perimeter zones only
|
|
128
|
+
await client.arm_partial() # Partial arm
|
|
129
|
+
await client.disarm() # Disarm
|
|
130
|
+
await client.cancel_alarm() # Cancel active alarm
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Data Models
|
|
136
|
+
|
|
137
|
+
### `AlarmStatusModel`
|
|
138
|
+
|
|
139
|
+
| Field | Type | Description |
|
|
140
|
+
|-------|------|-------------|
|
|
141
|
+
| `status` | `AlarmStatusEnum` | Current panel status |
|
|
142
|
+
|
|
143
|
+
### `AlarmStatusEnum`
|
|
144
|
+
|
|
145
|
+
| Value | Name | Description |
|
|
146
|
+
|:-----:|------|-------------|
|
|
147
|
+
| `0` | `ARMED_AWAY` | Armed, all zones |
|
|
148
|
+
| `1` | `DISARMED` | Disarmed |
|
|
149
|
+
| `2` | `ARMED_STAY` | Armed, stay mode |
|
|
150
|
+
| `3` | `CANCEL` | Alarm cancelled |
|
|
151
|
+
| `4` | `TRIGGERED` | Alarm triggered |
|
|
152
|
+
| `5` | `ALARM_ARMING` | Arming in progress |
|
|
153
|
+
| `6` | `UNAVAILABLE` | Status unknown |
|
|
154
|
+
| `8` | `ARMED_PARTIAL` | Armed, partial |
|
|
155
|
+
|
|
156
|
+
### `ZoneModel`
|
|
157
|
+
|
|
158
|
+
| Field / Property | Type | Description |
|
|
159
|
+
|------------------|------|-------------|
|
|
160
|
+
| `index` | `int` | Zone index |
|
|
161
|
+
| `name` | `str` | Zone name |
|
|
162
|
+
| `zone_type` | `int` | Zone type code |
|
|
163
|
+
| `status` | `ZoneStatusEnum` | Raw status bitmask |
|
|
164
|
+
| `is_open` | `bool` | Zone is faulted / open |
|
|
165
|
+
| `is_bypassed` | `bool` | Zone is bypassed |
|
|
166
|
+
| `low_battery` | `bool` | Low battery detected |
|
|
167
|
+
| `signal_loss` | `bool` | Wireless signal lost |
|
|
168
|
+
|
|
169
|
+
### `NetworkInfoModel`
|
|
170
|
+
|
|
171
|
+
| Field | Type | Description |
|
|
172
|
+
|-------|------|-------------|
|
|
173
|
+
| `name` | `str` | Panel device name |
|
|
174
|
+
| `mac` | `str` | MAC address |
|
|
175
|
+
| `ip` | `str` | IP address |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Error Handling
|
|
180
|
+
|
|
181
|
+
| Exception | When raised |
|
|
182
|
+
|-----------|-------------|
|
|
183
|
+
| `IAlarmMkConnectionError` | TCP failure, timeout, or unexpected error during login |
|
|
184
|
+
| `IAlarmMkLoginError` | Panel rejected credentials |
|
|
185
|
+
| `IAlarmMkAlarmError` | Panel returned a non-zero error code for a command |
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from open_ialarm_mk_local_api import IAlarmMkConnectionError, IAlarmMkLoginError
|
|
189
|
+
|
|
190
|
+
try:
|
|
191
|
+
async with IAlarmMkClient("192.168.1.100", 8000, "admin", "pass") as client:
|
|
192
|
+
await client.arm_away()
|
|
193
|
+
except IAlarmMkLoginError:
|
|
194
|
+
print("Wrong credentials")
|
|
195
|
+
except IAlarmMkConnectionError as e:
|
|
196
|
+
print(f"Connection failed: {e}")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Examples
|
|
202
|
+
|
|
203
|
+
Run any example directly from the repo root (no install needed):
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
python3 examples/get_status.py --host 192.168.1.100 --user admin --password password
|
|
207
|
+
python3 examples/arm_away.py --host 192.168.1.100 --user admin --password password arm-partial
|
|
208
|
+
python3 examples/subscribe_events.py --host 192.168.1.100 --user admin
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Integration test against a real panel
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
python3 examples/integration_test.py --host 192.168.1.100 --user admin --password password
|
|
215
|
+
# skip arm/disarm on a live production panel:
|
|
216
|
+
python3 examples/integration_test.py --host 192.168.1.100 --user admin --password password --skip-arm
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Testing
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
python -m pytest tests/
|
|
225
|
+
```
|
|
226
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from .enums.alarm_status_enum import AlarmStatusEnum
|
|
2
|
+
from .enums.zone_status_enum import ZoneStatusEnum
|
|
3
|
+
from .exceptions.alarm_error import IAlarmMkAlarmError
|
|
4
|
+
from .exceptions.connection_error import IAlarmMkConnectionError
|
|
5
|
+
from .exceptions.login_error import IAlarmMkLoginError
|
|
6
|
+
from .ialarmmk_client import IAlarmMkClient
|
|
7
|
+
from .ialarmmk_push_client import IAlarmMkPushClient
|
|
8
|
+
from .models.alarm_status_model import AlarmStatusModel
|
|
9
|
+
from .models.network_info_model import NetworkInfoModel
|
|
10
|
+
from .models.zone_model import ZoneModel
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|
|
13
|
+
__all__ = [
|
|
14
|
+
"IAlarmMkClient",
|
|
15
|
+
"IAlarmMkPushClient",
|
|
16
|
+
"AlarmStatusEnum",
|
|
17
|
+
"ZoneStatusEnum",
|
|
18
|
+
"AlarmStatusModel",
|
|
19
|
+
"ZoneModel",
|
|
20
|
+
"NetworkInfoModel",
|
|
21
|
+
"IAlarmMkConnectionError",
|
|
22
|
+
"IAlarmMkLoginError",
|
|
23
|
+
"IAlarmMkAlarmError",
|
|
24
|
+
]
|
|
File without changes
|