MQTT Alert messages from Blue Iris - not firing?

Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Attempted to setup MQTT feeds for alerts from Blue Iris to Home Assistant this afternoon. It appears a single MQTT message was generated, which lacked the camera name in the MQTT topic. It was supposed to look like this.
Code:
MQTT Topic:      BlueIris/&NAME/Alert
Post/Payload:    {"type":"Connectivity","trigger":"OFF"}
I use MQTT for other purposes in Home Assistant, so I'm troubleshooting using the MQTT Explorer program. Only the single message with a BlueIris topic of "BlueIris/Alert" was ever received. After that, no more. :(

Blue Iris version: 5.6.7.1 x64 (12/21/2022)
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
I restarted the Mosquitto MQTT add-on, and now the add-on log isn't showing any new connections from Blue Iris. I restarted the Blue Iris service on Windows first. I'm beginning to suspect a possible problem in the Mosquitto broker, possibly a recent release issue. But I don't believe it's been updated in some time. Very frustrating. I'm not even trying to handle or process the messages in Home Assistant yet, just get them to actually arrive in the MQTT message queue. :wtf:

Nope, not Mosquitto. I've still got weather station information coming in via RTL_433 / MQTT messages, and they are just fine.
In order to better identify the different incoming connections, I've created separate MQTT users for RTL_433 and Blue Iris.

I've also sent e-mail to support at blueirissoftware dot com to hopefully get some debugging hints.
 
Last edited:

Buxton

Young grasshopper
Joined
Mar 1, 2019
Messages
33
Reaction score
17
Location
los angeles, CA
I was never able to get macros to work with BlueIris MQTT. The same holds true for JSON payloads. I use simple topics and simpler payloads. A pain yes, but it does work for what I need it to do. The LWT comes from the watchdog tab online/offline trigger.
Where are you picking up the data for the payload?

Untitled.png
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
I was never able to get macros to work with BlueIris MQTT. The same holds true for JSON payloads. I use simple topics and simpler payloads. A pain yes, but it does work for what I need it to do. The LWT comes from the watchdog tab online/offline trigger.
Where are you picking up the data for the payload?

View attachment 149529
At this VERY early stage of the game, I was setting up the ON ALERT and ON RESET conditions, and also attempting to attach an alert JPEG image in the payload. Just the one camera on the driveway at this stage. Not going to invest a lot more effort until I can determine what/why things aren't working.
Code:
[B]On Alert[/B]
MQTT Topic: BlueIris/&NAME/Alert
Post/payload: {"type":"Connectivity","trigger":"ON"}

[B]On Reset[/B]
MQTT Topic: BlueIris/&NAME/Alert
Post/payload: {"type":"Connectivity","trigger":"OFF"}
As I understand it, &NAME should be replaced with the Camera Name, while &CAM is replaced with the Camera Short Name.
Unfortunately, when I used &CAM the first time, and a message appeared in MQTT Explorer, there was no value for &CAM.
The single MQTT message that actually fired from Blue Iris had the topic "BlueIris/Alert".
Quite frustrating, I must say.

FYI: A full list of the replacement variables is on page 152 of the Blue Iris PDF documentation, entitled "TIMECODE AND OTHER MACROS".
 
Last edited:
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Funny thing tonight. TONS of messages on the Mosquitto broker log, all from client (unknown). I know the new BlueIris user and password I created in Mosquitto is working, because I tested it from MQTT Explorer to make the connection. No problems, connected instantly. So, whatever is going on, it definitely appears to be Blue Iris as the source of the issue.
 

Buxton

Young grasshopper
Joined
Mar 1, 2019
Messages
33
Reaction score
17
Location
los angeles, CA
Funny thing tonight. TONS of messages on the Mosquitto broker log, all from client (unknown). I know the new BlueIris user and password I created in Mosquitto is working, because I tested it from MQTT Explorer to make the connection. No problems, connected instantly. So, whatever is going on, it definitely appears to be Blue Iris as the source of the issue.
Try just using "BlueIris/YourCameraName/Alert" and for the payload use "Off". All without quotes and substitute the name of the camera for YourCameraName. If it works, then you can be sure that it's the use of macros and/or json payloads that is causing the problem.
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Try just using "BlueIris/YourCameraName/Alert" and for the payload use "Off". All without quotes and substitute the name of the camera for YourCameraName. If it works, then you can be sure that it's the use of macros and/or json payloads that is causing the problem.
Nope, not seeing anything in either HA's Mosquitto log (debug is enabled) nor in MQTT Explorer. :(
 

Buxton

Young grasshopper
Joined
Mar 1, 2019
Messages
33
Reaction score
17
Location
los angeles, CA
Nope, not seeing anything in either HA's Mosquitto log (debug is enabled) nor in MQTT Explorer. :(
Here is my MQTT set up. Make sure that the Mosquitto server IP and port is correct in BlueIris. It must match your Mosquitto config.
 

Attachments

Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Yup, that was the very first thing I confirmed when things stopped working.
I see in the BlueIris phpBB support forum, there was a message back in August.
Unfortunately, there were no more replies to the thread.

Re: Issues with availability MQTT messages by BI5
Post by karson » Fri Aug 19, 2022 5:10 pm

I'm seeing similar oddities with MQTT topics/payloads not sending when configured under Alerts -> Actions -> On alert/On reset any longer, too. I have a support ticket in earlier today awaiting a reply.

The general -> Digital IO and IoT configuration test works successfully and you can see the topic publish in MQTT explorer, but nothing publishes on the actual camera config any longer. It did work 4-6 weeks ago when I was monitoring it, but since taking my eye off it, notice it no longer does.
 

Buxton

