HomeKit / Homebridge Example

General discussion about Blue Iris
Post Reply
DarkStar
Posts: 3
Joined: Mon Sep 02, 2019 4:06 pm

HomeKit / Homebridge Example

Post by DarkStar »

I thought that since I have been using Homekit/Homebridge with BI successfully for over six months I would provide my Homebridge configuration which covers BI profile control, notifications, and video. My reason for choosing Homekit is complicated and beyond the scope of this discussion. However with that said I have successfully integrated over 30 devices into the Homekit ecosystem via HomeBridge including everything from an EVR air handling system to BI. Should you decided to go down this route here is an example Homebridge config.json file (a subset of mine) that includes the basics for controlling BI via Homekit. The benefit of this configuration includes Siri control, scenes, location services and everything else Homekit brings to the table.

My configuration consists of a Raspberry Pi running Raspbian Jessie Lite, and the following software/plugins
Node.js - Foundation software
Homebridge - Interface to Homekit
homebridge-smtpsensor - Homebridge plugin used to provide motion notifications via BI smtp alerts
homebridge-http-switch - Homebridge plugin provides status as well as profile control based on either Homekit scenes or location services
homebridge-camera-ffmpeg - Homebridge plugin provides BI video to homekit

You could potentially run all of this on the BI Windows PC but I have seen Node.js reliability problems on Windows that I simply do not see on Raspbian.

As promised here is an example of my config.json file. This example only covers a subset of items relevant to BI and does not represent all of the platofrms or accessories being controlled via Homebridge.

{

"bridge": {

"name": "HomeBridge-BI",

"username": "XX:XX:XX:XX:XX:XX",

"port": 51826,

"pin": "XXX-XX-XXX"

},

"platforms": [

{

"platform": "SmtpSensor",
"port": "2525",
"sensors": [
{
"name": "UB-FLEX Motion",
"keyword": "UB-FLEX"
}
,
{
"name": "AC-PTZ Motion",
"keyword": "AC-PTZ"
}
]
},

{
"platform": "Camera-ffmpeg",
"cameras": [
{
"name": "GBR AC-PTZ",
"videoConfig": {
"source": "-re -i http://homebridge:password!@192.168.X.X:8080/h264/ac-ptz/temp.h264",
"stillImageSource": "-i http://homebridge:password!@192.168.X.X:8080/image/ac-ptz?q=50&s=80",
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 1024,
"maxFPS": 15
}
},
{
"name": "GBR UB-Flex",
"videoConfig": {
"source": "-re -i http://homebridge:password!@192.168.X.X:8080/h264/ub-flex/temp.h264",
"stillImageSource": "-i http://homebridge:password!@192.168.X.X:8080/image/ub-flex?q=50&s=80",
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 1024,
"maxFPS": 15
}
}
]
}]
,
"accessories": [

{
"debug" : false,

"accessory": "HTTP-SWITCH",
"service": "Light",
"switchHandling": "realtime",

"name": "BlueIris Arm",
"auth": {
"username": "homebridge",
"password": "xxxxx",
"sendimmediately": "true"
},

"http_method": "GET",

"switchType": "stateful",

"onUrl": "http://192.168.X.X:8080/admin?profile=1,lock=1",
"offUrl": "http://192.168.X.X:8080/admin?profile=2,lock=1",
"statusUrl": "http://192.168.X.X:8080/admin?status",
"statusPattern": "signal=green\nprofile=1\nlock=1"
},

{
"debug": false,
"accessory": "Http-SecuritySystem",
"name": "BlueIris",

"username": "homebridge",
"password": "password",
"sendimmediately": "true",

"polling": true,
"pollInterval": 10000,

"http_method": "GET",

"urls": {
"stay": {
"url": "http://192.168.X.X:8080/admin?profile=2&lock=1",
"body": "stay"
},
"away": {
"url": "http://192.168.X.X:8080/admin?profile=1&lock=1",
"body": "away"
},
"night": {
"url": "http://192.168.X.X:8080/admin?profile=3&lock=1",
"body": "night"
},
"disarm": {
"url": "http://192.168.X.X:8080/admin?profile=0&lock=1",
"body": "disarm"
},
"readCurrentState": {
"url": "http://192.168.X.X:8080/admin?status",
"body": ""
},
"readTargetState": {
"url": "http://192.168.X.X:8080/admin?status",
"body": ""
}
},

"mappers": [{
"type": "xpath",
"parameters": {
"xpath": "//partition[3]/text()"
}
},
{
"type": "regex",
"parameters": {
"regexp": "profile=(0|1|2|3|4|5|6|7)",
"capture": "1"
}
},
{
"type": "static",
"parameters": {
"mapping": {
"0" : "3",
"1" : "1",
"2" : "0",
"3" : "2",
"4" : "3",
"5" : "3",
"6" : "3",
"7" : "3"
}
}
}
]
}
]

}
scuzzie2k
Posts: 2
Joined: Wed Nov 20, 2019 8:22 am

