Blue Iris Integration Tutorial

Summary

I’ve seen multiple requests on the forum and Reddit regarding camera integration with Home Assistant. Most of them appear to be outside of the scope of what can reasonably be accomplished, e.g. using HA as a central point of monitoring for motion detection. As someone that’s used BI and has multiple PoE cameras around the house, I figured I’d share my setup. BI acts as the “brain” to the cameras and offers a massive amount of customization around detection, alerting, storage, etc. I don’t believe there’s anything that remotely compares to the functionality that is offered with BI.

What’s needed?

  • Cameras obviously. I’m partial to Hikvision PoE Dome Cameras. I’ve had zero problems with them and the image quality is pretty damn amazing for the price. I wired my home with a PoE switch and Cat6 a while back, so there’s drops outside where the cameras are mounted.
  • Blue Iris. It’s $60 and I haven’t found anything remotely close to functionality for the price. To be honest, I’m amazed it doesn’t cost a whole lot more. Please note that BI configuration is way outside the scope of this article, so the assumption is you already have it up and running.
  • Windows running 24/7. I know people will hate this part, but BI only runs on Windows. My desktop is always turned on so I just have it running on there.

Camera Integration

One of the great features of BI as that it can act as a central point for displaying your cameras. You don’t have to screw around with camera-specific features. It basically acts as the central hub for “everything camera”. In BI, simply go to Settings -> Web server and enable LAN access. I’m using a random port on mine, so we’ll assume it’s running on 38500 for the rest of the article.

You’ll also need to disable “advanced” authentication in Blue Iris since we’re just doing basic authentication. Go to Settings → Web Server → Advanced and uncheck the option Use secure session keys and login page.

Each camera can be added like this in the HA configuration:

camera:
  - platform: mjpeg
    mjpeg_url: http://bi.homenetwork.local:38500/mjpg/FDC
    name: FDC
    username: !secret bi_username
    password: !secret bi_password
    authentication: basic

Replace the hostname in the URL with the IP or hostname of your Windows host running BI. See that FDC at the end of the URL? Replace that with the short name of the camera in BI. It’ll work for any of them, so even if you have 5 different camera types, BI will abstract it into an mjpg stream.

Of course you’ll want to display this in your fancy Lovelace setup. It’s just as easy. Put something like this in your Lovelace UI:

- cards:
    - camera_image: camera.fdc
      camera_view: live
      entity: camera.fdc
      show_info: true
      title: FDC
      type: picture-entity
  icon: 'mdi:camcorder'
  title: Cameras

Motion Detection

Displaying the camera is nice, but most people will also want to be alerted if motion is triggered. I can’t emphasize this enough: BI beats the crap out of everyone for fine-tuning motion detection. I rarely get a false alert and have a few automations tied to it. Best of all, BI supports MQTT for alerting, with the assumption being that you already have MQTT configured with HA. To enable MQTT integration in BI, simply go to Settings -> Digital IO and IoT -> MQTT -> Configure and plug in your MQTT server:

You’ll then need to configure motion alerts for each camera. Again, way outside the scope of the tutorial, but the help files for BI are incredibly well documented. To configure camera motion alerting, right-click on the camera and select the following:

Camera properties -> Alerts -> On Trigger -> + -> Web Request or MQTT

Camera properties -> Alerts -> On Trigger Reset -> + -> Web Request or MQTT

It’s configurable, but I’m using blue_iris/binary_sensor/fdc_motion/state as the topic and ON and OFF for the values.

You then create the corresponding MQTT entry in HA:

binary_sensor:
  - platform: mqtt
    name: "FDC Motion"
    state_topic: blue_iris/binary_sensor/fdc_motion/state
    payload_on: "ON"
    payload_off: "OFF"
    device_class: motion

…and that’s it. You can configure it however you’d like in Lovelace, but mine looks like this:

- title: Contact and Motion
  icon: mdi:door
  cards:
    - type: entities
      title: Camera Motion
      entities:
        - binary_sensor.fdc_motion

Hope this helps!

47 Likes

I originally used BI for managing the camera feed and motion detection in HA but I found that, for some still unknown reason, on a couple of my camera’s the time between BI detecting motion (and beginning it’s recording) and the signal to be sent by BI and/or received in HA was around 10 to 15 seconds. That’s completely unacceptable when using motion for automation controls.

Eventually I just went to using the camera’s feeding directly to HA and using a polling of the camera state every few seconds and my lag isn’t anywhere near as bad as it was using BI.

Not to mention that if I’m away from home and my PC that BI is running on fails then I’m completely blind and I completely lose all motion detection. It’s just one more point of failure that I’ve eliminated.

Of course I still use BI for camera management, local viewing & recording to my PC on motion detection. It works great for that stuff.

Odd. Mine is almost instantaneous from when motion is flagged. Here’s the camera-specific settings I have to trigger on motion:

