Send SIA events by push mail
-
gol
- Webbplatsadministratör
- Posts: 81
- Joined: Sun 01 Jun 2014, 19:38
Post
by gol » Fri 06 Jun 2014, 17:40
This is program template written in Javascript that can be used to send SIA-events from the SPC panel by push mail.
To be able to run the program you need to install NodeJS and some NodeJS addon modules.
Install NodeJS
Code: Select all
sudo apt-get update
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
Check the installation with: node -v
Install required addon modules
Code: Select all
cd <INSTALL_DIR>
sudo npm install websocket
sudo npm install emailjs
Install spc-notify-mail
Code: Select all
cd <INSTALL_DIR>
tar xzvf spc-notify-mail.tar.gz
cd spc-notify-mail
Modify the settings in config.json according your environment and email account.
In spc-notify-mail.js, function manageSiaEvent() you have to add all SIA-event types you want to be managed by the program. Look in the SPC documentation for definitions of the SIA-event types.
Run the program with: ./spc-notify-mail.js
-
Attachments
-
- spc-notify-mail-1.0.tar.gz
- (1.71 KiB) Downloaded 256 times
-
BigSwede
- Posts: 4
- Joined: Tue 09 Aug 2016, 08:11
Post
by BigSwede » Tue 09 Aug 2016, 10:05
Here is an example of a SystemD startup script for NodeJS email notify script.
Using Raspbian Jessie. I placed a plugin directory under the installation directory.
Please adjust path's to match your system.
Create file in /etc/systemd/system
Code: Select all
cd /etc/systemd/system
touch spc-notify-email.service
chmod 664 spc-notify-email.service
nano spc-notify-email.service
Code: Select all
[Unit]
Description=SPC Notify Email plugin
After=spc-web-gateway.service
[Service]
ExecStart=/usr/bin/node /opt/spc-web-gateway/plugins/node-spc-notify-email-master/node-spc-notify-email.js
Restart=always
RestartSec=10
User=pi
[Install]
WantedBy=multi-user.target
Update SystemD, install and start.
Code: Select all
systemctl daemon-reload
systemctl enable spc-notify-email.service
systemctl start spc-notify-email.service
Good luck.