Skip to content

Instantly share code, notes, and snippets.

@DeFlanko
Last active February 22, 2026 00:19
Show Gist options
  • Select an option

  • Save DeFlanko/3936338c984b932a532447b1418144dd to your computer and use it in GitHub Desktop.

Select an option

Save DeFlanko/3936338c984b932a532447b1418144dd to your computer and use it in GitHub Desktop.
How‑To: Home Assistant & Blue Iris MQTT Alerts (Push Notification with Alert Image)

How‑To: Home Assistant & Blue Iris MQTT Alerts (Push Notification with Alert Image)

This guide shows how to:

  • Send Blue Iris Motion and AI alerts to Home Assistant via MQTT
  • Send Android notifications from Home Assistant with:
    • A dynamic message
      • An alert image preview (via Home Assistant camera proxy)
      • Tap alert to open image from the Home Assistant stored image.

Prerequisites

  1. Home Assistant MQTT configured

    • MQTT broker running (Mosquitto add-on or external)
    • Home Assistant connected (Settings → Devices & services → MQTT)
  2. Blue Iris publishing MQTT topics

    Typical topics used in this setup:

[On Alert] setup per camera:

    • Name: MQTT - On Alert
    • MQTT Topic: BlueIris/&CAM/Status
    • Payload: { "type": "&TYPE", "trigger": "ON" }
    • Name: MQTT - On Alert - JSON Payload
    • MQTT Topic: BlueIris/<CameraName>/alert-image
    • Payload: { "state":"ON", "camera":"&CAM", "object":"&MEMO", , "name":"&NAME", "type":"&TYPE", "time":"&ALERT_TIME", "id":"&ALERT_DB", "path":"&ALERT_PATH" }
    • Name: MQTT - On Alert - B64 (the Raw Base64 Image)
    • MQTT Topic: BlueIris/<CameraName>/alert-image-b64
    • Payload: &ALERT_JPEG

[On Reset] setup per camera:

    • Name: MQTT - On Reset
    • MQTT Topic: BlueIris/&CAM/Status
    • Payload: { "type": "&TYPE", "trigger": "OFF" }
  1. A Home Assistant Camera entity per alert image Example entities:

    • camera.cam203_alert
    • camera.cam201_alert

    Make a mqtt.yaml file and reference it in your configuration.yaml:

    mqtt: !include mqtt.yaml

    mqtt.yaml; customize this for your camera names and needs

     ###############################################################################
     #                                BI & MQTT
     ###############################################################################
     #mqtt:
     camera:
       - topic: BlueIris/Cam200/alert-image-b64
         name: Cam200_Alert
         unique_id: camera.Cam200_alert
         image_encoding: b64
    
       - topic: BlueIris/Cam201/alert-image-b64
         name: Cam201_Alert
         unique_id: camera.Cam201_alert
         image_encoding: b64
    
       - topic: BlueIris/Cam202/alert-image-b64
         name: Cam202_Alert
         unique_id: camera.Cam202_alert
         image_encoding: b64
    
       - topic: BlueIris/Cam203/alert-image-b64
         name: Cam203_Alert
         unique_id: camera.Cam203_alert
         image_encoding: b64
    
       - topic: BlueIris/Cam205/alert-image-b64
         name: Cam205_Alert
         unique_id: camera.Cam205_alert
         image_encoding: b64
    
     binary_sensor:
       - state_topic: BlueIris/Cam200/alert-image
         name: Cam200 Alert Details
         default_entity_id: Cam200_Alert_Details
         value_template: "{{ value_json.state }}"
         json_attributes_topic: BlueIris/Cam200/alert-image
         off_delay: 15
         device_class: motion
    
       - state_topic: BlueIris/Cam201/alert-image
         name: Cam201 Alert Details
         default_entity_id: Cam201_Alert_Details
         value_template: "{{ value_json.state }}"
         json_attributes_topic: BlueIris/Cam201/alert-image0
         off_delay: 15
         device_class: motion
    
       - state_topic: BlueIris/Cam202/alert-image
         name: Cam202 Alert Details
         default_entity_id: Cam202_Alert_Details
         value_template: "{{ value_json.state }}"
         json_attributes_topic: BlueIris/Cam202/alert-image
         off_delay: 15
         device_class: motion
    
       - state_topic: BlueIris/Cam203/alert-image
         name: Cam203 Alert Details
         #object_id: Cam203_Alert_Details
         default_entity_id: Cam203_Alert_Details
         value_template: "{{ value_json.state }}"
         json_attributes_topic: BlueIris/Cam203/alert-image
         off_delay: 15
         device_class: motion
    
       - state_topic: BlueIris/Cam205/alert-image
         name: Cam205 Alert Details
         default_entity_id: Cam204_Alert_Details
         value_template: "{{ value_json.state }}"
         json_attributes_topic: BlueIris/Cam205/alert-image
         off_delay: 15
         device_class: motion

    These must exist and display an image in Home Assistant.

  2. A Home Assistant URL reachable by your phone Example:

    • https://home.example.com:8123

