Blue Iris camera trigger from smart things

Maybe? Modify the code to test it without the user/pass details and let us know what happens! Follow the logging for the application instance to see what it’s calling, the app is setup to print the URL it’s attempting to reach to the logs in a pretty readable manner.

Its sending this (showing it in the log):
9:18:09 AM: debug sending GET to URL http://host.domain.com:81/cam/CameraName/pos=9
but nothing happens (I changed the internal FQDN name and camera name in the string above from my actual ones).

If I copy and paste the exact url to my browser window, the PTZ preset works. I also tried using the IP address instead of the FQDN.

@luma, Blue Iris is logging the Anonymous (local) login from both smartthings hub and the pc that I’m testing from by going to the same url in a browser…

The trouble with using your browser to test these commands is that it saves cookies and authentication. Can you try with WGET or cURL?

@luma It worked via command line using wget. I had already tried using incognito, which worked as well. Blue Iris logged both connections as anonymous as expected.

@luma
I replaced: def biRawCommand = "cam/${settings.biCamera}/pos=${settings.biPreset}"
with
def biRawCommand = "cam/ShortCamName/pos=9"
to remove any possibility that my strings were messed up and ran it through the IDE simulator using a virtual motion. It logs into my BI server as anonymous (BI shows me the IP of the hub) when I tell the virtual motion to “see motion”, logging from the IDE shows:
4899d99c-7abe-4697-a409-55a999990b1c 1:53:58 PM: debug sending GET to URL http://192.168.1.100:81/cam/ShortCamName/pos=8
(I changed the ids, ips, and cam names on this post to fake ones)

Yet, it doesn’t work… could it be the httpMethod?

Below is how I’ve edited your script so far:

definition(
name: “Send a Preset to Blue Iris”,
namespace: “aderusha”,
author: “aderusha”,
description: “Trigger Blue Iris camera preset in response to SmartThings events”,
category: “Convenience”,
iconUrl: “https://raw.githubusercontent.com/aderusha/SmartThings/master/resources/BlueIris_logo.png”,
iconX2Url: “https://raw.githubusercontent.com/aderusha/SmartThings/master/resources/BlueIris_logo%402x.png
)

preferences {
section(“Blue Iris server details”){
input “biServer”, “text”, title: “Server”, description: “Blue Iris web server IP”, required: true
input “biPort”, “number”, title: “Port”, description: “Blue Iris web server port”, required: true
input “biPreset”, “number”, title: “Preset#”, description: “7+preset number”, required: true
}
section(“Blue Iris Camera Name”){
input “biCamera”, “text”, title: “Camera Name”, required: true
}
section(“Select events to be sent to Blue Iris”){
input “myMotion”, “capability.motionSensor”, title: “Motion Sensors”, required: false, multiple: true
input “myContact”, “capability.contactSensor”, title: “Contact Sensors”, required: false, multiple: true
}
}

def installed() {
log.debug "Installed with settings: ${settings}"
subscribeToEvents()
}

def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribeToEvents()
}

def subscribeToEvents() {
subscribe(myMotion, “motion”, eventHandlerBinary)
subscribe(myContact, “contact”, eventHandlerBinary)
}

def eventHandlerBinary(evt) {
if ((evt.value == “active”) || (evt.value == “open”)) {
log.debug "processed event ${evt.name} from device ${evt.displayName} with value ${evt.value} and data ${evt.data}"
def biHost = "${settings.biServer}:${settings.biPort}"
def biRawCommand = "cam/${settings.biCamera}/pos=${settings.biPreset}"
log.debug "sending GET to URL http://$biHost/$biRawCommand"
def httpMethod = "GET"
def httpRequest = [
method: httpMethod,
path: biRawCommand,
headers: [
HOST: biHost,
Accept: “/”,
]
]
def hubAction = new physicalgraph.device.HubAction(httpRequest)
sendHubCommand(hubAction)
}
}

@blazenmp From the code you’ve posted it looks like you might have been working on an earlier version of the code (0.0.1 or 0.0.2, neither of which worked). Specifically, the biRawCommand needs a leading “/” character which you’re missing (and I also had missing until 0.0.3). I’d strongly recommend checking the GitHub for the latest version (0.0.3) and working from that, as it was the first version to actually work.

@luma I’m using 0.0.3 - 2015-12-10 from your Github.

I stand corrected… I originally removed the second “/” from your 0.0.3 version! I added it back and its working. Thank you for your time.

1 Like

LOL great minds think alike I guess, that same problem was why mine wasn’t working in the first couple versions. Glad you got it going!

1 Like

@luma. thanks for making this app. is exactly what i was looking for. the other one which sets profiles proved to be unusable to me when i dropped using smartrules and went to smartalarm.

Any help appreciated. I have the smartapp installed, and when it runs Blue Iris shows the login, but the camera doesn’t trigger/start to record. Is the camera name case sensitive or anything else? I have the short name all lower case in BI, and in the app. I’ve typed it in a browser window, and BI shows the login still, but no trigger. Thanks in advance!

EDIT - looking at the log, it is showing an Anonymous login, despite the username and password being in there. BI help says you need to be an Admin to use the trigger command (although that is in the JSON help, so I’m not sure it applies to HTTP GET methods).

Well, I just wrote a new app. It does the same basic functions as @luma, but is expanded. This is a parent/child smart app (so you can have multiple instances but only requires entering Blue Iris info once, and it keeps the smartapps list shorter). It uses the JSON interface, and works with HTTPS too. I also added switch trigger capability. Links to parent/child apps:

Parent
Child

3 Likes

For those using my parent/child app, it is combined now with profile integration and it works both locally or externally. Handful other features added, you can get the links and follow changes at it’s thread:

https://community.smartthings.com/t/release-blue-iris-fusion-integrate-smartthings-and-blue-iris/54226

3 Likes

Hello, I am using the updated code from blazenmp. When ST sends the command to BI for preset 2, nothing happens, any ideas?

4:05:06 PM: debug sending GET to URL http://1.1.1.101:81/cam/Front_Door/pos=3

4:05:06 PM: debug processed event contact from device test contact with value open and data {“microDeviceTile”:{“type”:“standard”,“icon”:“st.contact.contact.open”,“backgroundColor”:"#ffa81e"}}

Instead of 2, try 9. That is where the 7+ comes from, for preset 1, it’d be 8.

I think this is my issue above, I used your code directly from your post, and if I read right you had to add / back in. Could you do me a huge favor. Could you just copy your code from your ide and send to me?

Did you get the PTZ preset to work? I’ve tried for a few hours and I can’t make it work.

Yes, I have it working very well. I have monentary buttons setup for every position, zoom in, zoom out, and reboot.

url below can be altered just add on the end part for what you want to do, see all the syntax below.

http://login name.password@ip address & port/cam/cam short name/pos=5

I use HTTP commands for BI PTZ and it works great!

/cam/{cam-short-name}?pos=x
Performs a PTZ command on the specified camera, where x= 0=left, 1=right, 2=up, 3=down, 4=home, 5=zoom in, 6=zoom out, 7+1 = Preset 1, 7+2 = Preset 2, etc

I use HTTP commands for BI PTZ and it works great!

/cam/{cam-short-name}?pos=x
Performs a PTZ command on the specified camera, where x= 0=left, 1=right, 2=up, 3=down, 4=home, 5=zoom in, 6=zoom out, 7+1 = Preset 1, 7+2 = Preset 2, etc

Thanks for the info. I’ll try that, but when I looked thru the help file I did not find the 7+1 = Preset 1, 7+2 = Preset 2, etc. Did find the /cam/{cam-short-name}?pos=x where x= 0=left, 1=right, 2=up, 3=down, 4=home, 5=zoom in, 6=zoom out.

Here is the list I have.

/image/{cam-short-name}?q=50&s=80
A single JPEG image from a specific camera, with optional quality (q) and scale (s) parameters. Quality is a percentage from 1-100, and scale may be any number >0.

/image/{cam-short-name}?h=100
You may also specify a specific height (h) or width (w) instead of scale.

/mjpg/{cam-short-name}/video.mjpg
An M-JPEG stream. This stream is compatible with Blue Iris’s “MJPEG stream request.”

/file/clips/{filename}&mode=jpeg&speed=100
An M-JPEG stream of a clip from your New clips folder. You may include additional subdirectory names in the filename. The speed parameter is optional, a percentage of normal playback speed.

/thumbs/{filename}
A thumbnail image from a specific file in the New clips folder.

