Blue Iris motion alerts to notification with image in Home Assistant

The BI/+/alert-image-b64 node should have “a String” for “Output”.

I am talking about the image to buffer node

Progress, I am now getting notifications to my phone with an image, however the image is extremely small, maybe 1cm x 1cm. last piece of the puzzle to come

That’s correct. You should get that if you import the Node Red code I posted in the first message.

I also have my cameras on a VLAN that has no internet access. I am able to use the Blue Iris integration with no problems. Everything is happening on my LAN, except when there’s a notification sent to my phone, that of course has to go outside my LAN to get to my phone.

I’m also looking into this but have quite not made it yet.
According to this post it’s possible to convert the image by casting the string to base64_decode

You should be able to read the mqtt in orignal format with mqtt sensor

- platform: mqtt
  name: base64camera
  state_topic: BI/<CAM_NAME>/alert-image-b64

Sorry, not a complete solution as I’m still working on this but maybe something that can point you in the right direction?

1 Like

Here is a little bonus I am in love with. On Android, to get notifications instantly you need to set the ttl and priority as shown below. Also, adding a clickAction can make it so when you tap the notification image, it opens up a live UI3 feed in a browser to that camera (youll need to have port forwarding and all the remote access jazz setup to see it when not on local wifi, replace my 192.168.1.148:81 with wherever your UI3 lives). But here is my config:

{
   "message": "Camera alert: " & $split(topic,'/',3)[1],
   "data":
     {
       "ttl": 0,
       "priority": "high",
       "clickAction": "http://192.168.1.148:81/ui3.htm?maximize=1&tab=alerts&cam=" & $split(topic,'/',3)[1],
       "image": "/api/camera_proxy/camera." & $split(topic,'/',3)[1] & "_alert"
     }
}
2 Likes

@flyinglow I just found out that Blue Iris has a way to go directly to the clip of an alert (here). It uses an &ALERT_DB macro. If we could somehow get that into HA then you could make it so when you tap the picture notification it takes you to the actual clip that generated the picture in UI3.

I am at a loss though as to how to pass both the &ALERT_JPEG and &ALERT_DB via MQTT and have it work (that is, not have the &ALERT_DB mess with the base64 image). Any ideas on how you would be able tweak the BI sending and node red reception of the &ALERT_DB?

@flyinglow to answer my own question, I got it to work by passing the message via JSON! The first step was in the BI camera settings to change the payload to this:

{"img":"&ALERT_JPEG","db":"&ALERT_DB"}

Then in node-red I had to change the first mqtt node to output “a parsed JSON object” instead of “a String”. And in the following nodes have them look at payload.img for the image and then add a change node before mqtt out to move payload.img to just payload.

Now when I tap the image notification on my phone, it goes straight to open up the video clip that generated the image alert. Then after reviewing the clip all you have to do is click the X in the upper left that shows live view. Its perfect!

[{"id":"f64fc2c05427d1ff","type":"mqtt in","z":"115d468f22580d59","name":"BI/+/alert-image-b64","topic":"BI/+/alert-image-b64","qos":"2","datatype":"json","broker":"f2d4bba523eb0568","nl":false,"rap":true,"rh":0,"inputs":0,"x":410,"y":360,"wires":[["2bfc3a4d82e1f0c5","1ab27a3cec8f75fd"]]},{"id":"2bfc3a4d82e1f0c5","type":"image viewer","z":"115d468f22580d59","name":"","width":160,"data":"payload.img","dataType":"msg","active":true,"x":620,"y":400,"wires":[[]]},{"id":"1ab27a3cec8f75fd","type":"jimp-image","z":"115d468f22580d59","name":"Image to buffer","data":"payload.img","dataType":"msg","ret":"buf","parameter1":"{\"name\":\"clone\",\"parameters\":[]}","parameter1Type":"json","parameter2":"","parameter2Type":"num","parameter3":"0","parameter3Type":"num","parameter4":"RESIZE_NEAREST_NEIGHBOR","parameter4Type":"none","parameter5":"","parameter5Type":"none","parameter6":"","parameter6Type":"none","parameter7":"","parameter7Type":"none","parameter8":"","parameter8Type":"","sendProperty":"payload.img","parameterCount":0,"jimpFunction":"none","selectedJimpFunction":{"name":"none","fn":"none","description":"Just loads the image.","parameters":[]},"x":650,"y":360,"wires":[["79a0b47462d782c9"]],"icon":"font-awesome/fa-image"},{"id":"afc5b4de34a78c8c","type":"mqtt out","z":"115d468f22580d59","name":"BI/+/alert-image","topic":"","qos":"1","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f2d4bba523eb0568","x":1280,"y":360,"wires":[]},{"id":"79a0b47462d782c9","type":"change","z":"115d468f22580d59","name":"Change topic (-b64)","rules":[{"t":"change","p":"topic","pt":"msg","from":"/alert-image-b64","fromt":"str","to":"/alert-image","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":360,"wires":[["843d20b18246d1f4","6353dca61b1841d7"]]},{"id":"843d20b18246d1f4","type":"api-call-service","z":"115d468f22580d59","name":"Notify w/ Image","server":"f11c46a6.207018","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_iphone","entityId":"","data":"{\t \"message\": \"Camera alert: \" & $split(topic,'/',3)[1],\t \"data\":\t {\t \"ttl\": 0,\t \"priority\": \"high\",\t \"clickAction\": \"http://www.yourblueirisdomain.com:81/ui3.htm?maximize=1&tab=alerts&cam=\" & $split(topic,'/',3)[1] & \"&rec=\" & payload.db,\t \"image\": \"/api/camera_proxy/camera.\" & $split(topic,'/',3)[1] & \"_alert\"\t }\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1080,"y":420,"wires":[[]]},{"id":"6353dca61b1841d7","type":"change","z":"115d468f22580d59","name":"Move payload (img)","rules":[{"t":"move","p":"payload.img","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":360,"wires":[["afc5b4de34a78c8c"]]},{"id":"f2d4bba523eb0568","type":"mqtt-broker","name":"HASS MQTT","broker":"localhost","port":"1883","clientid":"NodeRed","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"f11c46a6.207018","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

3 Likes

Nicely done @ronaldjeremy!

Hi what you guys setup on BI side. Because I’m not getting any b64 image data from it. All im getting coming from mqtt is the actual wording of “&alert_jpeg”. The macro for db data come through so link to the clip does work. Only think I do not have is BI HACS integration. I don’t need bi camera steam and I do my own mqtt motion alert. So I have no need to install the integration plus the creator no longer maintain the project.

image

1 Like

I’m on BI v4 and can’t get &ALERT_JPG to work … is this a BI v5 only feature?

I’ve got things setup per this thread and the way @ronaldjeremy updated. Anyone have any reason why I would be getting a “Failed to load attachment. Response status code was unacceptable: 404.” error?

1 Like

Here’s my version of a notifier using appdaemon. I use this with telegram and it works great. By using the database record ID, it doesn’t require doing anything the camera feed - it grabs the image that was used in the AI processing from the BI database. It requires that BI be setup to notify on an AI alert topic with a payload like { "time" : "%Y-%m-%d %H:%M:%S", "type" : "&TYPE", "trigger" : "ON", "memo" : "&MEMO", "alert_db" : "&ALERT_DB", "alert_path" : "&ALERT_PATH", "data" : &JSON }

Code: HASS blue iris notify · GitHub

3 Likes

Is there a solution, for Android (perhaps with Telegram) and without Node Red?

That’s exactly what I just posted. Notifications without nodered using telegram.

I’m also getting this error: “Failed to load attachment. Response status code was unacceptable: 404.”

I am getting an error in node red when it receives the MQTT message it erros out in the Viewer and image to buffer node “Error Processing Image”

I used the Node Red flow in the first post apart from changing MQTT broker details to my own I haven’t changed anything.

it gives this error in the debug log…

Error: ENAMETOOLONG: name too long, open 'NO RECORD/9j/4AAQSkZJRgABAQEAYABgAAD/4QBgRXhpZgAATU0AKgAAAAgAAgExAAIAAAAKAAAAJodpAAQAAAABAAAAMAAAAABCbHVlIElyaXMAAAGQAwACAAAAFAAAAEIAAAAAMjAyMjowNTowMiAyMDo0MDo1NgAAAP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIBDgHgAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1

(I shortened this message as it was too large to post in forum 20’000 charters long)

I have this in my BI alert …
Topic: BI/&CAM/alert-image-b64
Payload: &ALERT_JPEG

I am running BlueIris V5.4.9

Any Ideas what I could be doing wrong? it is a 1920x1080 image is this too large?

The “NO RECORD” at the beginning of the mqtt message doesn’t look correct to me.

For reference I worked it out. I still dont know why it is happening but if I put a change node after the mqtt input node and used it to replace the “NO RECORD” with “data:image/jpeg;base64,” it works now.
image

1 Like

Glad you got it figured out! I have no idea why you ran into that problem.

Thanks for being one of the heroes of the Internet who posts the answer when they solve their own problem.