DSC/Envisalink integration
Posted: Wednesday 20 August 2014 16:47
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 :)
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 :)