Re: HomeKit / Homebridge Example

Post by scuzzie2k »

Hi Thanks for this, wanted to get his working for a while, done as you have with my settings for the cameras but just get No Response from on the Camara preview and the red exlamation mark. I installed homebridge-camera-ffmpeg v0.1.14 thats the correct one right?
scuzzie2k
Posts: 2
Joined: Wed Nov 20, 2019 8:22 am

Re: HomeKit / Homebridge Example

Post by scuzzie2k »

Hi, what plugin did you use for the camera homebridge-camera-ffmpeg v0.1.14 ? as all i get is a black screen and a red exclamtion mark.
mrh335
Posts: 3
Joined: Wed Jan 08, 2020 6:07 am

Re: HomeKit / Homebridge Example

Post by mrh335 »

I have been trying to follow the few examples out there on how to get Blue Iris to work with Homekit via Homebridge and have not been successful.

I have successfully installed Homebridge on my Synology in a Docker container, added a Nest platform and can actively monitor my Nest smoke detectors from Homekit.

I am confused on the setup steps for getting Blue Iris to work.

I have installed the homebridge-camera-ffmpeg plugin using the following command "npm install -g homebridge-camera-ffmpeg"
The plugin is installed and when Homebridge starts is shows this plugin is registered similar to the Nest plugin.

I modified my config.json file as shown below. I have verified via jsonlint the formatting is correct. I fixed a previous error and realized the platform had to be "Camera-ffmpeg".

I then realized I had to install ffmpeg on the Docker container. I accomplished this by adding "apk add --no-cache ffmpeg ffmpeg-libs" to the startup.sh file in the Homebridge directory.

When Homebridge container is set to run, it fully boots and I can review the status in the docker terminal window. I can then successfully add my camera to Homekit. In Homekit the camera shows a red exclamation mark and when I switch to that room with the camera where it should populate a snapshot or click on the camera to view the feed, I get no image in either. In the Docker terminal I see an error post for ffmpeg with error code 1.

Are there any other steps you can provide to help me along or better explain how to close out these last few steps?

Code: Select all

{
	"bridge": {
		"name": "Homebridge 6611",
		"username": "0E:23:4C:C2:66:11",
		"port": 53915,
		"pin": "031-45-154"
	},
	"description": "Homebridge config",
	"accessories": [],
	"platforms": [{
		"platform": "Nest",
		"email": "user@gmail.com",
		"googleAuth": {
			"issueToken": "token",
			"cookies": "cookie",
			"apiKey": "apikey"
		}
		},
		{
			"platform": "Camera-ffmpeg",
			"cameras": [{
				"name": "My First Camera",
				"videoConfig": {
					"source": "-re -i http://user:password@192.168.1.86:1000/h264/Drive4k/temp.ts",
					"stillImageSource": "-i http://user:password@192.168.1.86:1000/image/Drive4k?q=75",
					"maxStreams": 2,
					"maxWidth": 1280,
					"maxHeight": 1024,
					"maxFPS": 15
				}
			}]
		}
	]
}
mrh335
Posts: 3
Joined: Wed Jan 08, 2020 6:07 am

Re: HomeKit / Homebridge Example

Post by mrh335 »

Following up to my own post.

The key to solving my issue on the Docker install of Homebridge on my Synology was to property install ffmpeg using "apk add --no-cache ffmpeg ffmpeg-libs" in the startup.sh file and then changing one configuration in Blue Iris which was Options --> Webserver --> Advanced and then unchecking the "Use secure session keys and login page". Once this was unchecked, using the username and login and checking from VLC and then adding to config.json worked.

Working code is here:

Code: Select all

