Get data in from Blueiris?

So my goal is to get motion detection from my cameras via Blueiris. I can have Blueiris run a script and execute just about anything on the server, which is the same box for openHAB. Can I get openHAB to read a file and set variables or do anything similar?

Or since Blueiris will do whatever I ask it to, could it execute anything that would send a command to openHAB?

Any ideas would be appreciated.
Thanks1

1 Like

Yep - just access the openHAB REST API directly from your script - you can update any openHAB item, or send a command to anything you need. I do exactly this using motion for my IP cameras, whenever motion detects movement I have a little script which posts an update to my openHAB Camera_Motion item.

1 Like

Oh that is perfect!
I suddenly have Blueiris telling my lights to turn on when the cameras detect motion.

Taking it a step further, I have Blueiris setting an item to = motion which I can take action on including using the sitemap visibility option to only show links to the cameras that are currently showing motion. That makes it much faster to check things out quickly.

Unrelated, my text item that gets set to = motion with the visibility option, the visibility only changes when re-loading the sitemap page. Other items seemed to appear and disappear without having to do anything. I might have to look into that further.

Thanks!

1 Like

Blue iris is pretty cool… I’ve been using it for about 5 years now. At the moment I just display my cameras in openHAB. Now that I think of it, it would be cool to tell blue iris to arm the cameras whenever I set the house alarm or something like that.

Yep - again that is something I do - when the house is empty or the front gate opens my camera is armed via an HTTP item binding which posts a request to motion. Then if motion detects anything it posts an update back to openHAB to indicate motion detected. From there I can send myself notifications, and even upload a snapshot of the motion to my private Slack channel for viewing on my phone.

Today I use Milestone Protect but it is proving to be very difficult to try and get my camera streams integrated into openHAB. How are you guys pulling in your streams from Blue Iris into your openHAB? I am willing to change DVR solutions if it proves easier to get integration into openHAB. I spent hours trying to work through various ways to get the streams in and I want to pull my own head off. Thanks for any insight.

Getting the actual video feeds into openhab has been a problem for me too. Using the URL viewer they work on certain devices but not others, in certain locations (at home or away from home).

So I kind of gave up and just bookmarked the blueiris page for all my camera feeds.

Yep, I gave up on using the openHAB app as well for video streams. I have a snapshot view in the openHAB app, but also have Imperihome on my phone which is much better at streaming live video and works very well. It also allows you to put a shortcut on your desktop to take you straight to a particular camera stream - great for the daughters nursery camera!

Can you share how you did this? I tried to just have snapshots from blueiris in openhab and couldnt get it working.

Thanks

This is how I have them setup in my sitemap…

Text label="Security Cameras" icon="camera" {
			Video   url="http://x.x.x.x:85/mjpg/SECCAM01/video.mjpg" encoding="mjpeg"
			Video   url="http://x.x.x.x:85/mjpg/SECCAM02/video.mjpg" encoding="mjpeg"
		}
1 Like

Thanks when i go to that URL on my blueiris server using a browser i get prompted for a username and password. Have you set something within Blueiris to allow anonymous?

I have it set that if I’m on the lan it does not ask for a username and password. My Blue Iris is not exposed to the web in any way so it’s pretty “open”.

Thanks i will take a look i must have it set auth for both.

If you have security enabled on Blue Iris can use a URL format like this to pass your credentials:

http://username:password:x.x.x.x:85/mjpg/SECCAM01/video.mjpg" encoding=“mjpeg”

As an alternative to imperihome, this new app written by member @igor also supports streaming video
https://community.openhab.org/t/different-take-on-client-ui-android-for-now/

If you use the Macros function in Blue Iris, you can also get data in from OpenHAB as video overlay.
Here’s a sample:

All the text in this capture is pulled from OpenHAB. If there is any interest on how this is done, I can try to put up some instructions.

4 Likes

@roy_liao, please do share! Looks great!

This one is a bit more complicated, but i’ll try my best to explain it in a clear manner (copied, modified, and pasted from another post I previously wrote for a vera).

Overview:
This is actually very straightforward. However, there are quite a few steps involved. Basically, we need to find a way to get the status of an item into a text file the Blue Iris server can read. Once the BI server has access to the text file, you can configure that data to work as an overlay in your BI video.

Requirements:

  • Openhab
  • Blueiris with macros setup (Direct to Disk should be off)
  • A writeable CIFS mount from your OpenHAB to a share on your Blue Iris server to store text files. If you’re running OH and BI on the same machine, you don’t need this, just change the file path accordingly.

Step 1: Set up Blue Iris and OpenHAB connection
Mount a CIFS share to your Blue Iris machine from your OpenHAB server. Make sure you have permissions to write to it from the OpenHAB server. In this example, I will use /mnt/blueirismacros/ as the mounted path.

Create a text file (for example frontyardstatus.txt) in this share on your BI server. Open BI and assign it to a macro under Blue Iris Options; you’ll probably want to pick %1 to start with. Put a test message in the file.

Go into the settings for the camera you want the overlay on, and choose the video tab. Click on ‘edit’ under text and graphic overlays. Insert your test file by clicking ‘add text/time’ and entering your macro value (%1). Your BI video should now support the text overlay.

Part 2: Create a script in OpenHAB to write to a text file
In your OH server, create a text file in your configurations/scripts folder called filewriterfrontyard.script. This script will take care of actually writing the text file.

Here’s an example set of contents to put in the file

val java.util.Set linesSet = new java.util.HashSet()
val fileWriter = new java.io.FileWriter("/mnt/blueirismacros/frontyardstatus.txt")
try {
	val writevalues = new java.io.BufferedWriter(fileWriter,1)	
	writevalues.write("Garage Door: " + GarageDoorSensor.state.toString + " | Front Yard Lights: " + 
		FrontYardLights.state.toString) 
} finally {
	try { fileWriter.close() } catch (Exception e) {}
}
return linesSet

I like using one script per camera for better organization, so on our setup, I have a total of six scripts. Of course, feel free to organize this any way which works for you.

Part 3: Set up OpenHAB rules to call the script
Now we need to run the script to rewrite the text overlay any time one of the items changes. Here’s a sample rule. Make sure the parameter listed in the callScript function matches the name of the script file we created in step 2 (i.e. filewriterfrontyard in this case).

rule "BlueIris Overlay - Front Yard"
when
	Item GarageDoorSensor changed or 
	Item FrontYardLights changed
then
	callScript("filewriterfrontyard")
end

Good luck!

2 Likes

@roy_liao

Thanks Roy! I was able to work through your instructions (great work!) and I was able to get everything working on the OH side and the macro set up on the BI side. I now seem to have some issue with BI showing the text in the macro called text file. I set up the macro using the %1 macro and set up the camera overlay to use the macro. The overlay set up shows the correct text file text on the screen shot of the camera but when I save the setting and the camera reboots the macro text doesn’t show up on the live feed.

I manually added an overlay text (non-macro) to test and it shows up. Is there anything special about the format of the text file that I may have missed?

Hrm, the first place I would start is to create a dummy text file for testing purposes. If the test file doesn’t work, we can isolate the issue to BlueIris.

Assuming the problem is BlueIris, the first thing which comes to mind is the direct to disk feature must be off. Otherwise, macros won’t work.

BlueIris is pretty stable, but one time on version 4, one of the updates caused all macros to appear inconsistently. I wrote to the developer, and he was great in fixing it right away for the next version.