Zoneminder Linked to Samsung SmartThings for alarm triggers
Posted: Mon Dec 14, 2020 6:29 am
For anyone that is interested in being able to trigger alarms to the camera from Samsung Smartthings, I found a fairly easy solution. TriggerCMD.
It’s a simple program that you install on a computer/server that is on you LAN and running 24/7, from it you can remotely run preconfigured commands. Well, considering that anyone that is running Zoneminder already has a system that runs 24/7, you can install TriggerCMD on the same machine, integrate it with Smartthings, and you are all set. I am sure you can get it to work with other smart home systems, but you are on your own on getting it to work with TriggerCMD, but it does also work with IFTTT, so that may be a solution for some as well.
Here is a step by step on how I was able to set it up.
I am sorry if I am being too detailed, but hopefully for some noobies like my self this will be helpful.
Step 1. Enabling triggers in ZM and verifing you are able to trigger an alarm from terminal.
Some of this is documented on ZM wiki but partially outdated: https://wiki.zoneminder.com/ZMTrigger
In ZM, under Options>System, enable “OPT_TRIGGERS” and click save.
Go into terminal and run the command:
This will restart ZM
Now confirm you have trigger service running with this command:
You should see an output that has “zmtrigger.pl” from the user “www-data”
This process will be listening on port 6802, so verify that as well with this command:
At this point you should be able to run this command in terminal and trigger an alarm:
This will trigger an alarm on camera ID1 | for 15 seconds | Alarm Score 99 | description | Camera Overlay text
Feel free to adjust according to your needs.
P.S. I am running my ZM in the docker container, (if you don’t know what docker is, or you know you don't have it, ignore this portions and move to the next step) so the checks above, I did them while inside the container it self. To log into your docker container run the command:
“Zoneminder” is the name of my container, yours mostlikely different.
You will also need to map the port 6802 from your host machine to docker container. Here is a good walkthrough for that: https://mybrainimage.wordpress.com/2017 ... container/
Once your docker is set up, verify your host machine is listening on port 6802 via same netstat command as above and try to trigger the alarm as well.
Step 2. Install TriggerCMD on your system.
Instructions for linux system are here: https://www.triggercmd.com/forum/topic/ ... structions
or do it on a windows/mac system by following their respective instructions on the website/forum.
Once you have TriggerCMD installed and running, right click on tray icon, select “GUI Command Editor” and “Add Command”. In the popup window, first field named “Trigger” is just the name of what you want to call it, (e.g. Door Trigger). Second is the “Command” you want to send to trigger camera alarm:
echo "1|on+15|99|External-Motion|Motion" | telnet 127.0.0.1 6802
Its the same command you used at the end of the first step.
If you are setting up TriggerCMD not on the same machine as your ZM, be sure to insert proper IP address.
Click “Save” and verify you are able to trigger the alarm by moving the mouse over the command you just created and clicking the green play button.
If all goes well, last thing to do is to link it to Smartthings or maybe some other hub via other means.
Step 3. Linking TriggerCMD to Smartthings will require logging into the Smartthings website and copy/paste a couple of pieces of code. Developer did an awesome job documenting this process so I will just link it here: https://www.triggercmd.com/forum/topic/ ... -a-command
The only thing I would suggest doing different is when you are creating a "My Device Handlers”, when you paste the code for the device and before you click create, find the string “// off()” and change it to “off()” - no quotes. This will create a momentary switch in Smartthings instead of a regular on/off switch. After that you can use this in any of your Automations, Rules, or Scenes, etc.
That is all.
I know it came out a bit lengthy, it's my first time writing a tutorial of this sort.
Hope it makes sense
It’s a simple program that you install on a computer/server that is on you LAN and running 24/7, from it you can remotely run preconfigured commands. Well, considering that anyone that is running Zoneminder already has a system that runs 24/7, you can install TriggerCMD on the same machine, integrate it with Smartthings, and you are all set. I am sure you can get it to work with other smart home systems, but you are on your own on getting it to work with TriggerCMD, but it does also work with IFTTT, so that may be a solution for some as well.
Here is a step by step on how I was able to set it up.
I am sorry if I am being too detailed, but hopefully for some noobies like my self this will be helpful.
Step 1. Enabling triggers in ZM and verifing you are able to trigger an alarm from terminal.
Some of this is documented on ZM wiki but partially outdated: https://wiki.zoneminder.com/ZMTrigger
In ZM, under Options>System, enable “OPT_TRIGGERS” and click save.
Go into terminal and run the command:
Code: Select all
service zoneminder restart
Now confirm you have trigger service running with this command:
Code: Select all
ps auxw | grep zmtrigger
This process will be listening on port 6802, so verify that as well with this command:
Code: Select all
netstat -tulpn | grep 6802
Code: Select all
echo "1|on+15|99|External Motion|External Motion" | telnet 127.0.0.1 6802
Feel free to adjust according to your needs.
P.S. I am running my ZM in the docker container, (if you don’t know what docker is, or you know you don't have it, ignore this portions and move to the next step) so the checks above, I did them while inside the container it self. To log into your docker container run the command:
Code: Select all
sudo docker exec -it Zoneminder bash
“Zoneminder” is the name of my container, yours mostlikely different.
You will also need to map the port 6802 from your host machine to docker container. Here is a good walkthrough for that: https://mybrainimage.wordpress.com/2017 ... container/
Once your docker is set up, verify your host machine is listening on port 6802 via same netstat command as above and try to trigger the alarm as well.
Step 2. Install TriggerCMD on your system.
Instructions for linux system are here: https://www.triggercmd.com/forum/topic/ ... structions
or do it on a windows/mac system by following their respective instructions on the website/forum.
Once you have TriggerCMD installed and running, right click on tray icon, select “GUI Command Editor” and “Add Command”. In the popup window, first field named “Trigger” is just the name of what you want to call it, (e.g. Door Trigger). Second is the “Command” you want to send to trigger camera alarm:
echo "1|on+15|99|External-Motion|Motion" | telnet 127.0.0.1 6802
Its the same command you used at the end of the first step.
If you are setting up TriggerCMD not on the same machine as your ZM, be sure to insert proper IP address.
Click “Save” and verify you are able to trigger the alarm by moving the mouse over the command you just created and clicking the green play button.
If all goes well, last thing to do is to link it to Smartthings or maybe some other hub via other means.
Step 3. Linking TriggerCMD to Smartthings will require logging into the Smartthings website and copy/paste a couple of pieces of code. Developer did an awesome job documenting this process so I will just link it here: https://www.triggercmd.com/forum/topic/ ... -a-command
The only thing I would suggest doing different is when you are creating a "My Device Handlers”, when you paste the code for the device and before you click create, find the string “// off()” and change it to “off()” - no quotes. This will create a momentary switch in Smartthings instead of a regular on/off switch. After that you can use this in any of your Automations, Rules, or Scenes, etc.
That is all.
I know it came out a bit lengthy, it's my first time writing a tutorial of this sort.
Hope it makes sense