{
	"bridge": {
		"name": "Homebridge 6611",
		"username": "0E:23:4C:C2:66:11",
		"port": 53915,
		"pin": "031-45-154"
	},
	"description": "Homebridge config",
	"accessories": [],
	"platforms": [{
		"platform": "Nest",
		"email": "user@gmail.com",
		"googleAuth": {
			"issueToken": "token",
			"cookies": "cookie",
			"apiKey": "api key"
		}
		},
		{
			"platform": "Camera-ffmpeg",
			"cameras": [{
				"name": "Driveway",
				"videoConfig": {
					"source": "-re -i http://192.168.2.86:1000/mjpg/Drive4k?user=user&pw=password",
					"stillImageSource": "-f mjpeg -i http://192.168.2.86:1000/image/Drive4k?user=user&pw=password",
					"maxStreams": 2,
					"maxWidth": 1280,
					"maxHeight": 1024,
					"maxFPS": 30
				}
			},
			{
				"name": "Front Door",
				"videoConfig": {
					"source": "-re -i http://192.168.2.86:1000/mjpg/FD4k?user=user&pw=password",
					"stillImageSource": "-f mjpeg -i http://192.168.2.86:1000/image/FD4k?user=user&pw=password",
					"maxStreams": 2,
					"maxWidth": 1280,
					"maxHeight": 1024,
					"maxFPS": 30
				}
			},
			{
				"name": "Living Room",
				"videoConfig": {
					"source": "-re -i http://192.168.2.86:1000/mjpg/LIV?user=user&pw=password",
					"stillImageSource": "-f mjpeg -i http://192.168.2.86:1000/image/LIV?user=user&pw=password",
					"maxStreams": 2,
					"maxWidth": 1280,
					"maxHeight": 1024,
					"maxFPS": 30
				}
			},
			{
				"name": "Back Door",
				"videoConfig": {
					"source": "-re -i http://192.168.2.86:1000/mjpg/front2?user=user&pw=password",
					"stillImageSource": "-f mjpeg -i http://192.168.2.86:1000/image/front2?user=user&pw=password",
					"maxStreams": 2,
					"maxWidth": 1280,
					"maxHeight": 1024,
					"maxFPS": 30
				}
			}
		]
		}
	]
}


mrh335
Posts: 3
Joined: Wed Jan 08, 2020 6:07 am

Re: HomeKit / Homebridge Example

Post by mrh335 »

As another follow up.

I was able to get the motion sensing from Blue Iris camera to work as well and to send a trigger to Homekit. It seems to be very quick and configuring the automation in Homekit to turn on a light when motion is detected is easy.

This method doesn't require any email servers or otherwise and is straightforward.

I installed webhooks using "npm install -g homebridge-http-webhooks"

I had to change the default cache directory to "cache_directory": "/tmp/node-persist/storage" in the config.json file

In the configure Web or MQTT alert option in Blue Iris for each camera I added "192.168.2.34:51828/?accessoryId=sensor1&state=true" and then "192.168.2.34:51828/?accessoryId=sensor1&state=false" for the trigger reset.
I added the following code after my camera code. The above IP address is that of the Homebridge server. The port is what is configured in config.json for Webhooks. The accessoryID is the sensor id name and state is true or false for this application. The main page detailing this plugin lists many more functions which it can be used.

Code: Select all

{
	                "platform": "HttpWebHooks",
	                "webhook_port": "51828",
			"cache_directory": "/tmp/node-persist/storage", 

	                "sensors": [
	                    {
	                        "id": "sensor1",
	                        "name": "Sensor name 1",
	                        "type": "motion",
				"autoRelease": false
	                    },
	                    {
	                        "id": "sensor2",
	                        "name": "Sensor name 2",
	                        "type": "motion",
	                        "autoRelease": false
	                    }

	                ]
}
Tant
Posts: 2
Joined: Wed Jul 22, 2020 2:03 pm

Re: HomeKit / Homebridge Example

Post by Tant »

Hi there,

Am running Homebridge v1.3.4 in a Syno Docker (oznu/homebridge latest) w/Camera FFMPEG v3.1.2 and BI v5.3.9.13.

I've various make/model cams running in BI and am trying to get the streaming URL working in Homebridge.

The current video source string:

Code: Select all

-re -i http://x.x.x.x:x/CAM1?user=lahoser&pwd=lahoser
returns a 404 error: "[CAM1] [error] http://x.x.x.x:x/CAM1?user=lahoser&pwd=lahoser: Server returned 401 Unauthorized (authorization failed)" I've also tried swapping http out with rtsp with same results. No problem getting the still images.

BI Web Server 'Secure Session key and login page' is disabled when attempting.

Any suggestions on how I can get the video stream to work?
User avatar
terk
Posts: 175
Joined: Tue Jun 18, 2019 2:36 pm

Re: HomeKit / Homebridge Example

Post by terk »

This is what I'm using:

Code: Select all

-re -i http://user:password@192.168.4.98:82/mjpg/LivingRoom/video.mjpg
Where LivingRoom is the camera's short name.
Tant
Posts: 2
Joined: Wed Jul 22, 2020 2:03 pm

Re: HomeKit / Homebridge Example

Post by Tant »

terk wrote: Tue Mar 23, 2021 3:54 am This is what I'm using:

Code: Select all

-re -i http://user:password@192.168.4.98:82/mjpg/LivingRoom/video.mjpg
Where LivingRoom is the camera's short name.
Freaking brilliant. I wasn't expecting an old thread would get responded to that quickly. That did the trick, Terk. Thanks!

~Tant
User avatar
terk
Posts: 175
Joined: Tue Jun 18, 2019 2:36 pm

Re: HomeKit / Homebridge Example

Post by terk »

Tant wrote: Tue Mar 23, 2021 4:02 amThat did the trick, Terk. Thanks!
Glad you got it working.
Post Reply