Notification module

Материал из Wiren Board
Это утверждённая версия страницы. Она же — наиболее свежая версия.
Другие языки:
notification module configuration

The notification module (Alarm) is designed to quickly configure sending SMS and email in case of changing the parameters of the controller or connected devices (for example, the readings of the connected temperature sensor).

Pre-setting to send email

At the Linux level, the email utility is used to send emails. sSMTP. To start sending mail, you need to edit its configuration file "/etc/ssmtp/ssmtp.conf".

Emails will be sent from one of your mailboxes, which will be required:

  • login (for example, "robot@wirenboard.com"),
  • password,
  • SMTP server address and port (for Gmail mailboxes, it is "smtp.gmail.com:587", for Mail.Ru - "smtp.mail.EN:465").

Clear the contents of "/etc/ssmtp/ssmtp.conf" and fill in such lines, replacing the data with your own:

mailhub=smtp.gmail.com:587
AuthUser=robot@wirenboard.com
AuthPass=qwerty12345
UseTLS=Yes
UseSTARTTLS=Yes
#be sure to leave an empty line at the end of the file
#To send emails via Google Mail, you must allow sending emails from untrusted apps to your Google account

To verify that sending email is working, run the console command:

echo 'Test message to check sSMTP new configuration' | ssmtp ivanov@gmail.com
# instead ivanov@gmail.com substitute the address of your other box (for example, where you are going to receive notifications from the controller)

In case of additional questions, see [1] and [2].

Pre-setting for sending SMS

Make sure you insert the SIM card and connect the GSM antenna.

Configure the notification module

  1. Go to the "Configs - Alarm Configuraion" page of the web interface.
  2. Add notification recipients in the "Recipients" section:
    • press "+ Recipient";
    • select the type ("E-mail" or "SMS");
    • enter your postal address or phone number. You can also specify the subject of the email.
  3. Configure the parameter and condition to be checked in the "Alarms" section:
    • press "+ Item";
    • in the section that appears, select one of the four notification types from the drop-down list:
      1. "Expected Value Alarm" - notification, if the value is no longer equal to the specified value.
      2. "Minimum Value Alarm" - notification if the value becomes less than the specified value.
      3. "Maximum Value Alarm" - notification if the value becomes greater than the specified value.
      4. "Minimum&Maximum Value Alarm" - notification if the value is out of the specified range.
    • in "Alarm name" enter an arbitrary name for the notification;
    • in "Cell", enter the parameter you want to monitor. The parameter is specified as "Device/Control", where the device and Control names for each parameter can be found on the "Settings" page of the web interface in the "MQTT Channels" table. For example, for a 1-Wire sensor connected to an external Modbus WB-MS sensor, this string would look like "wb-ms-thls-v2_101/External Sensor 2";
    • in "Alarm activation message" enter the text of the message to be sent. You can enter two curly brackets "{} " in it in any place, instead of which a new parameter value will be substituted in the message, which is monitored.
    • depending on the notification type, fill in the fields "Minimum Value", "Maximum Value", "Expected Value";
    • some additional settings will be available if you click on the "Properties" button and check them.
  4. Click "Save" at the top of the page:
    • if you forget to specify some required parameter, the "Save" button will be inactive, and an error will be written next to the parameter in red, which should be corrected;
    • if everything is OK, notifications will start working.

How to set up notifications with more complex conditions

The notification module is designed to quickly configure simple notifications. If you need more complex notification scripts, they can be programmed via rules engine. To send a message, call the function from the rule

Notify.sendEmail(to, subject, text); //sends mail to the specified recipient (to), with the specified subject and content (text)

or

Notify.sendSMS(to, text); //sends SMS to specified number (to) with specified content (text)