Powerlink serial pinout, linux daemon and web interface

Forum about Visonic products like Powermax Plus and Powermax Pro

Moderators: Rene, Willem4ever

Re: Powerlink serial pinout, linux daemon and web interface

Postby jelleeelco » Sun Feb 12, 2017 10:10 am

Hi,

Thank you. This will point me in the right direction. Just a few questions on the code in your example if you don't mind.

if [ $1 = "4" ]; then #Puerta

So do I understand correctly that in your example $1 is done 1 (in your case called "Puerta"), and status "4" means zone Open?

Would you mind letting me know what the other statuses are? Or how I can find them out?
Many thanks for all your work!
jelleeelco
Starting Member
Starting Member
 
Posts: 7
Joined: June 2011

Re: Powerlink serial pinout, linux daemon and web interface

Postby ayasystems » Thu Feb 16, 2017 8:16 pm

Hi Jelleeelco

Example of alarm script (The scripts are in spanish but i think you can understand )

Code: Select all
#!/bin/sh

NOW=$(date +"%d/%m/%Y %H:%M")

EMAIL="To: xxxxx@gmail.com
Subject: ALARMA - Alarma $NOW

ALARMA ALARMA ALARMA
====== ====== ======
ALARMA ALARMA ALARMA
====== ====== ======.

$NOW"

echo "$EMAIL" | sendmail -t


EXAMPLE OF BATTERY LOW
Code: Select all
#!/bin/sh
NOW=$(date +"%d/%m/%Y %H:%M")
EMAIL="To: XXXX@GMAIL.COM
Subject: ALARMA - Batería zona $1 baja  $NOW

Batería zona $1 baja, compruebe el estado por favor."

echo "$EMAIL" | sendmail -t



ZONE CLOSE
Code: Select all
#!/bin/sh

NOW=$(date +"%d/%m/%Y %H:%M")

if [ $1 = "4" ]; then #Puerta

EMAIL="To: xxx@gmail.com
Subject: ALARMA - Zona Puerta cerrada $NOW

Zona Puerta cerrada
$NOW
"

echo "$EMAIL" | sendmail -t

#  Notify to my domotic system (Domoticz)
    wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=28&switchcmd=Off" &> /dev/null
fi



EXAMPLE OF ZONE EVENT (I use this kind of event to notify to my domotic system when PIR detects movement)

Code: Select all
#!/bin/sh
#Enviar evento a domoticz


#zonename = ["Entrada", "Salon", "Dormitorios", "Puerta","Garaje"];

if [ $1 = "1" ]; then #Entrada
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=29&switchcmd=On"  &> /dev/null
   sleep 5
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=29&switchcmd=Off"   &> /dev/null
fi

if [ $1 = "2" ]; then #Salon
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=35&switchcmd=On"  &> /dev/null
   sleep 5
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=35&switchcmd=Off" &> /dev/null
fi

if [ $1 = "3" ]; then #Dormitorios
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=36&switchcmd=On"  &> /dev/null
   sleep 5
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=36&switchcmd=Off" &> /dev/null 
fi

#if [ $1 = "4" ]; then#Puerta
#   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=29&switchcmd=On" &> /dev/null
#   sleep 5
#   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=29&switchcmd=Off" &> /dev/null
#fi

if [ $1 = "5" ]; then #Garaje
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=37&switchcmd=On"  &> /dev/null
   sleep 5
   wget -qO- "http://192.168.3.241/json.htm?type=command&param=switchlight&idx=37&switchcmd=Off"  &> /dev/null
fi



Do you need more details?


Regards
ayasystems
Starting Member
Starting Member
 
Posts: 39
Joined: May 2014

Re: Powerlink serial pinout, linux daemon and web interface

Postby jelleeelco » Tue Feb 21, 2017 3:03 pm

Hi Ayasystems,

Apologies for late reply - this is fantastic! I'll play with these and see how it works. Especially the PIR going to domotic is fantastic!

I'll report back!
Rgds and many thanks
Jelle
jelleeelco
Starting Member
Starting Member
 
Posts: 7
Joined: June 2011

Re: Powerlink serial pinout, linux daemon and web interface