Step 1 — Verify the MQTT payload

In Home Assistant:

  • Developer Tools → MQTTListen to a topic like: BlueIris/Cam203/alert-image

You can also use MQTT Explorer to capture real time payloads for troubleshooting.

Example payload:

{ "state":"ON", "camera":"Cam203", "object":"person:60%", "name":"Front_Door_203", "type":"Motion_AC", "time":"2026-02-21T22:40:02.763Z", "id":"@...", "path":"Cam203....jpg" }

Common problem: invalid JSON

Some Blue Iris MQTT formats can accidentally produce invalid JSON (for example an extra comma):

{ "object":"dog:85%", , "name":"Front_Door_203" }

If the payload is malformed, trigger.payload_json will fail. This guide uses a safe parse method that “cleans” the known , , pattern and then parses JSON.


Step 2 — Create the automation (UI-style YAML)

Create a new automation in Home Assistant and switch to YAML mode.

Note: Home Assistant may show triggers: / actions: in the UI YAML editor. That format is valid for recent HA versions.

Paste and customize this automation:

alias: BI MQTT - Camera Trigger
description: Blue Iris MQTT notifications with zone decoding + image (Android)

mode: queued
max: 10

triggers:
  - trigger: mqtt
    topic: "BlueIris/+/alert-image"

variables:
  # Extract camera from topic: BlueIris/Cam203/alert-image -> Cam203
  camera_name: "{{ trigger.topic.split('/')[1] }}"

  # Parse payload JSON, with cleanup for the known malformed pattern ", ,"
  bi_payload: >-
    {{ trigger.payload | replace(', ,', ',') | from_json }}

  # Map BI payload camera (e.g. "Cam203") to HA camera entity (e.g. camera.cam203_alert)
  cam_entity: >-
    {{ 'camera.' ~ (bi_payload.camera | lower) ~ '_alert' }}

  # Use a still image endpoint for better Android preview reliability and grabing the token value stored in Home Assistant for access to the image; this gets refreshed with every store of a new image.
  cam_image_url: >-
    https://home.example.com:8123/api/camera_proxy/{{ cam_entity }}?token={{ state_attr(cam_entity, 'access_token') }}

actions:
  - action: notify.user_devices
    data:
      title: "Blue Iris"
      message: >-
        {{ bi_payload.object }} detected on {{ bi_payload.name }}.
        Zones: {{ zone_text }}
      data:
        channel: "BlueIris"
        ttl: 0
        priority: high
        image: "{{ cam_image_url }}"
        clickAction: "{{ cam_image_url }}"

Customize these values

  • Notify target:
    • Replace notify.user_devices with your Android device notify service (or a notify group).
  • Home Assistant URL:
    • Replace https://home.example.com:8123 with your HA URL.
  • Camera entity naming:
    • This template assumes camera.cam203_alert style entities. If your entity IDs differ, adjust the cam_entity variable.

Step 3 — Confirm the camera entity naming

The template assumes:

  • Blue Iris sends: "camera":"Cam203"
  • Home Assistant entity is: camera.cam203_alert

If your entity is named differently, either adjust cam_entity or create a manual mapping.


Step 4 — Test the image URL

In Developer Tools → Templates, test:

{% set cam_entity = 'camera.cam203_alert' %}
https://home.example.com:8123/api/camera_proxy/{{ cam_entity }}?token={{ state_attr(cam_entity, 'access_token') }}

Open the rendered URL on your phone. If it loads, Android should be able to show a preview image in the notification.


Troubleshooting

“UndefinedError: bi_payload is undefined”

Common causes:

  • The automation isn’t actually triggered (templates referencing trigger won’t work when you press “Run” manually).
  • The automation YAML is invalid.

Fix:

  • Trigger it by publishing an MQTT message (real event).
  • Keep bi_payload as a block template (>-), not a quoted string.

Text shows but no image preview

Common causes:

  • Using camera_proxy_stream (streaming) instead of camera_proxy (still image).
  • The phone cannot reach your HA URL (LAN vs mobile data).
  • TLS/cert trust issues.

Fix:

  • Prefer /api/camera_proxy/ for image:.
  • Verify the image URL loads on the phone at alert time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment