Can Blue Iris trigger a tcp command script?

Gimmons

Getting comfortable
Jan 7, 2022
302
451
California
I've been working on my triggers and alerts. First, I got Pushover notifications working with a curl script, then I got Shelly relays turning on my exterior lights when certain cameras trigger, via web requests (Thanks jaydeel and TonyR for the tutorials).

I have a cheap Chinese relay, SR-201, that takes commands over tcp or udp. It can't be controlled via http, but it will respond to telnet or ncat from the windows command line.

My question is whether Blue Iris allows me to send a tcp (or udp) command as a response to a trigger event. I tried replacing the Pushover curl script, sending an ncat command to the relay: Ncat [ip address] [port] < [address of file containing the relay 'on' command.] That didn't work, however.

Alternatively, can I call a powershell script?
 
  • Like
Reactions: mat200 and TonyR
Yes, you can execute powershell scripts from Blue Iris Run-a-program actions. Search for any of my utility posts for examples.

A key point with executing scripts this way is that the background environment is PowerShell 5.1, so if you develop/test the script in PS7, it may not work as expected. Both the powershell.exe and powershell ISE consoles run PS5.1, so always final test the script in one (or both) of them
 
Last edited:
  • Like
Reactions: mat200
I posed the question to ChatGPT. The response was affirmative - "though with some configuration".

Here's a link to the full response.
jaydeel! Thanks very much for putting me on the right path. I'm going to have to write this up properly, but the approach of running a batch file on the trigger event was the winning concept. The batch file contains the ncat command, which references the text file that contains the actual Relay On / Off command.
 
Last edited:
Here is the tl;dr on controlling an SR-201 relay under the trigger or alerts tabs in Blue Iris. I set this up as a pre-alert action set under the triggers tab. but it could be an action taken on alert.

There are three actions: Relay 1 On, Wait x time period, and Relay 1 Off. Here's the settings for Relay 1 On:
Screenshot 2025-05-05 132015.png
 
Last edited:
The file ncat_11.bat has the following content:

ncat 192.168.10.87 6722 <c:\users\.120\11.txt

The file 11.txt has the following content:

11

Transmitting 11 to the relay at 192.168.10.87 at port 6722 turns the relay on.

Turning the relay off requires the number 21 to be transmitted to the same address and port, so there is a text file called 21.txt that just contains the number 21. 21.txt is called by a file called ncat_21.bat, which has the same content as ncat_11.bat, but specifying 21.txt as the file to call.
 
Last edited: