TRIGGERcmd and telnet
-
Is it possible to send telnet commands via TRIGGERcmd from local Linux machine to somewhere on the LAN? I am trying to integrate Smartthings and ZoneMinder. Basically when a contract sensor is open (front door), to send a command to ZoneMinder to start a camera recording that is facing the door. Zoneminder can receive commands via telnet. But I'm having a hard time finding anything that integrates with with Smartthings and able to communicate via telnet to link both systems together. Smartthings does not communicate over telnet (wouldn't that be awesome). And other cloud services like IFTTT, do not support it either. Plus I didn't want to open a telnet port into my network from outside, that's just asking for someone to "walk in". TRIGGERcmd seems like a perfect solution, if it supports telnet. Zoneminder has a wiki explaining how it is able to receive triggers here but basically send a telnet session to a specific ipaddress and port, and after that a string of text.
-
@hlywine, the site you linked to shows you could use a command like this:
echo "1|show||||testingOSD" | telnet ipaddress 6802
1|show||||testingOSD is the text you'd be sending to ZoneMinder via telnet.
-
@Russ Thanks for your reply. I saw the command but I guess my problem is, I don't know what to do with it. (I don't know how to code and currently trying to learn Linux, I'm a network guy) I figured I would have to write like a short bash script to open telnet and pass that string to the telnet session. And then setup triggerCMD to run the bash scrip when triggered via Smartthings. Am I thinking of this correct or is there an easier way to open telnet and pass info to it via triggerCMD?
-
@hlywine, I think you should be able to use this command directly, although of course you'll want to replace "ipaddress" with the actual IP address, and 6802 with the actual port.
echo "1|show||||testingOSD" | telnet ipaddress 6802
You could also create a bash script like this, but I don't think you'd have to:
#!/bin/bash echo "1|show||||testingOSD" | telnet ipaddress 6802
If you do you a script, you'll also want to make it executable like this:
chmod +x ./yourscript.sh
In case you're editing your ~/.TRIGGERcmdData/commands.json file directly, this is the json entry you could use. It includes the \ (backslash) for each quote:
{ "trigger": "Show testing OSD", "command": "echo \"1|show||||testingOSD\" | telnet ipaddress 6802", "offCommand": "", "ground": "foreground", "voice": "test", "voiceReply": "", "allowParams": "false" }
That command is really two commands with a pipe between them. Linux allows you to "pipe" the output of one command to the input of another command.
If you run this command:
echo "1|show||||testingOSD"
Your output will be:
1|show||||testingOSD
If you run this command:
telnet ipaddress 6802
It will just telnet to the ip address on port 6802 and wait for your input.
If you pipe the output of the echo command to the input of the telnet command, your ZoneMinder telnet server will receive this:
1|show||||testingOSD
-
@Russ Thank you so much. You are my hero! I have been wanting to link those two systems for ages and I finally got it. I'll also be creating a tutorial on Zoneminder forum on how to go through all the steps and do what I did and I'll be linking to a few different parts of the forum for reference. Hopefully bring more attention to such an awesome system that you have created. I believe TriggerCMD and Zoneminder can be friends and help each other out.
-
@hlywine, that's awesome! Thank you!