Blue Iris motion alerts to notification with image in Home Assistant

Has anyone got an example how to configure the mqtt alert in BI for licence plates?

1 Like

Thanks to all the help in this thread I am also seeing the image work on my HA dashboard. I would like to send this image notification via push notifications too (Android in my case), but I believe the only way of doing this is first putting the image in an internet-readable directory first like /www/. Can anyone confirm if that’s the case? I guess the other way is to have an always-on VPN on my phone connected to my LAN?

Edit: Looks like this is possible without a VPN or without exposing a camera snapshot to the internet by using the media_source (documentation). The media_source authenticates with the HA app and doesn’t expose media to the open internet which is exactly what I was looking for.

So an example automation would be something like this to anyone interested. My camera detects motion, triggers a camera snapshot, waits 1 second, then sends an alert with the picture of the camera snapshot to my phone:

alias: Test Picture Notification
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.blueirisvm_front_door_motion
condition: []
action:
  - service: camera.snapshot
    data:
      filename: /media/front_door.jpg
    target:
      entity_id: camera.blueirisvm_front_door
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: notify.mobile_app_s22
    data:
      message: Front Door
      data:
        image: /media/local/front_door.jpg
mode: single

If you wanted to use the aforementioned MQQT camera instead that would work too and I guess be slightly more accurate, but I think it’s pretty similar since instead we are just taking a camera snapshot in HA when BI sends us an MQQT signal.

if you are using android its easy to get the image, using the api securely directly from the mqtt camera entity without the need to snapshot

image: /api/camera_proxy/camera.xxx_alert

The only issue i still have is the image is cropped in the notification. android requires a 2:1 ratio image, the only way i can see to get this is to pad the image, cropping doesnt work.

My personal favourite is still saving camera images into the /www folder with a simple automation to delete the old ones - this way you can see all the previous notification snapshot images, otherwise you’ll only see the most recent image for all previous notifications

1 Like

image: /api/camera_proxy/camera.xxx_alert
This never worked for me…

Also, I tried the code below and I do get a notification on my mobile app but no image (no image is stored in my folder either). Not sure why, both my external and internal links are https might that be why?

automation:
  - alias: Blue Iris Kuna Person Alert
    trigger:
      - platform: state
        entity_id: binary_sensor.kun_person
        to: "on"
    action:
      - service: camera.snapshot
        data:
          filename: /media/front_door.jpg
        target:
          entity_id: camera.kuna
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - service: notify.mobile_app_pixel_6
        data:
          message: Front Door
          data:
            image: /media/local/front_door.jpg
    mode: single

ok got it to work…

was missing media_source: under my config.yaml

@TheHolyRoger Thanks for all the good info in this thread! I have the image on my dashboard now onto the notifications.

What sent me in circles is it seems BI’s Alert Test function does not push the image. I had to trigger the camera manually via BI UI for it to fire off to HA and the image to appear in the dash.

1 Like

Yeah unfortunately testing the full setup is a pretty manual process :slight_smile:

I’m using AI detection as well so I often find myself walking outside and waving in front of my cameras in the subtlest way possible and occasionally ringing my own doorbell. Not sure what my neighbours think…

1 Like

Got it working! Now if I can just make the On-Click image a little larger when I tap/hold on IoS I’d be really happy.

Config.yaml

mqtt:
  camera:
    - topic: BlueIris/image/garage
      name: Alert Garage
      unique_id: alert_garage
      image_encoding: b64

Blue Iris Alert

MQTT Topic: BlueIris/image/&CAM
Payload: {“db”:"&ALERT_DB",“cam”:"&NAME",“time”:"%X"}

HA Automation

alias: "Test - Blue Iris: Garage Notification"
description: ""
trigger:
  - platform: mqtt
    topic: BlueIris/image/garage
condition: []
action:
  - service: camera.snapshot
    data:
      filename: /config/www/BI_Alerts/{{ file_time }}_garage_ha.jpg
    target:
      entity_id: camera.alert_garage
  - service: notify.mobile_app_miphone5
    data:
      message: "{{ MSG }}"
      title: Blue Iris
      data:
        importance: max
        tag: persistent
        persistent: true
        image: /local/BI_Alerts/{{ file_time }}_garage_ha.jpg
variables:
  file_time: "{{ now().strftime('%Y%m%d_%H%M%S') }}"
mode: queued

@TheHolyRoger Would you know why I am getting notifications/snapshots every time HA restarts? I removed Persistent and it’s still sending the notification upon restart. Thanks again!

I think it’s because you have or had a retain setting on in blueiris for the mqtt message. You’ll need to turn that off then it should clear the retained message with the next alert

I disabled the retain setting on BlueIris and retriggered but when I restart I keep getting the latest alert. This happens when I restart Mosquitto broker or the Integration as well.

I think then you need to send a blank message with retain ON to that topic, and then it will clear the retained message.

Do this manually, not with blueiris

Stupid question, but how can I do that? From HA broker?

Probably the simplest way to do it from HA is go to the integrations page, click MQTT then configure, then you can publish to topics manually and listen etc

1 Like

That took care of it! No more 2AM notifications on my nightly HA reboot. Onto more cameras! Thank you!!

1 Like

Question for anyone.

Has anyone ever seen on IOS where clicking and holding pulls up the picture, BUT the simple notification does not always show the image?

I can fix it if I change this part of the code from:

service: notify.mobile_app_rotto_iphone
data:
  message: Activity detected at {{ camera_name }}
  data:
    entity_id: camera.{{ camera_name }}_alert  
                   

Works fine if I change it to:

service: notify.mobile_app_rotto_iphone
data:
  message: Activity detected at Driveway
  data:
    entity_id: camera.driveway_alert

Any ideas from anyone?

Sounds like either a bug in how your camera_name variable is assigned or maybe your HA version. Worth looking in the traces to see what’s going on with that variable

Can you paste your full automation/blueprint?

Here is how it is currently:

alias: Camera-Driveway Camera Alert
description: ""
trigger:
  - platform: mqtt
    topic: BI/Driveway/alert-image-b64
    variables:
      camera_name: "{{ trigger.topic.split('/')[1] }}"
condition: []
action:
  - service: notify.mobile_app_rotto_iphone
    data:
      message: Activity detected at Driveway
      data:
        entity_id: camera.driveway_alert
mode: queued
max: 10

Funny you mention it is how it is formatted. The problems I see when I was setting this up are as follows:

The {{ camera.name }} is an entity ID, but when you setup a MQTT camera there is not an option to set the entity.id, and it appears it is setting it based on the unique_id.

With that said, the guide skips over a little the naming of the cameras in BI.

From what I can tell, the automation needs the camera names to match to work correctly.

(I could have all of this totally wrong, but I had to do some tweaking to my BI camera names and my MQTT camera in the yaml to get that one to work initially.)

The only thing I can tell right now is a possible issue of the cameras not matching if the names are case sensitive as well.