DSC/Envisalink integration

Moderator: leecollings

prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

DSC/Envisalink integration

Post by prozzerg »

Hi,

This is a script I use as some sort of "middleware" to send events from my alarm system to domoticz. It's written in Perl and you have to have it running, so running it inside a screen is probably a good idea :)
You need some basic perl modules (included in ubuntu) and Mojolicious, see http://mojolicio.us/ for more information.
You need to create dummy devices in Domoticz and know the IDX for these devices.

In the top of the script you have to define your envisalink device and your domoticz server. You also need to map the zones in your alarm to the IDX in domoticz.

This is probably not the best way to do the integration and far from good looking code, but it works for me.

If you find any problem, please report them.

-- Update
As my first post lacked alot of information about how to get it running, here comes some quick steps:
1. Install the basic things needed (done via ssh):
sudo apt-get install libdatetime-perl libdatetime-format-strptime-perl libwww-perl libjson-perl build-essential curl screen

2. Install Mojolicious (done via ssh):
sudo -s
curl get.mojolicio.us | sh
exit

3. Create the virtual devices in Domoticz:
Click "Setup" in the main menu and click "Hardware"
In the "Type" dropdown, select "Dummy (Does nothing, used for virtual switches only)"
Enter a name on your virtual hardware, example: Alarm
Press the "Add" button
In the main meny, click "Switches" and then "Manual Light/Switch" to add a new virtual switch
In the popup, select your newly created virtual hardware.
Enter a name on the switch, example: Zone 1.
Select "Switch Type" of device. For motion sensors I use the type "Motion sensor" and for magnet contacts I use "On/Off".
For the rest of the options, select what you feel right. I don't think it matters.

4. Write down the Idx of each of your virtual devices (or Zones, if you wish to call them that)
Click "Setup" in the main meny and click "Devices"
You now have a table of all your devices. The first column contains the Idx of all the devices. Write these down, as you need them for the script.

5. Set up the script (done via ssh):
Open the script with nano; nano -w envisalink_domoticz.pl
Go down to the section/comment "information about the Envisalink module"
Edit the 3 lines below it, with your envisalink password, ip and port
After the Envisalink information you can toggle the debug flag. If it is set to 1, it enables debug, and 0 disables it.
The next section of the script is the information about your Domoticz installation. Please enter the IP to Domoticz and the HTTP port used. The default port is 8080
Next up is the mapping of zones to idx'es. From the previous steps you have your Idxes and I suppose you know the number of your alarm zones in your dsc setup.
The script comes with 11 zones defined, if you have more zones you just add them and if you have less you remove some of them.
The format is "'<zone id>' => <idx>"
Example; if your zone 1 got the idx 102, then set it like this; '001' => 102
When done, press ctrl+x and choose to save the file. This will also close nano

6. Run the script in a screen (done via ssh):
Start a new screen with the name envisalink; "screen -mS envisalink"
Start the script; perl envisalink_domoticz.pl
Detach the screen by pressing; ctrl+a+d
If you later want to return to the screen, attach it by running this command; screen -dr envisalink

7. Check that the virtual switches changes state in Domoticz when you move around or open a door.


Hopefully this will help you guys getting started with the script :)
Attachments
envisalink_domoticz-v1.0.zip
(3.32 KiB) Downloaded 402 times
Last edited by prozzerg on Thursday 21 August 2014 20:53, edited 1 time in total.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

This is great news!

I'm not sure exactly where to start though..... Any chance you could list down some install instructions for someone running it using the Raspberry Pi SD Image?
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:This is great news!

I'm not sure exactly where to start though..... Any chance you could list down some install instructions for someone running it using the Raspberry Pi SD Image?
I've updated my original post with some installation instructions. Please report back if you need any more information.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Holy Cow!!!! It works!!!

Being that I barely know what I'm doing your instructions were perfect and worked first time without any issues! Fantastic....

I'm not sure I understand the whole concept of "Screens" but I suspect that with what you've documented I'd have to start a new "screen" manually if the raspberry pi ever rebooted?

I'm still a little new to Domoticz too so excuse this dumb question.... I sort of assumed that my Motion Sensor virtual switch would change in the UI once it detected movement, but I didn't see anything happen, although if I click on the log I can see it going on and off as expected in the chart... Maybe it just goes on and off too quickly to register in the domoticz UI?
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:Holy Cow!!!! It works!!!

Being that I barely know what I'm doing your instructions were perfect and worked first time without any issues! Fantastic....

I'm not sure I understand the whole concept of "Screens" but I suspect that with what you've documented I'd have to start a new "screen" manually if the raspberry pi ever rebooted?

I'm still a little new to Domoticz too so excuse this dumb question.... I sort of assumed that my Motion Sensor virtual switch would change in the UI once it detected movement, but I didn't see anything happen, although if I click on the log I can see it going on and off as expected in the chart... Maybe it just goes on and off too quickly to register in the domoticz UI?
A screen is a "virtual terminal" where you can run programs that you want to continue to run even when you have logged off your system.
And yes, when you reboot your raspberry pi you have to start a new screen. This is probably fixable with a startup script.

If you have any magnet contacts in your alarm system, open one of those zones and you should see the change. Motion sensors change the state pretty fast.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Some sort of start up script would be great!

I don't have any magnetic contacts but I'm pretty sure its possible to extend the "activated" time within the DSC alarm so I'll look into that.

Just watching the SSH screen I'm amazed how quickly your utility talks to the envisalink board.... Are you just constantly polling it?
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:Some sort of start up script would be great!

I don't have any magnetic contacts but I'm pretty sure its possible to extend the "activated" time within the DSC alarm so I'll look into that.

Just watching the SSH screen I'm amazed how quickly your utility talks to the envisalink board.... Are you just constantly polling it?
The Envisalink board got a TPI (Third Party Interface) that you can connect to and that is what the script does. When a client is connected to the TPI the Envisalink board sends everything that happens to that client. So no polling, just an active stream of data directly from the Envisalink.

For those of you who are interested in the TPI interface, Eyez-on have documentation of it here: http://forum.eyez-on.com/FORUM/viewtopic.php?f=6&t=301
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Have you considered how to show a virtual switch for when the whole system is armed or not? Good for activating something when you get home and disarm the alarm.
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:Have you considered how to show a virtual switch for when the whole system is armed or not? Good for activating something when you get home and disarm the alarm.
That's coming in version 1.1 :)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: DSC/Envisalink integration

Post by Derik »

What hardware do in need?
And some one have a demo login or something?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

Derik wrote:What hardware do in need?
And some one have a demo login or something?
The hardware se use (beside the DSC alarm system) is this ethernet module: http://www.eyezon.com/?page_id=176
I don't think a demo login will do much good, as all you can see is virtual switches turning on and off in Domoticz.

The current state if the script makes it possible to do things based on events from the alarm system, the same way you do other things with Blockly.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Okay so I've had my alarm talking to Domoticz on the Raspberry Pi for over a week now and I've noticed a real slow down when you look at the log of each sensor. Some of them have over 18000 log entries so I guess this is what is slowing it down.

Is there any way to purge log entries for a certain sensor after x days?

At the moment the graph on the log just jumps from 0 to 100 each time the sensor is tripped. I think it'd be useful to also see a chart showing the number of trips per hour or day. One day when I get some central heating installed and hooked up I'd love to intelligently heat rooms based on how much they've been used recently, I think these sensors could give me that data. But I'm still too much of a newbie to conceptualize how I'd get this working :-)
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Do you think it will be feasibly to startup the screen and run your script using the "rc.local" startup script that is launched when the raspberry pi starts up?
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

@prozzerg

Hey! Any more thoughts on how we can make this great plugin/script start up automatically every time the Raspberry Bi starts up?
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:@prozzerg

Hey! Any more thoughts on how we can make this great plugin/script start up automatically every time the Raspberry Bi starts up?
Hi,

sorry for taking nearly 2 months to answer this. I've had alot to do lately and as Domoticz doesn't support (and probably never will) support the MySensors project I have replaced it with Ago Control.

Anyhow, to start it at boot, i would add it as a cronjob as a @reboot command.
Login as your user and start the cronjob editor;

Code: Select all

crontab -e
You will probably get a regular nano editor.
Add this:

Code: Select all

@reboot screen -mS <screenname> /path/to/the/script
Close and save.

Test it by rebooting.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Cool, thanks will give that a try....

Sad to see you have moved on from Domoticz because that means you won't be adding to your cool DSC Alarm script anymore :-)

What are your thoughts on Ago Control... I haven't tried it because it doesn;t even have any screenshots to show what it looks like etc.... Might install it on a different SD card because I am also interested in the MySensors integration.
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Okay have given this a try but it doesn't seem to be working....

I've tried adding both of the lines below to the "crontab" but it just doesn't seem to be running after a reboot...

@reboot screen -mS EnvisaLink /home/pi/envisalink_domoticz.pl

and

@reboot screen -mS EnvisaLink perl /home/pi/envisalink_domoticz.pl

Any sort of logs or something I could check?
prozzerg
Posts: 8
Joined: Wednesday 20 August 2014 16:05
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by prozzerg »

tommysharp wrote:Okay have given this a try but it doesn't seem to be working....

I've tried adding both of the lines below to the "crontab" but it just doesn't seem to be running after a reboot...

@reboot screen -mS EnvisaLink /home/pi/envisalink_domoticz.pl

and

@reboot screen -mS EnvisaLink perl /home/pi/envisalink_domoticz.pl

Any sort of logs or something I could check?
I might was a big quick on that one and forgot that you need the -d parameter to screen (detached). So, please try this instead:
@reboot screen -d -m -S EnvisaLink /home/pi/envisalink_domoticz.pl
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

Still no luck I'm afraid.... No idea what I'm doing really...

This is what I've added to my crontab..

@reboot screen -d -m -S EnvisaLink /home/pi/envisalink_domoticz.pl &>/tmp/tommy.log

The bit on the end was some stuff google told me to add to try and log any errors, it creates the log file but it's empty....
tommysharp
Posts: 33
Joined: Thursday 05 June 2014 13:09
Target OS: Linux
Domoticz version:
Contact:

Re: DSC/Envisalink integration

Post by tommysharp »

I don't suppose anyone is able to help me with getting this script to run automatically when my Raspberry Pi reboots?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests