MQTT payload issues (jpeg images) from Blue Iris. Maybe a Post issue?

thewolf56

Getting the hang of it
Joined
Mar 31, 2017
Messages
101
Reaction score
60
Location
AZ
A while back, I tried to setup Blue Iris and Home Assistant through the Blue Iris Integration in Home Assistant and MQTT to send me notifications through Home Assistant with the Blue Iris alert image attached. I had no success at the time, so I settled for setting up binary sensors (some with AI required objects) and simple payloads of "on". This worked perfectly and I was able to setup Home Assistant to take it's own snapshot of the image for the notification, but with the processing delays, this snapshot was not always accurate as to what actually triggered Blue Iris.

I recently started trying to get the Blue Iris Alert Image working again. Yesterday, I learned that a possible source of my issue was that the POST tab of my camera never had Post JPEGs set, so I set it and enabled the test automation in Home Assistant for the notification with the BI Alert Image.

An Amazon delivery driver came into my courtyard and I received a notification through Home Assistant with the Blue Iris alert image attached with the AI identification boxes on the jpeg. Great news. then my wife went to the courtyard to get the package and I got a new notification with the JPEG attached, only it was the same Blue Iris alert image with the Amazon driver. I've tried checking various settings, but even just using the testing section of the Alerts, I still only get the Amazon delivery driver photo.

I double checked the folder where Home Assistant stores the snapshot. The metadata for the photo gets updated as a new file is saved before being attached to the notification, but it's still the same image. I even tried changing the automation so that it saves the payload jpeg as a different name, but even the newly-named image has the same image.

Here is my On Alert settings
1698948726677.png

Code:
MQTT topic: BI/courtyard_camera/alert-image-b64
Post/payload: { "camera":"&CAM", "time":"%Y%m%d_%H%M%S", "dbid":"&ALERT_DB" }
Here is my Post settings for the camera
1698948861769.png


I would love to figure this out as there are a few cameras I would really like to add the BI alert images to the notifications. Any help is appreciated
 

Jacoob

n3wb
Joined
Dec 14, 2018
Messages
1
Reaction score
1
Location
uk
Did you manage to get it working? I have it working on two cameras, but a third is doing exactly the same as you described. They are all set up identially so I'm really not really sure what else to try!
 

thewolf56

Getting the hang of it
Joined
Mar 31, 2017
Messages
101
Reaction score
60
Location
AZ
No, it is still not working. I've tried posting in a few different places, but still no help has been forthcoming. I did check the MQTT logs when trying to test and it was an error I've never seen before. I'm away from my computer right now, but I'll see if I can dig it up.
 

The Automation Guy

Known around here
Joined
Feb 7, 2019
Messages
1,415
Reaction score
2,814
Location
USA
I experience the same issue with a camera that uses the pushover app to send me notifications of alerts. I will get the alert correctly, but the image attached is usually the previous alert's image (which might be hours or even days earlier). Rarely the image will be the same for multiple alerts before eventually changing to a newer (but not the correct) image. I think this happens when several alerts occur within a very short period of time and when this happens all those alerts have the same incorrect image attached. I don't use MQTT for this however which really points to the problem lying somewhere within the trigger/alert/notification setup (or underlying bug within this section of programming code) and not specifically with the communication method being used (ie MQTT or Pushover). I haven't been bothered to track the issue down myself, but perhaps that information can help point you in the right direction.

The strange thing is that my system worked reliably for a long time before starting to send out the wrong image. To my knowledge, nothing changed in my camera setup. I've surely upgraded BI over time, but the problem did not begin right after an update (that would have been an obvious red flag). It really seemed like the system worked correctly one day and then started to attach the wrong image to the notification the next day.
 
Last edited:

thewolf56

Getting the hang of it
Joined
Mar 31, 2017
Messages
101
Reaction score
60
Location
AZ
I found the error that was posted in MQTT

Exception in message_received when handling msg on ‘BI/courtyard_camera/alert-image-b64’: ‘b’{ “camera”:“Courtyard”, “time”:“20231102_105157”, “dbid”:"" }’’ Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py”, line 43, in wrapper msg_callback(msg) File “/usr/src/homeassistant/homeassistant/components/mqtt/camera.py”, line 110, in message_received self._last_image = b64decode(msg.payload) ^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.11/base64.py”, line 88, in b64decode return binascii.a2b_base64(s, strict_mode=validate) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ binascii.Error: Invalid base64-encoded string: number of data characters (37) cannot be 1 more than a multiple of 4
 

thewolf56

Getting the hang of it
Joined
Mar 31, 2017
Messages
101
Reaction score
60
Location
AZ
So, I tried a different MQTT topic and payload that I had read as a possibility and it still didn't work. After a few days, it started working out of nowhere and even tried it on a 2nd camera (this time, it only took a couple of hours for it to work)

What worked this time:
1706292159152.png

Home Assistant:
I use a mqtt.yaml file, so it would be slightly different if you do everything in the config.yaml file

Code:
camera:
- topic: BlueIris/image/"Camera's Short Name in Blue Iris"
  name: Camera Name Alert MQTT Image
  unique_id: alert_camera_image
  image_encoding: b64
I'm still not sure what happened, but it has been working for over a week now. I have not upgraded Blue Iris at all since the issue started, but I have upgraded Home Assistant 2023.12.3 and HA's Mosquitto Broker add-on. The funny thing is, I only noticed that it started working because there was a picture in the Overview dashboard (I never use it but keep it around just in case) for the MQTT camera for the alert when I was looking for another recently-added device I was working on. I checked if the picture changed if I triggered it through Blue Iris (physically and not through the alert testing) and it did change. I disabled the home assistant action for the Home Assistant snapshot for notifications and tried the new one and it worked.
 
Top