Page 16 of 16

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Sun Feb 12, 2017 11:10 am
by jelleeelco
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!

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Thu Feb 16, 2017 9:16 pm
by ayasystems
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

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Tue Feb 21, 2017 4:03 pm
by jelleeelco
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

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Wed Feb 22, 2017 3:51 pm
by jelleeelco
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

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Wed Feb 22, 2017 6:09 pm
by jelleeelco
Hi,
Please disregard all my questions.... I have sorted it out. it was easy, needed the port in the json statement.

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Mon Apr 17, 2017 12:49 pm
by clement
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

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Wed May 10, 2017 12:33 am
by clement
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

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Tue Aug 01, 2017 12:02 pm
by jelleeelco
@ayasystems Did anything change? I was running my system without issues, and suddenly the connection between the visonic and the raspberrry pi is lost. I checked everything...attaching the visonic to a windows pc and use the visonic driver works.

I reinstalled everything (different SD card), tried a different raspberry pi, no luck. It just keeps hanging at ' Sarting main loop" . How can I check what the 'broken component' is? I was thinking it would be xPLL_Hub, but how do I check that?

Thanks in advance!
Jelle

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Tue Aug 15, 2017 12:14 pm
by al30k
Hi, is it possible to "arm away" or "arm home" in instant mode with this app?
I use it with "arm home" at night, to make perimeter sensors around house work without "entry delay".

According this, PowerMax plugin for Vera can do it and use same interface, http://code.mios.com/trac/mios_visonic-powermax

thanks.

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Wed Nov 01, 2017 3:58 pm
by doff
viknet wrote:hello all,

I had trouble finding the pinout of the powermax pro (without buying any cable), so with the help of a multimeter and a usb to 3.3V serial TTL adapter (such as this one cgi.ebay.fr/2pcs-USB-2-0-to-TTL-UART-6P ... 3a6f4cc144 but others from arduino/spakfun/adafruit will work) I found these information

I can confirm the pinout because I manage to link a PC using http://realterm.sourceforge.net/ and such a cable I manually calculated a checksum and manage to do the enrolement process.

for the posterity, please find attached two picture of the serial port, with your protocol the serial pinout and a small router such as this one TP-Link TL-WR703N
http://wiki.openwrt.org/toh/tp-link/tl-wr703n you can easily recreate yourself a free (not as in beer) powerlink.

Best regards

Viknet

P.S.
By the way hello to all of domoticaforum user and a big thanks to Rene for describing the protocol

P.S 2
for those too lazy for registering to view the pictures, the port is a 10pin header labeled PC /IP the pinout is described below :

Code: Select all

_______________________________
|?0V   GND  TX   RX     3.75V |
|?0V   ?3V    ?0V  GND  3.75V |
-------------------------------
             PC / IP

Hello,
I know this is somehow restarting from an old post, but this is the only place I've found the information.
Thanks a lot for the pinout, this is exactly what I've been looking for....
I mean, almost.
I've purchased an RS-232-T device, in order to acheive this, as I knew there was a PC/IP connector in max powermax box.
But, yesterday, I was stuck opening it. The PC/IP is now just an IP labelled connector, and the powerlink IP module is attached to it.
And I cannot plug in anything.
I've got a powermax-33 G2, and I'd like to wire this serial interface.
I've also noticed that, there are 2 RJ11 connectors : one is labeled "line" where the telephone line is plugged in, and the other one is labelled "SET".
Would this port be a serial one ? where I could plug my RS-232-T device ?
thanks

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Thu Nov 02, 2017 8:55 am
by doff
Ooops, sincere apologies, my box is a PowerMaster-33 G2, not a powermax.

Re: Powerlink serial pinout, linux daemon and web interface

Posted: Sun May 03, 2020 11:44 am
by swedishcook
Thanks for the work in this thread, I've been installing to a Raspberry pi using instructions here domoticz.com/forum/viewtopic.php?f=38&a ... f0ac945853, based on your work. On Raspberry pi it appears that the following two lines in pmaxd.c are causing an issue, with the second line reseting bits set by the first, I'm not sure if it affects any other platforms (if it had then I expect someone would have spotted it by now). On Raspberry Pi the nett effect of the two lines seems to be to enable CS5 rather than CS8 operation and communication with the panel fails.

These are the lines I needed to swap to get pmaxd to work for me :
options.c_cflag |= (CLOCAL | CREAD | CS8 );
options.c_cflag &= ~(PARENB | CSTOPB | CSIZE);