Young grasshopper
Joined
Mar 1, 2019
Messages
33
Reaction score
17
Location
los angeles, CA
I noticed with Camera Alerts that if any of the conditions are false, and there are many conditions, then the alert will not fire. Which gives you a fine grain adjustment, but can also easily cause failure. When you run the test on the alert itself, does it fire (the lightning bolt icon)? You could try different combinations of conditions to see what is causing the failure as you know from the general setup that BlueIris is talking to the broker.
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
I just found out what was going on. And I'm surprised I did not consider it sooner.

I had put the DNS node name for the Home Assistant system into the MQTT Configuration page. Now, I know, it's not the same as using the IP Address. That's why I put the DNS node name and the 192.168.1.xxx LAN IP address into the file C:\Windows\System32\drivers\etc\hosts . I opened a DOS / CMD window on the Blue Iris system, and pinged the DNS node name of the HA box. Windows completely ignored the hosts file entry, and returned pings from my WAN IP address. As you might understand, I do NOT forward any external ports for MQTT, that traffic is only local from my LAN.

When I put the literal 192.168.1.xxx LAN IP address into the MQTT Configuration page, Blue Iris messages started appearing, and consistently.
Go figure. Thanks, Microsoft!! (not)
 

Buxton

Young grasshopper
Joined
Mar 1, 2019
Messages
33
Reaction score
17
Location
los angeles, CA
Yeah, DNS at a top level is easy. Layers down it's black magic. So you're saying that macros and JSON payloads do work? If so, I'll have to try that as they previously did not work.
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Using the macro substitution &ALERT_JPEG definitely sends the Base64 data of a JPEG file to Home Assistant.

1672546439970.png

No JSON, no HTTP syntax, nothing. Payload is simply:
Code:
&ALERT_JPEG
Now my next problem is getting Home Assistant to successfully decode the BASE64 payload.
Setup an MQTT Camera with the topic and a unique name and ID, but so far, no images appear. :(
I do believe it's time to call it a night, and continue wrestling with this more tomorrow.
 
Joined
May 1, 2019
Messages
2,215
Reaction score
3,504
Location
Reno, NV
Using the macro substitution &ALERT_JPEG definitely sends the Base64 data of a JPEG file to Home Assistant.

View attachment 149612

No JSON, no HTTP syntax, nothing. Payload is simply:
Code:
&ALERT_JPEG
Now my next problem is getting Home Assistant to successfully decode the BASE64 payload.
Setup an MQTT Camera with the topic and a unique name and ID, but so far, no images appear. :(
I do believe it's time to call it a night, and continue wrestling with this more tomorrow.
is the camera a Dahua?
 
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
Interesting. I started out with the MQTT Payload as simply &ALERT_JPEG and that never worked.
Changed it to a JSON dictionary of three data values, and these were reliably written to disk as JSON text with a .JPG extension, whenever camera.snapshot was fired.
I've since changed it to a pair of MQTT messages, one for the JSON data and another for the Base64 image data.

I'm seriously hoping @Holbs can provide some better insight.

After splitting the Base64 image data and JSON event data into two separate actions, it appears images and data are now coming through successfully. :secret:

Code:
MQTT topic: BlueIris/&CAM/Image
Post/payload: &ALERT_JPEG
Code:
MQTT topic: BlueIris/&CAM/JSON
Post/payload: { "camera":"&CAM", "time":"%Y%m%d_%H%M%S", "dbid":"&ALERT_DB" }
Two of the critical changes were the JSON parsing syntax for the automation, and the MQTT image encoding definition:
Code:
- alias: Alert JSON Living Room
  description: Camera activity detected in Living Room
  variables:
    cam_name: "{{ trigger.payload_json.camera  }}"
    img_time: "{{ trigger.payload_json.time    }}"
    bi_dbid: "{{ trigger.payload_json.dbid    }}"
Code:
mqtt:
  camera:
  - unique_id: living_room_alert
    topic:     BlueIris/LivingRoom/Image
    name:    "Alert LivingRoom"
    image_encoding:  b64
 
Last edited:
Joined
Aug 3, 2015
Messages
3,827
Reaction score
12,289
Location
Charlotte
So, today I finally got the notifications working from the Home Assistant companion app on my iPhone. EXCEPT it wasn't respecting the 'clickAction:' value where I provided a URL back to the Blue Iris ui3.htm server page. Turns out, ya absolutely, positively, GOTTA include the 'url:' value or it doesn't work. Updates to my previous code shown above:

Trigger actions:
Code:
MQTT topic:    BlueIris/&CAM/JSON
Payload:       { "camera":"&CAM", "time":"%Y%m%d_%H%M%S", "dbid":"&ALERT_DB", "clipid":"&ALERT_CLIP", "memo":"&MEMO" }
Home Assistant automation:
Code:
  variables:
    cam_name: "{{ trigger.payload_json.camera  }}"
    img_time: "{{ trigger.payload_json.time    }}"
    bi_dbid: "{{  trigger.payload_json.dbid    }}"
    bi_clip: "{{  trigger.payload_json.clipid  }}"
    ai_memo: "{{  trigger.payload_json.memo    }}"

service: notify.mobile_app_keiths_iphone
data:
  title: Blue Iris activity alert
  message: Activity in {{ cam_name }} at {{ img_time }}
  data:
    image: /local/{{ cam_name }}.jpg
    url: >-
      https://myurl.duckdns.org:12345/ui3.htm?maximize=1&tab=alerts&cam={{
      cam_name }}&rec={{ bi_clip }}
    clickAction: >-
      https://myurl.duckdns.org:12345/ui3.htm?maximize=1&tab=alerts&cam={{
      cam_name }}&rec={{ bi_clip }}
 
Last edited:
Top