Blue Iris motion detection to activate smart app

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?

2 Likes

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.

1 Like

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!

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}"

			}
	}
}
5 Likes

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!!

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.

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

@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…

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?

1 Like

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

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.

@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…

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.

Mine has always failed the test…

If you change the url will it pass the test?

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

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:

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.

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…

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!