Postby jelleeelco » Wed Feb 22, 2017 2:51 pm

Hi Ayasystems,

I struggle getting the scripts to work. I looked at ./pmaxd -fvvvvvvvvr and tested by opening a window (in my dining room, zone 5 " Eetkamer" ).
I noticed that it sometimes executes script zoneEvent, and sometimes zoneOpen... I can't find a logic as to why it choses which one.

I created two scripts in /etc/pmaxd and made them executable (by sudo chmod +x zoneOpen and sudo chmod +x zoneEvent).

zoneOpen
Code: Select all
#!/bin/sh

NOW=$(date +"%d/%m/%Y %H:%M")

if [ $1 = "5" ]; then #Eetkamer

EMAIL="To: jelleeelco.vanderploeg@gmail.com
Subject: LET OP - Zone Eetkamer is Open $NOW

Zone Eetkamer is Open
$NOW
"

echo "$EMAIL" | sendmail -t

#  Notify to my domotic system (Domoticz)
    wget -qO- "http://192.168.1.13/json.htm?type=command&param=switchlight&idx=96&switchcmd=On" &> /dev/null
fi


zoneEvent
Code: Select all
#!/bin/sh
#Visonic Motion Detector update domoticz


#zonename = ["Eetkamer"];

if [ $1 = "5" ]; then #Eetkamer
   wget -qO- "http://192.168.1.13/json.htm?type=command&param=switchlight&idx=96&switchcmd=On"  &> /dev/null
fi


I then created dummy hardware in Domoticz: " Visonic Eetkamer". I then created a light switch (on/off) using that hardware, and that has IDX 96.

So when the window opens, the system reports the following (status of pmax is disarmed):
Code: Select all
DEBUG: [Wed Feb 22 14:47:35 2017 sendBuffer:0183]result of serial write:: 5
NOTICE: [Wed Feb 22 14:47:35 2017 ExecuteScript:0182]Script /etc/pmaxd/zoneEvent 5  executed
INFO: [Wed Feb 22 14:47:35 2017 PmaxStatusUpdatePanel:0474]System status: disarmed   Flags : Alert-in-Memory Zone-event     Zone 5 Open
DEBUG: [Wed Feb 22 14:47:35 2017 packetManager:0366]End of packet treatment
DEBUG: [Wed Feb 22 14:47:35 2017 packetManager:0339]Timeout while waiting packet: assumig packet is complete......
DEBUG: [Wed Feb 22 14:47:35 2017 calculChecksum:0167]checksum: 0015
DEBUG: [Wed Feb 22 14:47:35 2017 deFormatBuffer:0199]checksum OK
DEBUG: [Wed Feb 22 14:47:35 2017 packetManager:0341]Packet received
DEBUG: [Wed Feb 22 14:47:35 2017 logBuffer:0157]BufferSize: 12
DEBUG: [Wed Feb 22 14:47:35 2017 logBuffer:0158]Buffer: A5 00 02 00 00 00 00 00 00 00 00 43
DEBUG: [Wed Feb 22 14:47:35 2017 findCommand:0229]Command find !!!!
DEBUG: [Wed Feb 22 14:47:35 2017 sendBuffer:0174]Sending the following buffer to serial TTY
DEBUG: [Wed Feb 22 14:47:35 2017 logBuffer:0157]BufferSize: 2
DEBUG: [Wed Feb 22 14:47:35 2017 logBuffer:0158]Buffer: 02 43
DEBUG: [Wed Feb 22 14:47:35 2017 calculChecksum:0167]checksum: 00BA
DEBUG: [Wed Feb 22 14:47:35 2017 sendBuffer:0183]result of serial write:: 5
NOTICE: [Wed Feb 22 14:47:35 2017 PmaxStatusUpdateZoneBat:0481]Status Update : Zone state/Battery
DEBUG: [Wed Feb 22 14:47:35 2017 packetManager:0366]End of packet treatment


