Blue Iris motion detection to activate smart app


#1

I have a Blue Iris connected camera viewing my back door. At that same back door I have an Aeon Z Wave bulb (outside the door) and z-wave door contact switch inside. Is it possible to have Blue Iris send a signal to smart things to have that porch light turn on when motion is detected via blue iris?


Blue Iris camera trigger from smart things
Reolink IP Cameras
[DEPRECATED] [RELEASE] Blue Iris Fusion - Integrate SmartThings and Blue Iris!
[DEPRECATED] [RELEASE] Blue Iris Fusion - Integrate SmartThings and Blue Iris!
(Minollo) #2

I haven’t done it for Blue Iris; but it is possible. As part of the Blue Iris alert notification configuration, you can choose to run a script or invoke a web service. You should create a smartapp which supports OAuth and exposes a mapping to a function that serves as the web service endpoint. If you search around about OAuth documentation and examples, you’ll see it’s relatively easy to do.


#3

Thanks for the help Minollo, but I’m not a coder and unless I can find somebody who’s already doing this to lend a hand and explain exactly what they had to do then I think I’m probably a long way from making this happen on my own.
I found this thread on the MiCasa forums that outlines what I’m trying to do and was hoping for something similar on Smart Things:
http://forum.micasaverde.com/index.php?topic=10390.0

Thanks so much!


Need direction on a Blue Iris custom device type
(Kristopher Kubicki) #4

I don’t use Blue Iris, but iSpyConnect. I think it has the same functionality though – when iSpy detects motion, I have the software hit an HTTP endpoint. Here is the SmartApp to do that. You’ll also need to create a simulated motion sensor.

/**
 *  Camera Motion
 *
 *  Copyright 2015 Kristopher Kubicki
 *
 */
definition(
    name: "HTTP Motion Endpoint",
    namespace: "KristopherKubicki",
    author: "kristopher@acm.org",
    description: "Creates an HTTP motion endpoint for your camera or other device",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/intruder_motion-cam.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/intruder_motion-cam@2x.png")


preferences {
    page(name: "selectDevices", install: false, uninstall: true, nextPage: "viewURL") {
    	section("Allow endpoint to control this thing...") {
			input "motions", "capability.motionSensor", title: "Which simulated motion sensor?"
			label title: "Assign a name", required: false
			mode title: "Set for specific mode(s)", required: false
        }
    }
    page(name: "viewURL", title: "viewURL", install: true)
}

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

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

}



mappings {

    path("/active") {
        action: [
            GET: "activeMotion"
        ]
    }
    path("/inactive") {
        action: [
            GET: "inactiveMotion"
        ]
    }
}

void activeMotion() {
	log.debug "Updated with settings: ${settings}"
    motions?.active()
    runIn(15,"inactiveMotion")
}

void inactiveMotion() {
	log.debug "Updated with settings: ${settings}"
    motions?.inactive()
}


def generateURL() {
	
	createAccessToken()
	
	["https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/active", "?access_token=${state.accessToken}"]
}


def viewURL() {
	dynamicPage(name: "viewURL", title: "HTTP Motion Endpoint", install:!resetOauth, nextPage: resetOauth ? "viewURL" : null) {
			section() {
                generateURL() 
				paragraph "Activate: https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/active?access_token=${state.accessToken}"
                paragraph "Deactivate: https://graph.api.smartthings.com/api/smartapps/installations/${app.id}/inactive?access_token=${state.accessToken}"

			}
	}
}

Blue Iris camera trigger from smart things
How to send data from my LAN connected device to HubV2?
Any cameras that can report motion event to ST?
WiFi Cameras that work with SmartThings but allow local storage?
Blue Iris + SmartThings Push Notifications + ReaditToMe Integration (Android)
Why would SmartThings API not work from flic but works from command line curl?
[Solved] (in a round-about way), Turn on/off outlet or switch from Blue Iris
Need recommendations for a outdoor security cam
#5

Too cool, thanks Kristopher! Can you give me a little more info on how to use your app. I’ve created a simulated motion sensor but when using your app, as I try to save it says “Error - bad state, Unable to complete page configuration”

Also, here’s the blue iris config page. Do you what my trigger address and POST text would be? (http://?)

Thanks again for your help!!


#6

In the newly created SmartApp, you need to enable OAuth from within the IDE on your computer. That’s where you’re getting hung up.

Then you can configure the SmartApp to use the camera.

Copy and paste the URL the smart app gives you into the screenshot you posted, but change to https (and make sure you strip off https:// from the copy/pasted URL.


(Jeff) #7

Thanks for this! Just what I was looking for. I have it working with the Smart Porch Light app.


#8

@Kristopher - I’m not sure what’s going on, but every day or so, the endpoint urls change. As such, the motion detection stops working until I copy and paste the new url the camera smartapps create into BlueIris again.

Is there a step I’m missing to make the http endpoints work long term? Do I have to launch the “activate” link in a browser first? I can’t imagine what else it could be that causes the urls to regenerate…


(Kristopher Kubicki) #9

Hey @kars85 – that is strange. It should definitely not be changing endpoint URLs. Once you hit “Done” the endpoint should be live and nothing should change. Do you have any other info that I can use to try to track it down?


(Jody) #10

@kars85 I have been testing this SmatApp for the last 48 hours and my endpoints have remained the same. Can you paste the logs?


#11

Here is one of the four camera virtual motion sensors experiencing the issue. I’ve certainly been active in that area tripping the motion endpoint several times in the last 13 hours, so I can’t pinpoint what might be causing it.


#12

@jody.albritton - is this what your Blue Iris web alert screen looks like? Note, the “active” url in the When Triggered and “Inactive” when trigger is reset…


(Jody) #13

That is what mine looks like. Yes. Do you get something returned 0 bytes when you click test? I have found that it does not always trigger motion but the test always works, so the url is fine. I think there is some fine tuning to be done with BI in regards to trigger sensitivity and alerts.


#14

Mine has always failed the test…


(Jody) #15

If you change the url will it pass the test?


(Jody) #16

Things to check

  • remove https:// from the url string
  • make sure oAuth is enabled in the settings section of the SmartApp
  • Open the “active” url with a tool like postman; it should set the motion to active and return 0 bytes

#17

If I throw the active URL in Postman, it returns 200 OK. URL string does not include https:// since that’s prepended on from the dropdown in BI. oAuth is enabled, too…Running out of ideas :frowning:


(Jody) #18

Looking at your phone, when you run the active url, does your virtual motion trigger?

Other option is to check the outbound firewall settings and make sure blueiris can go out unrestricted.


#19

Great test suggestion. Both active and inactive URL’s trigger motion/no motion in the ST app from the BI server’s browser. But only the inactive URL returns 0 bytes when clicking on the test button within BI. I have to leave the active URL/when triggered section blank in order to get a successful test.

EDIT: full disclosure on how I think it’s now fixed. Previously, I was only copying/pasting the “active” url, then also pasting it into the deactivate alert BI window and changing the word active -> inactive. This is bad because the oAuth tokens aren’t necessarily the same. Hopefully that fixes everything for me…


(Justin) #20

Just a note, when you go through the SmartApp installation, just take a screenshot of the page where it gives you the endpoints. I was keying them into a text editor from the screen, and then pressing “Done”. I think the OAuth2 stuff might have timed out, because I was getting a 500 status code back, and this json:

{"error":true,"type":"java.lang.IllegalArgumentException","message":"An unexpected error occurred."}

Ultimately, I had to uninstall the smartapp, and reinstall it. Once I did that, things worked perfectly. Thanks!