Step by step guide: Visonic Powermax Pro integration
Posted: Saturday 19 March 2016 15:35
It took quit some time to get this done, but finally success! My Visonic Powermax Pro alarm system can now communicate via Raspberry pi to Domoticz, it can read it's status, but it also possible to send commands ; arm / disarm
http://www.domoticaforum.eu/viewtopic.p ... 52&start=0 was an important source for information.
Also a warning. I have not integrated Domoticz alarm panel functionality yet. Therefore presetting the alarm system code on your system is a security risk. Make sure that you WLAN and your raspi are secure!
This guide with follow the below steps;
1. Hardware install
2. Test connection
3. Installing pmax software
4. Config Domoticz
-----------------------------
1. Hardware install
To connect the raspberry use a usb serial module; https://microkloon.nl/nl/gereedschap/11 ... ch340.html
I used a module with a ch340 chip, since I could not make it work with 2303 chip. As you can see in the above link, the price is just EUR 5.
The Powermax Pro has a port (2x5) labeled PC, see pictures below. This is the port to use, since it’s voltage is 3,3v and that is the voltage that usb-serial port can handle. Don’t use the dual serial port which is an optional component of the Powermax pro series. The serial port has a voltage of 12v, connecting the serial usb module to this port will fry the module immediatly
See below the nummering of the 2x5 port of the panel. 3 is ground, 5 TxD for the panel, 7 is RxD fort the panel. Connect ground (3) to ground on the ch340 module, TxD (5) to RxD of the ch340, RxD (7) to TxD of the ch340 module.
1 3 5 7 9
2 4 6 8 10
2. Test connection
To test the connection I made it myself a bit easier by using this Windows application; Visonic (Powermax) LV Interface ; http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129
The developer, bartbakels, developed this application to let the Visonic alarm communicate with Homeseer. But you don’t need Homeseer to actually use the Visonic (Powermax) LV Interface.
Install the Visonic interface (currently version 1.0.4) http://www.promedes.nl/Downloads/Visoni ... V1.0.4.zip, to the Visonic panel and start up the Visonic interface driver. You should be able to arm and disarm the panel via this application. If that works continue to step 3. If it does not work, stop here, check your cabling!
3. Install Pmax software and other things that are required. I'm using Domoticz image version 4834, so it;s bases on Jessie!
a. First install a relevant library by issuing this:
b. Compile and install the xPL Hub by doing the following; The Hub is used to exchange xPl messages between the Pmax application and Apache2.
c. change the following file (/etc/rc.local) to let the hub start at reboot. Make sure that you insert the below before the line; exit 0
reboot the rasp pi, and after reboot, check by using "top" to see if xPL_Hub is in the list
d. Install the pmaxd application. Pmaxd is developed by viknet, see http://www.domoticaforum.eu/viewtopic.p ... 52&start=0
Given that Pmaxd is not developed for the Raspberry, a couple of changes are required in the Makefile, to make sure that the pmaxd source compiles
First jump to the pmaxd directory ;
Replace the contents of Makefile by the code below; Credits should go to, ayasystems, see http://www.domoticaforum.eu/viewtopic.p ... 120#p70430
Issue the command;
You should see something similar as below
copy the pmaxd config file to the /etc map;
The contents of the pmaxd.conf should resemble the below;
Change the above dummy usercode (1234) to your own usercode
Time to test pmaxd
Run pmaxd by issuing the following; you should see something similar as below
./pmaxd -fvvvvvvvv
I have boldfaced the checksum OK. That;s the relevant part of the above log. If you see Checksum Not OK, adjust the packet_timeout value in pmaxd.conf to e.g 3000, etc.
If you have also the checksum OK as above, you can do the following to arm and disarm the alarmsystem;
a
for Arm
d
for disarm
g
to get the log
The command is case sensitive.
e. Next, install Apache2
Since the pmaxd application needs to communicate with a webserver to run a few cgi scripts, Apache 2 is required.
From you home dir do this;
Create a cgi-file with the following content just to make sure that the Apache2 is working as expected;
And make the cgi file executable by doing this;
cgi is not enabled by default on an Apache2 server. To enable the cgi, do the following;
Time to test the hello script
Load the cgi file by loading the following url in your browser;
This should show Hello World in capital letters.
If that works you can try the following;
Change the following file (/etc/rc.local) to let the pmaxd start at reboot. Make sure that you insert the below before the line; exit 0
reboot the rasp pi, and after reboot, check by using "top" to see if both xPL_Hub and pmaxd are visible in the list.
After reboot reload the following url in your browser
That should return the following json string;
{ "status":"disarmed","pmaxstatus":"disarmed","readytoarm":"","sensor":[{"zone":"Woonkamer","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"},{"zone":"Slaapkamer","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"},{"zone":"2e Etage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"}]}
Also you can load the following website to arm and disarm the alarm. It's something to play around with. I won;t use this website, given that I want to integrate things in Domoticz;
4. Config Domoticz
a. Create a dummy switch with the name Visonic Alarm Status. Then copy past the below in a script_device_etc.lua script
b. Create a dummy selector switch. Hide the off switch
Create 3 sh script with the following names, and contents. By the way, I have copied xPLSend from the /home/pi/xPLLib/examples directory to another raspiberry pi (the main server) to /home/pi/xPL directory. xPLSend will broadcast an xPL message accross the network, which the xPL Hub on the other pi will receive.
Level 10, called: Arm_Away
script:///home/pi/domoticz/scripts/visonic_alarm_arm_away.sh
Level 20, called: Arm_Home
script:///home/pi/domoticz/scripts/visonic_alarm_arm_home.sh
Level 30, called: Disarm
script:///home/pi/domoticz/scripts/visonic_alarm_disarm.sh
That's all. Good luck
http://www.domoticaforum.eu/viewtopic.p ... 52&start=0 was an important source for information.
Also a warning. I have not integrated Domoticz alarm panel functionality yet. Therefore presetting the alarm system code on your system is a security risk. Make sure that you WLAN and your raspi are secure!
This guide with follow the below steps;
1. Hardware install
2. Test connection
3. Installing pmax software
4. Config Domoticz
-----------------------------
1. Hardware install
To connect the raspberry use a usb serial module; https://microkloon.nl/nl/gereedschap/11 ... ch340.html
I used a module with a ch340 chip, since I could not make it work with 2303 chip. As you can see in the above link, the price is just EUR 5.
The Powermax Pro has a port (2x5) labeled PC, see pictures below. This is the port to use, since it’s voltage is 3,3v and that is the voltage that usb-serial port can handle. Don’t use the dual serial port which is an optional component of the Powermax pro series. The serial port has a voltage of 12v, connecting the serial usb module to this port will fry the module immediatly

See below the nummering of the 2x5 port of the panel. 3 is ground, 5 TxD for the panel, 7 is RxD fort the panel. Connect ground (3) to ground on the ch340 module, TxD (5) to RxD of the ch340, RxD (7) to TxD of the ch340 module.
1 3 5 7 9
2 4 6 8 10
2. Test connection
To test the connection I made it myself a bit easier by using this Windows application; Visonic (Powermax) LV Interface ; http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129
The developer, bartbakels, developed this application to let the Visonic alarm communicate with Homeseer. But you don’t need Homeseer to actually use the Visonic (Powermax) LV Interface.
Install the Visonic interface (currently version 1.0.4) http://www.promedes.nl/Downloads/Visoni ... V1.0.4.zip, to the Visonic panel and start up the Visonic interface driver. You should be able to arm and disarm the panel via this application. If that works continue to step 3. If it does not work, stop here, check your cabling!
3. Install Pmax software and other things that are required. I'm using Domoticz image version 4834, so it;s bases on Jessie!
a. First install a relevant library by issuing this:
Code: Select all
sudo apt-get install libconfig-dev
Code: Select all
$ wget http://www.xpl4java.org/xPL4Linux/downloads/xPLLib.tgz
$ tar xzvf xPLLib.tgz
$ cd xPLLib
$ sudo make install
$ cd examples
$ make
$ sudo cp xPL_Hub /usr/local/bin
$ sudo chmod a+rx /usr/local/bin/xPL_Hub
Code: Select all
/usr/local/bin/./xPL_Hub &
d. Install the pmaxd application. Pmaxd is developed by viknet, see http://www.domoticaforum.eu/viewtopic.p ... 52&start=0
Code: Select all
git clone https://github.com/viknet365/pmaxd.git
First jump to the pmaxd directory ;
Code: Select all
cd /pmaxd
Code: Select all
# build helloworld executable when user executes "make"
CFLAGS += -I $(SRCDIR)/FLU $(OPTIMIZE) $(DEBUG) -fsigned-char
LDFLAGS += -fsigned-char
CC = $(CROSS_COMPILE)gcc
all: pmaxd xplsendjson jsongetxplstate testpmaxd
install: pmaxd xplsendjson jsongetxplstate testpmaxd
cp -f pmaxd /usr/bin/pmaxd
cp -f testpmaxd /usr/testpmaxd
cp -f xplsendjson.cgi /usr/lib/cgi-bin/xplsendjson.cgi
cp -f jsongetxplstate.cgi /usr/lib/cgi-bin/jsongetxplstate.cgi
pmaxd: pmaxd.o
$(CC) $(LDFLAGS) pmaxd.o -o pmaxd -lxPL -lconfig
pmaxd.o: pmaxd.c
$(CC) $(CFLAGS) -c pmaxd.c
xplsendjson: xplsendjson.o
$(CC) $(LDFLAGS) xplsendjson.o -o xplsendjson.cgi -lxPL
xplsendjson.o: xplsendjson.c
$(CC) $(CFLAGS) -c xplsendjson.c
jsongetxplstate: jsongetxplstate.o
$(CC) $(LDFLAGS) jsongetxplstate.o -o jsongetxplstate.cgi -lxPL
jsongetxplstate.o: jsongetxplstate.c
$(CC) $(CFLAGS) -c jsongetxplstate.c
testpmaxd: testpmaxd.o
$(CC) $(LDFLAGS) testpmaxd.o -o testpmaxd -lxPL -lconfig
testpmaxd.o: testpmaxd.c
$(CC) $(CFLAGS) -c testpmaxd.c
# remove object files and executable when user executes "make clean"
clean:
rm *.o pmaxd testpmaxd xplsendjson.cgi jsongetxplstate.cgi
Code: Select all
make
Code: Select all
gcc -I /FLU -fsigned-char -c pmaxd.c
pmaxd.c:299:6: warning: conflicting types for ‘serialHandler’
void serialHandler() {
^
In file included from pmaxd.c:23:0:
pmaxd-xpl.c:44:7: note: previous implicit declaration of ‘serialHandler’ was here
serialHandler();
^
pmaxd.c:335:6: warning: conflicting types for ‘packetManager’
void packetManager(struct PlinkBuffer * commandBuffer) {
^
pmaxd.c:327:9: note: previous implicit declaration of ‘packetManager’ was here
packetManager(&commandBuffer);
^
gcc -fsigned-char pmaxd.o -o pmaxd -lxPL -lconfig
gcc -I /FLU -fsigned-char -c xplsendjson.c
gcc -fsigned-char xplsendjson.o -o xplsendjson.cgi -lxPL
gcc -I /FLU -fsigned-char -c jsongetxplstate.c
gcc -fsigned-char jsongetxplstate.o -o jsongetxplstate.cgi -lxPL
gcc -I /FLU -fsigned-char -c testpmaxd.c
gcc -fsigned-char testpmaxd.o -o testpmaxd -lxPL -lconfig
Code: Select all
sudo cp pmaxd.conf /etc
Code: Select all
# authenticator
usercode=0x1234;
device = ["/dev/ttyUSB1", "/dev/ttyUSB0"]; // Use more than 2
zonename = ["Woonkamer", "Eetkamer", "2e Etage", "Slaapkamer"]; // Use more than 2
restartscript = "/etc/restart.sh";
packet_timeout = 2000;
Time to test pmaxd
Run pmaxd by issuing the following; you should see something similar as below
./pmaxd -fvvvvvvvv
Code: Select all
pi@raspberrypi:/home/pi/pmaxd$ ./pmaxd -fvvvvvvv
NOTICE: [Tue Mar 22 23:10:25 2016 initLog:0058]Logging initialized
NOTICE: [Tue Mar 22 23:10:25 2016 initLog:0059]Verbose level: 7
NOTICE: [Tue Mar 22 23:10:25 2016 main:0412]Program started by User x
INFO: [Tue Mar 22 23:10:25 2016 main:0414]setting SID
NOTICE: [Tue Mar 22 23:10:25 2016 main:0446]Starting......
INFO: [Tue Mar 22 23:10:25 2016 initSerialPort:0069]there are 2 device in your config file
INFO: [Tue Mar 22 23:10:25 2016 initSerialPort:0082]opening /dev/ttyUSB0
I have 4 zone:
NOTICE: [Tue Mar 22 23:10:25 2016 PmaxInit:0162]zone: 0, name: Woonkamer
NOTICE: [Tue Mar 22 23:10:25 2016 PmaxInit:0162]zone: 1, name: Slaapkamer
NOTICE: [Tue Mar 22 23:10:25 2016 PmaxInit:0162]zone: 2, name: 2e Etage
NOTICE: [Tue Mar 22 23:10:25 2016 PmaxInit:0162]zone: 3, name: Eetkamer
DEBUG: [Tue Mar 22 23:10:25 2016 sendBuffer:0171]Sending the following buffer to serial TTY
DEBUG: [Tue Mar 22 23:10:25 2016 logBuffer:0154]BufferSize: 12
DEBUG: [Tue Mar 22 23:10:25 2016 logBuffer:0155]Buffer: A2 00 00 00 00 00 00 00 00 00 00 43
DEBUG: [Tue Mar 22 23:10:25 2016 calculChecksum:0164]checksum: 001A
DEBUG: [Tue Mar 22 23:10:25 2016 sendBuffer:0180]result of serial write:: 15
DEBUG: [Tue Mar 22 23:10:25 2016 sendBuffer:0171]Sending the following buffer to serial TTY
DEBUG: [Tue Mar 22 23:10:25 2016 logBuffer:0154]BufferSize: 12
DEBUG: [Tue Mar 22 23:10:25 2016 logBuffer:0155]Buffer: AB 06 00 00 00 00 00 00 00 00 00 43
DEBUG: [Tue Mar 22 23:10:25 2016 calculChecksum:0164]checksum: 000B
DEBUG: [Tue Mar 22 23:10:25 2016 sendBuffer:0180]result of serial write:: 15
DEBUG: [Tue Mar 22 23:10:25 2016 main:0453]Sarting main loop....
DEBUG: [Tue Mar 22 23:10:26 2016 packetManager:0336]Timeout while waiting packet: assumig packet is complete......
DEBUG: [Tue Mar 22 23:10:26 2016 calculChecksum:0164]checksum: 00EF
ERR: [Tue Mar 22 23:10:26 2016 deFormatBuffer:0200]checksum NOK calculated:00EF in packet:0000
ERR: [Tue Mar 22 23:10:26 2016 packetManager:0356]Packet not correctly formated
DEBUG: [Tue Mar 22 23:10:26 2016 logBuffer:0154]BufferSize: 44
ERR: [Tue Mar 22 23:10:26 2016 logBuffer:0155]Buffer: A5 0D 01 00 00 00 00 00 00 00 00 43 09 0A 0D 02 43 BA 0A 0D A5 0D 01 00 00 00 00 00 00 00 00 43 09 0A 0D 02 43 BA 0A 0D A5 0D 01 00
DEBUG: [Tue Mar 22 23:10:26 2016 packetManager:0363]End of packet treatment
DEBUG: [Tue Mar 22 23:10:40 2016 packetManager:0336]Timeout while waiting packet: assumig packet is complete......
DEBUG: [Tue Mar 22 23:10:40 2016 calculChecksum:0164]checksum: 0009
DEBUG: [Tue Mar 22 23:10:40 2016 deFormatBuffer:0196[b]]checksum OK[/b]
DEBUG: [Tue Mar 22 23:10:40 2016 packetManager:0338]Packet received
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0154]BufferSize: 12
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0155]Buffer: A5 0D 01 00 00 00 00 00 00 00 00 43
INFO: [Tue Mar 22 23:10:40 2016 packetManager:0350]Packet not recognized
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0154]BufferSize: 12
INFO: [Tue Mar 22 23:10:40 2016 logBuffer:0155]Buffer: A5 0D 01 00 00 00 00 00 00 00 00 43
DEBUG: [Tue Mar 22 23:10:40 2016 sendBuffer:0171]Sending the following buffer to serial TTY
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0154]BufferSize: 2
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0155]Buffer: 02 43
DEBUG: [Tue Mar 22 23:10:40 2016 calculChecksum:0164]checksum: 00BA
DEBUG: [Tue Mar 22 23:10:40 2016 sendBuffer:0180]result of serial write:: 5
DEBUG: [Tue Mar 22 23:10:40 2016 packetManager:0363]End of packet treatment
DEBUG: [Tue Mar 22 23:10:40 2016 packetManager:0336]Timeout while waiting packet: assumig packet is complete......
DEBUG: [Tue Mar 22 23:10:40 2016 calculChecksum:0164]checksum: 0008
DEBUG: [Tue Mar 22 23:10:40 2016 deFormatBuffer:0196][b]checksum OK[/b]
DEBUG: [Tue Mar 22 23:10:40 2016 packetManager:0338]Packet received
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0154]BufferSize: 12
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0155]Buffer: A5 0D 02 00 00 00 00 00 00 00 00 43
DEBUG: [Tue Mar 22 23:10:40 2016 findCommand:0226]Command find !!!!
DEBUG: [Tue Mar 22 23:10:40 2016 sendBuffer:0171]Sending the following buffer to serial TTY
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0154]BufferSize: 2
DEBUG: [Tue Mar 22 23:10:40 2016 logBuffer:0155]Buffer: 02 43
DEBUG: [Tue Mar 22 23:10:40 2016 calculChecksum:0164]checksum: 00BA
DEBUG: [Tue Mar 22 23:10:40 2016 sendBuffer:0180]result of serial write:: 5
INFO: [Tue Mar 22 23:10:40 2016 PmaxStatusUpdateZoneBat:0406]Status Update : Zone state/Battery
If you have also the checksum OK as above, you can do the following to arm and disarm the alarmsystem;
a
for Arm
d
for disarm
g
to get the log
The command is case sensitive.
e. Next, install Apache2
Since the pmaxd application needs to communicate with a webserver to run a few cgi scripts, Apache 2 is required.
Code: Select all
sudo apt-get install apache2 -y
Code: Select all
cd pmaxd/www
ls -l
sudo cp *.* /var/www/html
cd ..
ls -l
sudo cp *.cgi /usr/lib/cgi-bin
Code: Select all
#!/bin/bash
echo -e "Content-type: text/html\n\n"
echo "<h1>Hello World</h1>"
Code: Select all
cd /usr/lib/cgi-bin
sudo nano hello.cgi
Code: Select all
sudo chmod +x /usr/lib/cgi-bin/hello.cgi
Code: Select all
sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
sudo service apache2 restart
Load the cgi file by loading the following url in your browser;
Code: Select all
http://ip/cgi-bin/hello.cgi
If that works you can try the following;
Change the following file (/etc/rc.local) to let the pmaxd start at reboot. Make sure that you insert the below before the line; exit 0
Code: Select all
/home/pi/pmaxd/./pmaxd &
After reboot reload the following url in your browser
Code: Select all
http://ip/cgi-bin/jsongetxplstate.cgi
{ "status":"disarmed","pmaxstatus":"disarmed","readytoarm":"","sensor":[{"zone":"Woonkamer","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"},{"zone":"Slaapkamer","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"},{"zone":"2e Etage","type":"perimeter","alert":"false","armed":"false","tamper":"false","low-battery":"false","alarm":"false"}]}
Also you can load the following website to arm and disarm the alarm. It's something to play around with. I won;t use this website, given that I want to integrate things in Domoticz;
Code: Select all
http://ip/alarm.html
a. Create a dummy switch with the name Visonic Alarm Status. Then copy past the below in a script_device_etc.lua script
Code: Select all
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local visonic=assert(io.popen('curl http://ip/cgi-bin/jsongetxplstate.cgi'))
local status = visonic:read('*all')
visonic:close()
local jsonStatus = json:decode(status)
local visonic_woonkamer = 'Visonic Alarm Status'
print("Eerste JSON stappen met LUA")
print(status)
powermaxstatus = jsonStatus['pmaxstatus']
commandArray = {}
print(powermaxstatus)
if (powermaxstatus == "disarmed" or powermaxstatus == "armed" or powermaxstatus == "armed-home" or powermaxstatus == "armed-away") then
if powermaxstatus == "disarmed" then
print('<font color="blue">Visonic: Het alarm staat uit</font>')
commandArray[visonic_woonkamer]='Off'
end
if (powermaxstatus == "armed" or powermaxstatus == "armed-home"or powermaxstatus == "armed-away") then
print('<font color="red">Visonic: Het alarm is ingeschakeld!</font>')
commandArray[visonic_woonkamer]='On'
end
end
return commandArray
Create 3 sh script with the following names, and contents. By the way, I have copied xPLSend from the /home/pi/xPLLib/examples directory to another raspiberry pi (the main server) to /home/pi/xPL directory. xPLSend will broadcast an xPL message accross the network, which the xPL Hub on the other pi will receive.
Level 10, called: Arm_Away
script:///home/pi/domoticz/scripts/visonic_alarm_arm_away.sh
Code: Select all
#!/bin/bash
/home/pi/xPL/xPLSend -c security.basic command=arm-away
script:///home/pi/domoticz/scripts/visonic_alarm_arm_home.sh
Code: Select all
#!/bin/bash
/home/pi/xPL/xPLSend -c security.basic command=arm-home
script:///home/pi/domoticz/scripts/visonic_alarm_disarm.sh
Code: Select all
#!/bin/bash
/home/pi/xPL/xPLSend -c security.basic command=disarm
That's all. Good luck