Blue Iris integration- HTTP binding, REST api

Hi All

many thanks to everyones work with OH- absolutely wonderful product!!

I’ll admit my programming skills aren’t great but I’m learning everyday :slight_smile:

I would love to get the motion triggers from Blue Iris into my items file, after much reading there have been references to REST API. I have had luck using REST API with webiopi recently but hit a deadend with Blue Iris so any tips are appreciated.

Blue Iris can do the following:

run a program, request a web service…

I was thinking of using the web service function HTTP POST but don’t understand how to integrate this with openhab, webiopi had set REST API, blue iris doesn’t.

If someone has successfully achieved this with blue iris or similar could you kindly share examples.

thanks

2 Likes

Yes, this can easily be done, even without a specific binding for Blue Iris.

If you want Blue Iris to act as a motion sensor in Openhab:

In Blue Iris, go into the alerts tab for a camera, open the the Configure Web Alert screen you have pasted, and enter the following:

When Triggered
192.168.1.100:8080/CMD?MotionSensorItem=ON

Check off “Request again when trigger is reset” (turn off motion sensor)
192.168.1.100:8080/CMD?MotionSensorItem=OFF

Where
IP Address for openhab = 192.168.1.100
Openhab port = 8080
Item Name = MotionSensorItem

If you want OpenHAB to control Blue Iris (i.e. change profile):

Install http binding for OpenHAB

