Prerequisites
GSM modem
A serial GSM modem connected via USB or UART. The SIM900 module has been tested and confirmed to work.
SIM card
An active SIM card with SMS capability inserted in the modem.
No additional packages beyond the base PAI installation are required. Serial communication is handled by
pyserial-asyncio, which is already a core dependency.Configuration
Add the following to yourpai.conf:
pai.conf
Configuration reference
GSM_ENABLE
GSM_ENABLE
Enable or disable the GSM interface.Default:
FalseGSM_MODEM_PORT
GSM_MODEM_PORT
The filesystem path of the serial port to which the GSM modem is connected. Common values are
/dev/ttyUSB0 for USB modems or /dev/ttyS0 for hardware UART.Default: ''GSM_MODEM_BAUDRATE
GSM_MODEM_BAUDRATE
The baud rate for serial communication with the modem. Must be between
9600 and 115200.Default: 115200GSM_CONTACTS
GSM_CONTACTS
A list of phone numbers in international format that are allowed to send SMS commands to the panel and will receive SMS notifications. SMS messages from numbers not in this list are logged as unknown and ignored.Default:
[]Example:GSM_MIN_EVENT_LEVEL
GSM_MIN_EVENT_LEVEL
The minimum severity level for events to trigger an SMS. Accepted values:
DEBUG, INFO, WARN, ERROR, CRITICAL.The default is CRITICAL because SMS delivery has a per-message cost and latency. Reserve SMS for events that genuinely require immediate attention regardless of internet connectivity.Default: 'CRITICAL'GSM_EVENT_FILTERS
GSM_EVENT_FILTERS
A list of tag expressions that control which events trigger an SMS. Each entry is a comma-separated list of tags; a
- prefix excludes a tag.Default:GSM_ALLOW_EVENTS and GSM_IGNORE_EVENTS
GSM_ALLOW_EVENTS and GSM_IGNORE_EVENTS
Alternative to
GSM_EVENT_FILTERS using regular expressions.GSM_ALLOW_EVENTS— list of regex patterns matchingtype,label,property=valuefor events to forward.GSM_IGNORE_EVENTS— list of regex patterns for events to suppress, applied afterALLOW_EVENTS.
[] for bothExample configuration
How event filtering works
- Tag filters (GSM_EVENT_FILTERS)
- Regex filters (GSM_ALLOW_EVENTS / GSM_IGNORE_EVENTS)
Each entry in
GSM_EVENT_FILTERS is a comma-separated list of tags. A - prefix means the tag must not be present. An SMS is sent if an event matches all tags in any one filter entry.Modem initialisation
When PAI starts, it sends a sequence of AT commands to configure the modem:| Command | Purpose |
|---|---|
AT | Verify modem is responsive |
ATE0 | Disable command echo |
AT+CMEE=2 | Enable verbose error reporting |
AT+CMGF=1 | Set SMS text mode |
AT+CFUN=1 | Enable full modem functionality |
AT+CNMI=1,2,0,0,0 | Route incoming SMS directly to the serial port via +CMT |
AT+CUSD=1 | Enable USSD result code presentation |
The SIM900 module has been tested with this integration. Other modems that support standard GSM AT commands (3GPP TS 27.005) should also work.