/admin?signal
Changes the traffic signal icon and returns the new status. This requires admin authentication.

audio/{cam-short-name}/temp.wav
Pull a raw audio stream (MIME type audio/x-wav).

/cam/{cam-short-name}?pos=x
Performs a PTZ command on the specified camera, where x= 0=left, 1=right, 2=up, 3=down, 4=home, 5=zoom in, 6=zoom out, 7+1 = Preset 1, 7+2 = Preset 2, etc

/cam/{cam-short-name}?pos=100
Causes a snapshot image to be captured from the specified camera.

/h264/{cam-short-name}/temp.h264
Pull a raw H.264 stream (MIME type video/H264). This stream will play in a tool like VLC, and may be used in future versions of the ActiveX control.

/h264/{cam-short-name}/temp.ts
Pull an MPEG-2 transport stream (MIME type video/MP2T).

/h264/{cam-short-name}/temp.m or .m3u8
Pull a virtual M3U8 file (MIME type application/vnd.apple.mpegurl). This will play in QuickTime, iPad and the iPhone using the iPhone Live Streaming format.

Well I sure am late… here it is, remember, this has been modified for me to do a PTZ:

/**

  • Send preset to Blue Iris
  • Trigger Blue Iris in response to SmartThings events
  • https://github.com/aderusha/SmartThings/blob/master/Send-Trigger-to-Blue-Iris.groovy
  • Copyright 2015 aderusha
  • Version 0.0.1 - 2015-12-06 - Initial test release
  •  0.0.2 - 2015-12-06 - Only trigger on "motion" or "open", added more debug logging
    
  •  0.0.3 - 2015-12-10 - Actually tested this against Blue Iris and made it work.
    
  • This SmartApp will send selected events to a Blue Iris server on the local network.
  • This requires the Blue Iris web server to allow un-authenticated connections. In
  • settings > Web Server > Advanced > Authentication select “Non-LAN only” (preferred)
  • or “No” to disable authentication altogether.
  • TODO:
    • Add device types
    • Add configurable conditions
  • ISSUES:
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/

definition(
name: “Send a Preset to Blue Iris”,
namespace: “aderusha”,
author: “aderusha”,
description: “Trigger Blue Iris in response to SmartThings events”,
category: “Convenience”,
iconUrl: “https://raw.githubusercontent.com/aderusha/SmartThings/master/resources/BlueIris_logo.png”,
iconX2Url: “https://raw.githubusercontent.com/aderusha/SmartThings/master/resources/BlueIris_logo%402x.png
)

preferences {
section(“Blue Iris server details”){
input “biServer”, “text”, title: “Server”, description: “Blue Iris web server IP”, required: true
input “biPort”, “number”, title: “Port”, description: “Blue Iris web server port”, required: true
input “biPreset”, “number”, title: “Preset#”, description: “7+preset number”, required: true
}
section(“Blue Iris Camera Name”){
input “biCamera”, “text”, title: “Camera Name”, required: true
}
section(“Select events to be sent to Blue Iris”){
input “myMotion”, “capability.motionSensor”, title: “Motion Sensors”, required: false, multiple: true
input “myContact”, “capability.contactSensor”, title: “Contact Sensors”, required: false, multiple: true
}
}

def installed() {
log.debug "Installed with settings: ${settings}"
subscribeToEvents()
}

def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribeToEvents()
}

def subscribeToEvents() {
subscribe(myMotion, “motion”, eventHandlerBinary)
subscribe(myContact, “contact”, eventHandlerBinary)
}

def eventHandlerBinary(evt) {
if ((evt.value == “active”) || (evt.value == “open”)) {
log.debug "processed event ${evt.name} from device ${evt.displayName} with value ${evt.value} and data ${evt.data}"
def biHost = "${settings.biServer}:${settings.biPort}"
def biRawCommand = "/cam/${settings.biCamera}/pos=${settings.biPreset}"
log.debug "sending GET to URL http://$biHost$biRawCommand"
def httpMethod = "GET"
def httpRequest = [
method: httpMethod,
path: biRawCommand,
headers: [
HOST: biHost,
Accept: “/”,
]
]
def hubAction = new physicalgraph.device.HubAction(httpRequest)
sendHubCommand(hubAction)
}
}