In your rules file, you can write something like this:
//Start BI profile #7
sendHttpGetRequest(“http://user:password@192.168.1.200:8030/admin?profile=7”)

Where
IP Address for Blue Iris = 192.168.1.200
Blue Iris port = 8030
Blue Iris Profile = 7
(user:password@ can be omitted if you are not using authentication for your Blue Iris web server)

FYI, the entire list of Blue Iris web server commands which can be controlled via http is also in their help file. Here is a pasted copy of that:

/image/{cam-short-name}?q=50&s=80 A single JPEG image from a specific camera or group, 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 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. 
/alerts/{filename} A JPEG image from the Alerts folder. 
/admin?profile=x Temporarily change the active profile to x.  Use x=-1 to toggle the lock status. 
/admin?camera=x&trigger Trigger camera x (short name) 
/admin?signal=x Changes the traffic signal state and returns the current state.  x=0 for red, x=1 for green, x=2 for yellow.  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 
/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.
6 Likes

Hi Bob

Sorry for the late reply. I hope you have managed to make this work.

I have been integrating BI with OH for a while now, getting lighting to trigger on camera motion etc. It works very well.

Let me know if you need any further help.

Aaron

This part is a bit tricky, for the CMD “API” you need to have the classic UI installed, CMD is not an official API.
You can also use the official REST API, but you need to fill POST data.

Could you (i_grave) or @ajheyworth please post your items and sitemap for the cameras?
Cheers!

Hi

You don’t need an item.

Simply add your camera to the sitemap in the following format:

Video url="http://<blueirisipaddress:port>/mjpg/<cameraname>/video.mjpg" encoding="mjpeg" height=10
1 Like

I just setup the RestAPI. Has one one noticed a long latency between when Blue Iris triggers and when it sends the command to OpenHab? I have lights that turn on based on motion and its taking 5-10 seconds. \

Before implementing the method in this post, I was using a python script to query the motion events on my cameras directly (HikVision). That latency was was 2-3 seconds.

I don’t know if this addresses any latency concerns, but I’ve changed my camera web alert settings to the attached pic and the trigger happens instantly.

3 Likes

Thanks for the feedback. In the process of upgrading 1.8 to 2.1. I entered the new RESTAPI and it works. It is still taking 6 sec for Blue Iris / OpenHab to update the motion switch. Too slow for turning lights on.

In the process of setting up cameras, one did not have the correct settings. So the the second camera in the chain was triggering – which was the cause for the delay.

I am using the PIR sensors through Blue Iris since the video feeds over overlap. With motion detection lights turning on and off cause motion trips in other cameras. The result is somewhat comical. Anyway thanks for the help. Work great now. Now running 2.1

I am using BlueIris as well. Using the RESTful cmds to switch an entry way light on when motion is detected by cameras watching the front area and vehicles (we have a lot of vehicle theft/burglary).
The biggest problem I have is that when the light is switched on, I would like it to also be switched off after say 10 minutes. If you use the blueiris web integration action when trigger is reset, it turns off the light as soon as motion detection stops.

I think what is needed is to create some sort of object or thing in OH2 that can have it’s state flipped to ON by blueiris and then a rule defined that when that object is ON, start a timer and when timer expires the rule would set the light state to OFF. Also, when the light is manually switched to ON state, the tracking object needs to override any automatic switching off of the light until it is manually switched off.

Has anyone tackled this sort of rule yet? Is it possible to send an argument/parameter via a RESTful POST action directly to a rule? If this were possible, the state flags for the light could be maintained entirely within the rule I believe.

Look into the expire binding. You should be able to figure out how to use this to turn off a motion switch after a predetermined period of time.

Hi All

Im using the HTTP section of Blue Iris with OpenHab2 and its nice works very well.

Does anyone know if its possible to configure BI/OH2 in a way like an alarm system?

By this I mean you essentially turn on a Dummy Switch which tells BI to use its Alerts/Schedule function? ie send alerts if motion detected during certain hours?

Id like to basically before bed or when going away, ARM the system (turn a dummy switch on using Alexa) that enables the motion detection alerts of BI.

Any thoughts?

Cheers

I turn on alerting when at night or when my alarm is on and we are not home. You do this by changing the traffic signal from 0 to 1.
sendHttpGetRequest(“http://xxx.xxx.xxx.xxx/admin?signal=1&user=xxxxxx&pw=xxxxxx”)

2 Likes

Thanks Rob! This would also mean all motion detection is off when the signal is 0. This would mean whilst I’m home, it wouldnt record any motion as the signal is red

Ill think about this a bit more . Thanks for the nice suggestion!

I have two profiles set up. 1 for home, 2 for away.

sendHttpGetRequest("http://192.168.1.xx:8585/admin?profile=1&user=xxxx&pw=xxxx")

This is how I force the change between my profiles.

Hi Paul,

Cool. I’ve created a rule to just disable motion when I’m home , using an existing gPresenceSensors group and also the vTimeOfDay. If its Day, and we are home, motion recording is switched off in Blue Iris.

If its anything else, ie: its night/evening and we are home, it will record as my IF condition is &&.

EDIT: Actually… thinking about this, that’s not going to work.

I still want certain cameras to be recording. Doh!!

Cool, yeah just set blue iris up so that its always recording (in the main settings for BI set up the Schedule page based on your Profiles). This will set up when it’s recording. You’ll want both Profiles to always be recording.

Then in each camera’s Properties you’ll want to set up the Alert settings for each different Profile. No alerts when in the Home profile, alert when Away. This way it’ll always record when home, but never alert.

1 Like

OK, so this is what I’ve done.

When either my partner or I are home (indicated by gPresenceSensors being ON) and the vTimeOfDay is Day, then this will disable Motion Recording on the inside and rear yard cameras. The rest of the cameras will still record (ones that monitor my gates, doors and rear lane)

Otherwise, all cameras are recording.

Here is some motion alerts which alert us at night time if the Carport or Garage are triggered:


rule "Blue Iris Motion Detection Alert - Garage"
when
    Item Motion_Garage received command
then
     if(Kris_MobileAP.state != "Garage" || Jodie_MobileAP.state != "Garage"){
         logInfo("Blue Iris", "There is motion in the Garage")
           Echo_Living_Room_TTS.sendCommand('There is motion in the Garage')
           Echo_Garage_TTS.sendCommand('The police have been called')
        sendBroadcastNotification("There is motion in the Garage")
}
end

rule "Blue Iris Motion Detection Alert - Carport"
when
    Item Motion_Carport received command
then
    if(Kris_MobileAP.state != "Garage" || Jodie_MobileAP.state != "Garage"){
     logInfo("Blue Iris", "There is motion in the Carport")
       Echo_Living_Room_TTS.sendCommand('There is motion in the Carport')
       Echo_Garage_TTS.sendCommand('The police have been called')
    sendBroadcastNotification("There is motion in the Carport")
}
end

And this is the one that enables/disables motion but its not working lol! The HTTP commands execute just find if I use a browser


rule "Turn off Blue Iris Motion Recording when we are Home"
when
        Item gPresenceSensors changed
then
        if(gPresenceSensors.state == ON && vTimeOfDay.state == "DAY"){   // If we are home and its day time, turn off Motion Recording
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=RearYard&motion=0&user=Kris&pw=XXXX")       // Disable Motion Recording in Rear Yard
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=LivingRoom&motion=0&user=Kris&pw=XXXX")     // Disable Motion Recording in Living Room
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=Alfresco&motion=0&user=Kris&pw=XXXX")       // Disable Motion Recording in Alfresco
        logInfo("Blue Iris", "Selective motion recording OFF because someone came home and its day")
}
        if(gPresenceSensors.state == ON && vTimeOfDay.state == "NIGHT"){   // If we are home and its night time, turn on Motion Recording
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=RearYard&motion=1&user=Kris&pw=XXXX")       // Enable Motion Recording in Rear Yard
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=LivingRoom&motion=1&user=Kris&pw=XXXX")     // Enable Motion Recording in Living Room
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=Alfresco&motion=1&user=Kris&pw=XXXX")       // Enable Motion Recording in Alfresco
        logInfo("Blue Iris", "It's night time so all motion recording ON")
}
        else (gPresenceSensors.state == OFF){
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=RearYard&motion=1&user=Kris&pw=XXXX")       // Enable Motion Recording in Rear Yard
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=LivingRoom&motion=1&user=Kris&pw=XXXX")     // Enable Motion Recording in Living Room
           sendHttpGetRequest("http://192.168.0.4:82/admin?camera=Alfresco&motion=1&user=Kris&pw=XXXX")       // Enable Motion Recording in Alfresco
        logInfo("Blue Iris", "Motion recording ON as no one is home")
}
end



It’s been a while since I’ve visited this thread, but wanted to share some updates on Blue Iris + openHAB integration.

I’ve been using BI’s motion detection + a separate hardware PIR to sense and confirm if someone is at the door. If there is, OH will send notifications through pushover. Pushover recently announced GIF support, so with some hacking, I’ve managed to adjust this to send an animated GIF of the recorded activity and include it in the notification.

Since it ties in a lot of different things (Blue Iris, FFMPEG, Pushover, OH2) the process is pretty hackish, but if anyone is interested, I can do a writeup.

Some sample images:

Converted GIF sample:
out

Pushover notification on phone (this is shown as animated GIF):

Linked live view:

2 Likes