|
1 | 1 | # AlarmPI  [](https://github.com/bkbilly/AlarmPI/releases/latest) |
2 | 2 |
|
3 | | -AlarmPI is a home security system based on Raspberry PI. It supports wired sensors (PIR, Magnetic etc.) and wireless through MQTT or Hikvision. It is controlled with a Web UI, a Android Application, or through HTTP & MQTT messages. When the alarm detects movement, it supports the following events: |
4 | | - * Enables the Siren |
5 | | - * Send Mail |
6 | | - * VoIP Calls |
7 | | - * Send MQTT message |
| 3 | +**AlarmPI** is a modern, modular home security and automation system designed for Raspberry Pi and Linux systems. It features a fully dynamic, plugin-based architecture for both **Sensors** and **Notifiers**, backed by a sleek real-time Web dashboard and Home Assistant integration. |
8 | 4 |
|
9 | | -It is written in python and supports both python 2.7 & python 3.6. There is also the option of having more than one user by editing the server.json file accordingly. |
| 5 | +--- |
10 | 6 |
|
| 7 | +## Key Features |
11 | 8 |
|
12 | | -## Installation |
13 | | -With this command on your terminal you can install and update the application with my latest commit. |
14 | | -```bash |
15 | | -bash <(curl -s "https://raw.githubusercontent.com/bkbilly/AlarmPI/master/install.sh") |
| 9 | +- **Folder-Based Modular Plugins**: |
| 10 | + - **Notifiers** (`alarmcode/notifiers/`): Drop in any `.py` file to automatically register new notification channels (e.g., Telegram, Pushover, Discord, Webhooks) without editing core code. |
| 11 | + - **Sensors** (`alarmcode/sensors/`): Easily add custom sensor drivers (GPIO, Hikvision cameras, MQTT, Virtual/Webhooks). |
| 12 | +- **Smart Arming & Sensor Behaviors**: |
| 13 | + - **Arm After Closing**: Instantly arms the system as soon as entry/exit doors close without waiting for remaining exit delay. |
| 14 | + - **Auto-Bypass Open Sensors (Force Arm)**: Automatically bypasses open windows/doors upon arming without blocking system arming. |
| 15 | + - **Entry & Exit Delays**: Configurable grace periods with live countdown and audio warning beeps. |
| 16 | + - **Door Chime**: Plays gentle browser & system chimes when perimeter doors open while disarmed. |
| 17 | + - **Rich Sensor Behaviors**: `Normal (Armed only)`, `Entry/Exit (Delay Countdown)`, `Instant Breach`, `24-Hours (Always Active: Smoke/Tamper)`, and `Chime`. |
| 18 | + - **Siren Auto-Cutoff**: Configurable siren timeout to prevent battery drain and comply with noise ordinances. |
| 19 | +- **Dynamic Backend Settings**: All plugin schemas and configuration parameters are defined on the backend and dynamically rendered on the frontend UI. |
| 20 | +- **Modern Hardware & OS Compatibility**: Compatible with Python 3.10 – 3.14+, Raspberry Pi OS (Debian Bookworm / Pi 5), with transparent hardware/virtual GPIO fallback for development and testing. |
| 21 | +- **Real-Time Web Dashboard**: Responsive dark-mode interface with live Socket.IO state synchronization, interactive zone arming/disarming, and visual sensor timelines. |
| 22 | +- **Home Assistant & MQTT Discovery**: Instant integration with Home Assistant via MQTT Discovery (Alarm Control Panel, Siren, Binary Sensors). |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Modular Plugin Architecture |
| 27 | + |
| 28 | +### Adding a Notification Plugin |
| 29 | +Create a new file in [`alarmcode/notifiers/`](file:///home/bkbilly/Documents/AlarmPI/alarmcode/notifiers/) (e.g. `telegram.py`): |
| 30 | + |
| 31 | +```python |
| 32 | +from alarmcode.notifiers.base import BaseNotifier, NotifierField |
| 33 | + |
| 34 | +class TelegramNotifier(BaseNotifier): |
| 35 | + name = "telegram" |
| 36 | + display_name = "Telegram Bot" |
| 37 | + description = "Send instant alert messages and photos via Telegram Bot API." |
| 38 | + icon = "send" |
| 39 | + |
| 40 | + @classmethod |
| 41 | + def define_fields(cls): |
| 42 | + return [ |
| 43 | + NotifierField("enable", "Enable Telegram", "boolean", default=False), |
| 44 | + NotifierField("bot_token", "Bot Token", "password", default=""), |
| 45 | + NotifierField("chat_ids", "Chat IDs", "list", default=[], placeholder="1234567, 9876543"), |
| 46 | + ] |
| 47 | + |
| 48 | + def on_intruder_alert(self, alert_info=None): |
| 49 | + if self.is_enabled(): |
| 50 | + # Send alert to Telegram... |
| 51 | + pass |
16 | 52 | ``` |
| 53 | +*AlarmPI will automatically discover your plugin, add its configuration schema to the backend, and render its controls and live status badge in the Settings UI!* |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +### Adding a Sensor Plugin |
| 58 | +Create a new file in [`alarmcode/sensors/`](file:///home/bkbilly/Documents/AlarmPI/alarmcode/sensors/) (e.g. `zigbee.py`): |
| 59 | + |
| 60 | +```python |
| 61 | +from alarmcode.sensors.base import BaseSensorPlugin, SensorField |
| 62 | + |
| 63 | +class ZigbeeSensorPlugin(BaseSensorPlugin): |
| 64 | + sensor_type = "Zigbee" |
| 65 | + display_name = "Zigbee Device" |
| 66 | + description = "Monitor Zigbee door sensors and PIR detectors." |
| 67 | + |
| 68 | + @classmethod |
| 69 | + def define_fields(cls): |
| 70 | + return [ |
| 71 | + SensorField("device_ieee", "Device IEEE Address", "string", required=True), |
| 72 | + ] |
| 73 | +``` |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Installation & Running |
| 78 | + |
| 79 | +```bash |
| 80 | +# Clone the repository |
| 81 | +git clone https://github.com/bkbilly/AlarmPI.git |
| 82 | +cd AlarmPI |
| 83 | + |
| 84 | +# Create virtual environment and install dependencies |
| 85 | +python3 -m venv .venv |
| 86 | +source .venv/bin/activate |
| 87 | +pip install -r requirements.txt |
17 | 88 |
|
18 | | -## Usage |
19 | | -### Web UI |
20 | | -The Web Interface of the alarm has all the features that are needed to configure and use the home security. It supports real time events of the sensors, the logs and their status. |
21 | | -It also works as an smartphone application from the browser: _Add to Home screen_ |
22 | | - |
23 | | -### Mobile Application |
24 | | -The android application is very light and fast and it is recomended for the phone, but it has no real time updates. |
25 | | -You can download it from here: [Play Store](https://play.google.com/store/apps/details?id=bkbilly.alarmpi) |
26 | | - |
27 | | -The source code for the application is here: https://github.com/bkbilly/AlarmPI-Android |
28 | | - |
29 | | -### Snips |
30 | | -Through voice commands from Snips platform using this application: [snips console](https://console.snips.ai/store/en/skill_G4V82q5rb2) |
31 | | - |
32 | | -### Home-Assistant |
33 | | -It is also controlled with MQTT commands with the Home-Assistant component: 'MQTT Alarm Control Panel'. |
34 | | -On Home-Assistant the configuration is like so: |
35 | | -```yaml |
36 | | -alarm_control_panel: |
37 | | - - platform: mqtt |
38 | | - name: "AlarmPI" |
39 | | - state_topic: "home/alarm" # The State Topic from AlarmPI |
40 | | - command_topic: "home/alarm/set" # The Command Topic from AlarmPI |
41 | | - payload_arm_home: "ARM_HOME" # This is not used |
42 | | - payload_arm_away: "ARM_AWAY" |
| 89 | +# Start the server |
| 90 | +python3 run.py |
43 | 91 | ``` |
44 | 92 |
|
45 | | -## API |
46 | | -### HTTP |
47 | | - * `https://admin:secret@example.com:5000/setSensorStatus?name=test1&state=off` |
48 | | - * `https://admin:secret@example.com:5000/activateAlarmZone?zones=home,away` |
49 | | - * `https://admin:secret@example.com:5000/activateAlarmOnline` |
50 | | - * `https://admin:secret@example.com:5000/deactivateAlarmOnline` |
51 | | - * `https://admin:secret@example.com:5000/stopSiren` |
52 | | - * `https://admin:secret@example.com:5000/startSiren` |
53 | | - * `https://example.com:5000/login?username=admin&password=secret` |
54 | | - |
55 | | -### MQTT |
56 | | -These are the possible mqtt messages. First you will have to setup the MQTT state_topc & command_topic. |
57 | | - * `home/alarm/set` [ARM_HOME,ARM_AWAY,ARM_NIGHT,DISARM,PENDING] |
58 | | - * `home/alarm/set/siren` {"state": "ON"} |
59 | | - * `home/alarm/set/sensor/test1` [off,online] |
60 | | - * `home/alarm/sensor/test1` [off,on,error] |
61 | | - * `home/alarm` [armed_away,disarmed,triggered] |
62 | | - |
63 | | -Supports custom messages subscriptions on MQTT Sensors by filling the appropriate information about topic and payload on sensor settings. This can be used for cases like zigbee2mqtt so that zigbee devices can be used. The payload must be a python function with the payload stored as `message` like this: |
64 | | - * message['contact'] == 'ON' |
65 | | - |
66 | | -### IFTTT |
67 | | -It can also be used with IFTTT using the Webhooks module like this: |
68 | | -`https://admin:secret@example.com:5000/activateAlarmOnline` |
69 | | -`https://admin:secret@example.com:5000/deactivateAlarmOnline` |
70 | | ->My personal favourite is to control it with Google Assistant. |
71 | | - |
72 | | -## SipCall (VoIP) |
73 | | -I have built the sipcall for the Raspberry Pi, so hopefully you will not have to build it yourself. |
74 | | -To test it, execute this replacing the (myserver, myusername, mypassword, mynumbertocall): |
75 | | - |
76 | | -`./sipcall -sd myserver -su myusername -sp mypassword -pn mynumbertocall -s 1 -mr 2 -ttsf ../play.wav` |
| 93 | +Open your browser at `http://localhost:5000` (Default credentials: `test1` / `secret`). |
0 commit comments