Do you also get the delay when you click “Trigger Now”?

2 Likes

Honestly I haven’t used BI integration into HA for a long time now. Once I went directly to my cameras for the data I haven’t messed with the BI integration again.

And it was strange that only one or two cameras would lag but not all of them. I also verified all of the settings for all the cameras were identical in BI but I still couldn’t solve the lag.

That was also before MQTT was added to BI so maybe it will work better using that instead of the HTTPS POST method. Maybe if I get free time (HA! :laughing:) I’ll revisit it.

1 Like

Cool stuff, thanks for the write-up! Got a question, is it possible to serve the picture that Blue Iris takes on a motion event and send it via MQTT to HASS? So it could be forwarded via HASS to Pushbullet/Email/etc?

Example code would be super-sweet for a noob like me :slight_smile:

That’s beyond what you can do with MQTT. It’s just designed so devices can talk to each other. This might help though.

TIL.

I don’t know about blue iris sending a picture via MQTT, but HA can certainly receive it

Instead of putting the password in the HA config, you can go into the webserver settings in BI and set specific IP addresses to have access without authentication. Just need to put a ^ before the IP address of your HA device.
Webserver

Hope this helps, now i need to go back to your post regarding the motion detection :smiley:

5 Likes

Ha, that I didn’t know. I’ll have to give it a shot. Motion detection with TensorFlow is still working like a champ.

1 Like

Is it possible to make bi enable motion detection only when nobody are home? (Group.all_devices is away for instance) I don’t want bi to report motion and start to store clips when I walk by one of my cameras.

You would do that through Blue Iris. It has the ability to detect when you are home. You can use home/ away status to put the cameras on different schedules. Schedules control when motion is triggered and or when recordings are triggered. You can even set different motion detection zones and motion detection types. Blue Iris is a very powerful NVR system and well worth the $60 for the server and $10 for the mobile app.

1 Like

Solved it :slight_smile:
Made a command_line switch that sends a http request to Blue Iris to change profile (2 different profiles called ARMED and DISARMED). HASS can now enable ARMED when group.all_devices is set to “not_home” for more than x minuttes. The logic is being handled by a Node Red flow.

Switch:

platform: command_line
switches:
cam_armed:
command_on: ‘curl -k “http://ip:port/admin?profile=1&lock=2& user=username&pw=password”’
command_off: ‘curl -k “http://ip:port/admin?profile=2&lock=2& user=username&pw=password”’

Node Red flow to turn the switch on or off depending on if there are anyone home and the time of day:

2 Likes

krmzn,

Could you share the flow? I have been looking for something very similar to this for a while.

Thanks.

Sure :slight_smile:
https://pastebin.com/N90XhvBy

Slightly update to the flow:

1 Like

Thanks. Now I have a project for the weekend. :slight_smile:

1 Like

I am having a heck of a time getting this to work. I can go to a browser and type in the ip and port and get to a blue iris screen where I can log in and see the video stream but HA just shows image not available.

    mjpeg_url: http://192.168.1.32:81/mjpg/living_room
    name: living_room
    username: testadmin
    password: test
    authentication: basic ```

I use HA presence to switch Blue Iris profiles; I have two. One sends SMS alerts when motion is detected, one does not. We only want alerts when we are not home.

So, when HA determines that people are home, it sets BI to the non-alerting profile. When there is no one home, HA sets BI to send alerts.

I do it like this:

- id: blueiris_profile_2
  alias: Blue Iris Profile 2
  trigger:
    platform: state
    entity_id: binary_sensor.people_home
    from: 'on'
    to: 'off'
    for: 
      minutes: 4
  action:
    - service: switch.turn_on
      entity_id: switch.blue_iris

- id: blueiris_profile_1
  alias: Blue Iris Profile 1
  trigger:
    platform: state
    entity_id: binary_sensor.people_home
    from: 'off'
    to: 'on'
  action:
    - service: switch.turn_off
      entity_id: switch.blue_iris

Here’s the Blue Iris switch:

platform: command_line
switches:
  blue_iris:
    command_on: '/usr/bin/curl -X GET "http://xx.xx.xx.xx:8081/admin?profile=2&lock=2"'
    command_off: '/usr/bin/curl -X GET "http://xx.xx.xx.xx:8081/admin?profile=1&lock=1"'
    friendly_name: Blue Iris

You could easily create a profile with no motion detection and switch to it as needed. Check Bluie Iris’s webserver help page for details on configuration.

2 Likes

would me using duckdns be part of the issue you think?

Try adding the HASS ip to the list of clients that BI will accept without a user/password, and then remove the authentication part in your config. Worked like a charm for me.

2 Likes

Tnx for the tip, but I’ve already solved it in the exact same way (2-3 post up) :slight_smile: