Blueiris camera's in HASS

Is anyone using Blue Iris web server via HTTPS? I’m trying to find information on how to set it up but am not getting a good guide. Seeing something about stunnel but not sure if I have to go that route. I’d like to be able to add the Blue Iris web server to my HASS web gui but HASS is SSL so I have to get Blue Iris webserver to produce HTTPS instead of just HTTP. Can Blue Iris provide both HTTP and HTTPS?

You have to use HTTPS to get the inputs from Blue Iris as far as I know.

When I used Blue Iris for motion alerts that was the configuration that I had and it worked fine

I’m a newcomer to HA - have just installed it - but I’m an existing Blue Iris user. I was wondering what the main benefits are of HA/BI integration? I already have BI recording and alerting me on motion detection by the cameras, so I wouldn’t need HA to help with that.
What sorts of things are Blue Iris users doing with HA that can’t be done entirely with Blue Iris?

the motion detection can be used in HA to control other automations.

I use it for lighting controls and a cheap home brew “alarm” system.

Or at least I used to use it for that. until I figured out I could bypass BI altogether and use the camera output directly in HA for motion detection. Now I just use that.

There was nothing per se wrong with using BI for that but if the PC you are running BI on goes down then you lose that functionality for all your cameras.

Ah OK I’m beginning to see the possibilities. I have an iSmartAlarm home alarm system but I’m not sure whether I could integrate that into a HA setup. I have alot of research to do!

@finity can you please provide some code examples of how you capture motion from the camera to turn on lights?

I’m assuming you want code for using the camera output directly and bypassing BI. the code below is used for that. If you want the code for using BI I can post that too if you want.

This brings the live view of the camera into HA:

camera:
  - platform: foscam
    ip: 192.168.1.xx
    username: !secret cam_user
    password: !secret cam_pw
    port: xxxx
    name: Dining Room

The following sets up the motion sensor, and the automation to control lights:

    sensor:
      - platform: command_line
        name: "Diningroom Camera Motion"
        command: 'curl -k --silent "http://192.168.1.xx:PORT/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxx&pwd=xxxx" | grep -oP "(?<=motionDetectAlarm>).*?(?=</motionDetectAlarm>)"'
        value_template: >-
          {%- if value == "0" -%}
            Disabled
          {%- elif value == "1" -%}
            None
          {%- elif value == "2" -%}
            Detected
          {%- endif -%}
        scan_interval: 3 
        friendly_name: 'Diningroom'


automation:
  - id: diningroom_lights_on_with_movement
    alias: Turn on diningroom light when there is movement
    initial_state: 'off'
    trigger:
      platform: state
      entity_id: sensor.diningroom_camera_motion
      to: 'on'
    action:
      service: homeassistant.turn_on
      entity_id:
        - light.zw_light_2_level
    
  - id: diningroom_lights_off_after_x_delay
    alias: Turn off diningroom light 10 minutes after last movement
    initial_state: 'off'
    trigger:
      platform: state
      entity_id: sensor.diningroom_camera_motion
      to: 'off'
      for:
        minutes: 10
    action:
      service: homeassistant.turn_off
      entity_id: 
        - light.zw_light_2_level

the above works for, at least, the newer Foscam cameras.

If you have an older Foscam then the camera live view and sensor code might be a little different:

camera:
  - platform: mjpeg
      mjpeg_url: http://192.168.1.zz:PORT/videostream.cgi?user=xxxx&pwd=yyyy
      username: !secret cam_user
      password: !secret cam_pw
      authentication: basic
      name: Kitchen

sensor:
  - platform: command_line
    name: "Kitchen Camera Motion"
    command: 'curl -k --silent "http://192.168.1.xx:PORT/get_status.cgi?user=xxxx&pwd=yyyy" | grep -oP "(?<=alarm_status=).*?(?=;)"'
    value_template: >-
      {%- if value == "0" -%}
        None
      {%- elif value == "1" -%}
        Detected
      {%- endif -%}
    scan_interval: 3 
    friendly_name: 'Kitchen'

All of the above works for me on my newer and older Foscam models. If you have other cameras I’m not sure what you will need to do differently. Try this first tho. It may work even on other models of camera.

1 Like

Hi Rabit!

Thanks for the code, works great!

Is there a way to pre-create the sensors? So that I can customize the sensors?

Edit:
Noticed the post to create a template, thanks :slight_smile:

sensor:
#----------------------------------------------------------------

  # MOTION SENSORS
  # Blue Iris performs rest calls when motion is detected and when it stops
  # This dynamically creates the binary_sensors - so no motion detected means
  # no binary sensor and no state to display or use in an automation.  The
  # sensors below compensate for this.
  #----------------------------------------------------------------
  - platform: template
    sensors:
      motion_indoor_camera_living_room:
        friendly_name: 'Living Room'
        value_template: >-
          {% if states.binary_sensor.blueiris_living_room.state %}
            {% if is_state('binary_sensor.blueiris_living_room', 'on') %}
              On
            {% elif is_state('binary_sensor.blueiris_living_room', 'off') %}
              Off
            {% else %}
              {{ states('binary_sensor.blueiris_living_room') }}
            {% endif %}
          {% else %}
            Off
          {% endif %}

Cool. I am hoping to sit down and look at Blue iris’s API to come up with a component.

It would be nice if we could point HA at BI and import all cameras, motions sensors among other things.

1 Like

BI v4.7.0.0 just came out with MQTT support… not sure how that will help us but :slight_smile:

MQTT IoT server/publish support

1 Like

I’ve been running this setup with a few of my outside cameras and it’s been working great. With the addition of mqtt output in Blue Iris, Would there be any benefits to switch?

It can be used as a mqtt binary sensor when motion is detected. I was expecting this to trigger presence detection using the geofence feature on Blueiris app but i think is not possible yet.

03%20PM

Just saw MQTT in the support docs. I’m going to switch over to it today. It would eliminate some lines of code if you are pre-creating the sensors with sensor templates.

Hi
I am trying to use MQTT for the camera alert.
I have tested the main and it responds with a connect Ok

But the camera alert does not.

Did you get it working?

It didn’t work for me either,
there must be a bug in Blue Iris,
hopefully a fix is coming soon.

amazing - was about to start tearing hair out with zoneminder (and external storage) - testing now! so far MQTT and the app looks pretty good (wonder if it will run on a HP microserver ok)

so using:
mosquitto_sub -d -u <user> -P <password> -t cctv/camera/motion

on my HA box - i can see the ON payloads come in, but for some reason cant get HA to pick up…

am i missing something:

> binary_sensor:
>   - platform: mqtt
>     name: "camera motion"
>     state_topic: "cctv/camera/motion"
>     #payload_on: "ON"
>     #payload_off: "OFF"

i didnt need the payloads it seems

anyway to change the modes in blueiris from HA? be cool to add add the alarm_control_panel (like arlo has)

any thoughts?

I think you can by using profile=x as your message payload sent to “BlueIris/admin”, but I havent tried it yet, because I can’t get Blue iris to communicate with HA.

It turns out that there was something wrong with my password in mqtt, everything is working fine now.