Package: miqro-alarm
miqro_alarmThis 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 inputsCustom conditions for alarms can be expressed, e.g., if a value rises above a certain thresholdPrealarms are supported - raise awareness to an issue before the full alarm is triggered, or allow time for disabling the alarmDebouncing of input signals is supported, e.g., to avoid false alarms due to sensor noiseAlarm 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 intervalsDifferent alarm schedules can be mapped to one topic, e.g., to show a different light pattern for intrusion alarms and fire alarmsAlarm groups capture multiple inputs and drive one or more alarm outputsComprehensive support for liveness checks:If an MQTT topic is not received in a certain interval, send a notificationEnsure that other services are alive, send notification if they failCan call an external HTTP liveness check to ensure the alarm service is still runningSupport for alarm inhibition (e.g., suppress an intrusion alarm when owner is at home)Alarms can be switched on/off and observed via MQTTSee (examples/miqro.example.yml)[examples/miqro.example.yml] for configuration examples.InstallingTo install the software, follow these stepsas root:Ifpip3is not installed, runapt install python3-pipfirst.Then runpip3 install miqro_alarmCreate the configuration file/etc/miqro.ymlSeeexamples/miqro.example.ymlfor an exampleSeethe MIQRO documentationfor other options you can use in the configuration fileInstall the system service:miqro_alarm  --installsystemctl enable miqro_alarmsystemctl start miqro_alarmConfigurationThe configuration is based on a few concepts:Outputsdefine MQTT topics an alarm can be sent to. This can be:Atext output: This output is defined by a single MQTT topic that accepts a human-readable message, for example, an SMS gateway.Aswitch 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 Groupsdefine 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 anamethat it used in the MQTT messages and a human-readablelabel.The alarm group can be configured to trigger a number ofoutputsat once.You can also define aprealarm, 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 ofinputs. 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 defineliveness checksfor 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 defineinhibitorsfor 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 TopicsFor each alarm group, the following topics are published:service/alarm/GROUP1/state— the state of alarm group GROUP1:off,prealarm, oralarmservice/alarm/GROUP1/enabled/state—1when the group is enabled,0otherwiseservice/alarm/GROUP1/inhibited/state—1when the alarm is inhibited,0otherwiseservice/alarm/GROUP1/any_inhibitor_active—1if alarm group is manually inhibited or via a defined inhibitor,0otherwiseservice/alarm/GROUP1/all_inputs_online—1when all inputs of this group are live,0otherwiseservice/alarm/GROUP1/live—1when all liveness checks for this group are OK and all inputs and inhibitors are liveservice/alarm/g1/display_state— a unified view on the state of this alarm group:disabled,inhibited,enabled,prealarm,alarm— recommended for use in user interfacesFor each input of the group:service/alarm/GROUP1/input/INPUT1/state— the state of this input:invalid_response,unknown,offline, oronlineservice/alarm/GROUP1/input/INPUT1/value— the last evaluated value for this alarm input —1or0Same for each inhibitor (../inhibitor/..) and liveness check (../liveness/..) of the alarm group.All outputs listed above are also published in a JSON object atservice/alarm/GROUP1/info.:inbox_tray: Subscribed TopicsThe following topics can be used to control the alarm groups:service/alarm/GROUP1/enabled/command— send1to enable alarm group,0to disableservice/alarm/GROUP1/inhibited/command— send1to (manually) inhibit alarm group,0to remove manual inhibitionservice/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