and when it uses the zoneOpen:
Code: Select all
DEBUG: [Wed Feb 22 14:49:10 2017 sendBuffer:0174]Sending the following buffer to serial TTY
DEBUG: [Wed Feb 22 14:49:10 2017 logBuffer:0157]BufferSize: 2
DEBUG: [Wed Feb 22 14:49:10 2017 logBuffer:0158]Buffer: 02 43
DEBUG: [Wed Feb 22 14:49:10 2017 calculChecksum:0167]checksum: 00BA
DEBUG: [Wed Feb 22 14:49:10 2017 sendBuffer:0183]result of serial write:: 5
NOTICE: [Wed Feb 22 14:49:10 2017 PmaxStatusUpdateZoneBat:0481]Status Update : Zone state/Battery
INFO: [Wed Feb 22 14:49:10 2017 PmaxStatusUpdateZoneBat:0492]Zone 5 is open
NOTICE: [Wed Feb 22 14:49:10 2017 ExecuteScript:0182]Script /etc/pmaxd/zoneOpen 5 & executed
DEBUG: [Wed Feb 22 14:49:10 2017 packetManager:0366]End of packet treatment
/etc/pmaxd/zoneOpen: 14: /etc/pmaxd/zoneOpen: sendmail: not found


I guess the sendmail is a command I'm missing, but it shows that at least it runs the script. But no update to domoticz what-so-ever.

I'm lost! If you have any clue please let me know!

Rgds
Jelle
jelleeelco
Starting Member
Starting Member
 
Posts: 7
Joined: June 2011

Re: Powerlink serial pinout, linux daemon and web interface

Postby jelleeelco » Wed Feb 22, 2017 5:09 pm

Hi,
Please disregard all my questions.... I have sorted it out. it was easy, needed the port in the json statement.
jelleeelco
Starting Member
Starting Member
 
Posts: 7
Joined: June 2011

Re: Powerlink serial pinout, linux daemon and web interface

Postby clement » Mon Apr 17, 2017 11:49 am

Hi,
thanks a lot for your work, I've been using Viknet binary for years and just switched to the last one with real time alerting which works perfectly :)

I have a small request,
It would be nice to notify my home automation system as soon as the alarm is "arming-away" (which last 30s for me). I know where to edit the code (file pmax_constant.h line 404) but don't know how to compile the code.

Thanks,
Clement from France
clement
Starting Member
Starting Member
 
Posts: 8
Joined: June 2013

Re: Powerlink serial pinout, linux daemon and web interface

Postby clement » Tue May 09, 2017 11:33 pm

Hello,
I'm not so far from recompile the source code with the armingAway notification feature (previous post).

Here is where I am :

I downloaded the toolchain for TL-WR703N : http://downloads.openwrt.org/barrier_br ... .2.tar.bz2
Set some environments variables :
Code: Select all
export STAGING_DIR=/tmp/OpenWrt-Toolchain-ar71xx-for-mips_34kc-gcc-4.8-linaro_uClibc-0.9.33.2
export TOOLCHAIN_DIR=$STAGING_DIR/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2
export LDCFLAGS=$TOOLCHAIN_DIR/usr/lib
export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/usr/lib
export PATH=$TOOLCHAIN_DIR/bin:$PATH


Ran make with CC argument :
Code: Select all
ubuntu@clem:/tmp/pmaxd$ make CC=mips-openwrt-linux-uclibc-gcc LD=mips-openwrt-linux-uclibc-ld
mips-openwrt-linux-uclibc-gcc  pmaxd.o -o pmaxd -lxPL -lconfig
/tmp/OpenWrt-Toolchain-ar71xx-for-mips_34kc-gcc-4.8-linaro_uClibc-0.9.33.2/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lxPL
/tmp/OpenWrt-Toolchain-ar71xx-for-mips_34kc-gcc-4.8-linaro_uClibc-0.9.33.2/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: cannot find -lconfig
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'pmaxd' failed
make: *** [pmaxd] Error 1
ubuntu@clem:/tmp/pmaxd$


I'm stuck at cannot find -lxPL
This is probably because mips-openwrt-linux-uclibc-gcc cannot find the flagged library or maybe because I didn't cross-compiled them...?

How did you compiled the code for the TP-Link @viknet @ayasystems ?
Thanks
clement
Starting Member
Starting Member
 
Posts: 8
Joined: June 2013

Previous

Return to Visonic Alarm systems

Who is online

Users browsing this forum: No registered users and 1 guest