1
0
Fork 0
hswro-alarm-bot/README.md

108 lines
3.3 KiB
Markdown
Raw Normal View History

2024-02-08 18:23:46 +00:00
# Hackerspace Wroclaw Alarm Bot
[![builds.sr.ht status](https://builds.sr.ht/~michalr/hswro-alarm-bot.svg)](https://builds.sr.ht/~michalr/hswro-alarm-bot?)
Warning: this is a proof of concept, don't rely on it
2024-03-10 20:34:00 +00:00
It was very basically tested, and while it seems to work, approach it without any expectations.
In other words - treat it as a toy, not as a tool that will save your life or valuables, because it probably won't.
2024-02-08 18:23:46 +00:00
## Usage
```
$ TELEGRAM_APITOKEN=YOUR_API_TOKEN ./alarm_bot --satel_addr=127.0.0.1 --satel_port=31337 --tg_chat_id=YOUR_CHAT_ID_FROM_BOTFATHER
2024-02-09 22:32:32 +00:00
```
### Notification via HTTP callbacks
Set the following environment variables:
2024-03-06 21:31:08 +00:00
- `NOTIFY_URL_ARM` - for an URL that will be POST when partition **0** is armed
- `NOTIFY_URL_DISARM` - for an URL that will be POST when partition **0** is unarmed
- `ALARM_URL_ARM` - for an URL that will be POST when **any** partition alarm is activated
2024-02-18 17:44:08 +00:00
### Filtering events by change type
It's possible to filter events by change type. Use the `--allowed-types=TYPE1,TYPE2,...` command line parameter to do that. If that parameter is not provided, then all change types are allowed, otherwise only the provided ones will be used for notifications.
Supported types are:
- `zone-violation`
- `zone-tamper`
- `zone-alarm`
- `zone-tamper-alarm`
- `zone-alarm-memory`
- `zone-tamper-alarm-memory`
- `zone-bypass`
- `zone-no-violation-trouble`
- `zone-long-violation-trouble`
- `armed-partition-suppressed`
- `armed-partition`
- `partition-armed-mode-2`
- `partition-armed-mode-3`
- `partition-with-1st-code-enter`
- `partition-entry-time`
- `partition-exit-time-over-10s`
- `partition-exit-time-under-10s`
- `partition-temporary-blocked`
- `partition-blocked-guard-round`
- `partition-alarm`
- `partition-fire-alarm`
- `partition-alarm-memory`
- `partition-fire-alarm-memory`
- `output`
- `doors-opened`
- `doors-opened-long`
- `status-bit`
- `trouble-part-1`
- `trouble-part-2`
- `trouble-part-3`
- `trouble-part-4`
- `trouble-part-5`
- `trouble-memory-part-1`
- `trouble-memory-part-2`
- `trouble-memory-part-3`
- `trouble-memory-part-4`
- `trouble-memory-part-5`
- `partition-with-violated-zones`
- `zone-isolate`
2024-03-10 20:34:00 +00:00
### Filtering events by index (which meaning depends on the change type)
2024-02-18 18:00:49 +00:00
Use the `--allowed-indexes=1,2,3,...` command line parameter to set the list of allowed indexes (of course provide your own list instead of `1,2,3,...`). If that parameter is not provided, then all indexes are allowed; otherwise the notification is sent for all indexes.
2024-03-10 20:34:00 +00:00
## example systemd unit
```
[Unit]
Description=Satel Alarm Telegram Status Notifier
Requires=network.target
After=network.target
[Service]
Type=simple
ExecStart=/path/to/alarm_bot --satel-addr=192.168.13.37 --satel-port=7094 --tg-chat-id=1234,4567,9876
Environment=TELEGRAM_APITOKEN=YOUR_API_TOKEN
Environment=NOTIFY_URL_DISARM="http://localhost/disarmed"
Environment=NOTIFY_URL_ARM="http://localhost/armed"
DynamicUser=True
RuntimeDirectory=hswro-alarm-bot
StateDirectory=hswro-alarm-bot
RestartSec=30
Restart=on-failure
CPUAccounting=true
CPUQuota=5%
MemoryAccounting=true
MemoryHigh=25M
MemoryMax=50M
[Install]
WantedBy=multi-user.target
```
2024-02-09 22:32:32 +00:00
## Debugging
Set the `OMIT_TG` environment variable to, well, omit sending anything over to Telegram and just see the logs instead.