A universal alarm service using MQTT as input and output.
Project description
miqro_alarm
This is a full-fledged alarm logic, completely based on MQTT inputs and outputs. Reliability was a top priority during development.
Features:
- Listens to MQTT topics for alarm inputs
- Custom conditions for alarms can be expressed, e.g., if a value rises above a certain threshold
- Prealarms are supported - raise awareness to an issue before the full alarm is triggered, or allow time for disabling the alarm
- Debouncing of input signals is supported, e.g., to avoid false alarms due to sensor noise
- Alarm outputs:
- Text messages sent to MQTT topics (e.g., an SMS gateway, push message provider, etc.)
- Switch outputs, i.e., MQTT topics expecting custom messages (e.g., to connect to other MQTT services or to drive lights, sirens, etc.)
- Messages can be repeated in custom intervals
- Different alarm schedules can be mapped to one topic, e.g., to show a different light pattern for intrusion alarms and fire alarms
- Alarm groups capture multiple inputs and drive one or more alarm outputs
- Comprehensive support for liveness checks:
- If an MQTT topic is not received in a certain interval, send a notification
- Ensure that other services are alive, send notification if they fail
- Can call an external HTTP liveness check to ensure the alarm service is still running
- Support for alarm inhibition (e.g., suppress an intrusion alarm when owner is at home)
- Alarms can be switched on/off and observed via MQTT
See (examples/miqro.example.yml)[examples/miqro.example.yml] for configuration examples.
Installing
To install the software, follow these steps as root:
- If
pip3is not installed, runapt install python3-pipfirst. - Then run
pip3 install miqro_alarm - Create the configuration file
/etc/miqro.yml- See examples/miqro.example.yml for an example
- See the MIQRO documentation for other options you can use in the configuration file
- Install the system service:
miqro_alarm --installsystemctl enable miqro_alarmsystemctl start miqro_alarm
Configuration
The configuration is based on a few concepts:
- Outputs define MQTT topics an alarm can be sent to. This can be:
- A text output: This output is defined by a single MQTT topic that accepts a human-readable message, for example, an SMS gateway.
- A switch output: Defines one or more MQTT topics that accept custom messages. This can be used to drive lights, sirens, etc. You can define separate MQTT topics for different alarm schedules, e.g., to show a different light pattern for intrusion alarms and fire alarms. For each alarm schedule, you can define the MQTT topic, the message that is sent when the alarm is activated, whether the message is to be repeated, and an MQTT topic and message that is sent when the alarm is deactivated.
- Alarm Groups define a set of inputs that are to be monitored. If any of the inputs is triggered, the alarm for the group is activated. Each alarm group offers a number of configuration options:
- Each group has a name that it used in the MQTT messages and a human-readable label.
- The alarm group can be configured to trigger a number of
outputs at once. - You can also define a prealarm, which is activated before the alarm is triggered. After a defined interval, the prealarm is deactivated and the alarm is triggered.
- You can define a number of inputs. Each input is defined by a single MQTT topic and a condition. If the condition is met, the input is triggered. Conditions can be defined using python expressions. You can define a number of conditions, e.g., if a value rises above a certain threshold or if a value is below a certain threshold. Additionally, there is a timeout for each input that you can define. If no message is received for the input in the defined interval, the input is considered to be dead and a notification will be sent.
- You can define liveness checks for each alarm group: If a liveness check is not triggered in a certain interval, a notification is sent. This can be used, e.g., to check that a sensor sends data in a certain interval or that another service is still running.
- You can define inhibitors for each alarm group. If an inhibitor is triggered, the alarm is inhibited. This can be used, e.g., to suppress an intrusion alarm when the owner is at home.
See (examples/miqro.example.yml)[examples/miqro.example.yml] for configuration examples and explanations.
MQTT Topics
:outbox_tray: Published Topics
For each alarm group, the following topics are published:
-
service/alarm/GROUP1/state— the state of alarm group GROUP1:off,prealarm, oralarm -
service/alarm/GROUP1/enabled/state—1when the group is enabled,0otherwise -
service/alarm/GROUP1/inhibited/state—1when the alarm is inhibited,0otherwise -
service/alarm/GROUP1/any_inhibitor_active—1if alarm group is manually inhibited or via a defined inhibitor,0otherwise -
service/alarm/GROUP1/all_inputs_online—1when all inputs of this group are live,0otherwise -
service/alarm/GROUP1/live—1when all liveness checks for this group are OK and all inputs and inhibitors are live -
service/alarm/g1/display_state— a unified view on the state of this alarm group:disabled,inhibited,enabled,prealarm,alarm— recommended for use in user interfaces
For each input of the group:
-
service/alarm/GROUP1/input/INPUT1/state— the state of this input:invalid_response,unknown,offline, oronline -
service/alarm/GROUP1/input/INPUT1/value— the last evaluated value for this alarm input —1or0
Same for each inhibitor (../inhibitor/..) and liveness check (../liveness/..) of the alarm group.
All outputs listed above are also published in a JSON object at service/alarm/GROUP1/info.
:inbox_tray: Subscribed Topics
The following topics can be used to control the alarm groups:
-
service/alarm/GROUP1/enabled/command— send1to enable alarm group,0to disable -
service/alarm/GROUP1/inhibited/command— send1to (manually) inhibit alarm group,0to remove manual inhibition -
service/alarm/GROUP1/reset/command— send1to reset the alarm when it is active (inalarmorprealarmstate) -
service/alarm/GROUP1/reset/auto/command— send1to reset the alarm, if it is inalarmorprealarmstate; otherwise, the alarm is disabled or enabled — this is to be used in user interfaces
Project details
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 miqro_alarm-0.2.3.tar.gz.
File metadata
- Download URL: miqro_alarm-0.2.3.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e0f70077b4192e828c97a01b0358103da231706b4a37a96440f89ecd43f7f07
|
|
| MD5 |
e2f72cbd65f293c56aa240bfb580ec5b
|
|
| BLAKE2b-256 |
df0baa5ecdebe8632b7c1ef643011b54e16594a43d0de6809740b132270c579c
|
Provenance
The following attestation bundles were made for miqro_alarm-0.2.3.tar.gz:
Publisher:
python-publish.yml on danielfett/miqro_alarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miqro_alarm-0.2.3.tar.gz -
Subject digest:
3e0f70077b4192e828c97a01b0358103da231706b4a37a96440f89ecd43f7f07 - Sigstore transparency entry: 796487039
- Sigstore integration time:
-
Permalink:
danielfett/miqro_alarm@ae7dd1b943e979d4907685df32ebff2088f40fdd -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/danielfett
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ae7dd1b943e979d4907685df32ebff2088f40fdd -
Trigger Event:
release
-
Statement type:
File details
Details for the file miqro_alarm-0.2.3-py2.py3-none-any.whl.
File metadata
- Download URL: miqro_alarm-0.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e2db30039b9c0373bc08bd87021ce20c9a084016560e94805c12b11c14aad98
|
|
| MD5 |
690eed9a7f2022142760c2743024e72a
|
|
| BLAKE2b-256 |
944153b4d1914357403a6b6342fb296d471089b70ecaf30e9d02043e1639e134
|
Provenance
The following attestation bundles were made for miqro_alarm-0.2.3-py2.py3-none-any.whl:
Publisher:
python-publish.yml on danielfett/miqro_alarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
miqro_alarm-0.2.3-py2.py3-none-any.whl -
Subject digest:
2e2db30039b9c0373bc08bd87021ce20c9a084016560e94805c12b11c14aad98 - Sigstore transparency entry: 796487077
- Sigstore integration time:
-
Permalink:
danielfett/miqro_alarm@ae7dd1b943e979d4907685df32ebff2088f40fdd -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/danielfett
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ae7dd1b943e979d4907685df32ebff2088f40fdd -
Trigger Event:
release
-
Statement type: