Blue Iris motion alerts to notification with image in Home Assistant

If you wait until 2022.5.5 you don’t need nodered for this as I posted above

@flyinglow and @TheHolyRoger thank you for putting this together! I am setting up my cameras and just updated to Home Assistant 2022.5.5. I am very new at MQTT and HA, so I may be making a silly error. Unfortunately, the entity I have set up to receive the base64 data as an MQTT camera doesn’t seem to register anything. I get a long string sent over via MQTT, but I can’t seem to get any further.

Reading the release notes for 2022.5.5, I don’t see any reference to @TheHolyRoger’s commit. Are we certain that the native b64 decoding has been included in this release? Should the MQTT camera topic be exactly the same as the topic that BlueIris publishes to (no trailing slashes or anything further)? Thanks in advance!

I’m afraid my fix hasn’t been included in the release yet, I was advised it will likely be 2022.6, for now I’ve been manually patching my files which I can show you how to do if you’re on haos or core

Thanks for the quick reply! I wouldn’t want to waste your time on something that you’ve already worked so hard on and will be ready to go in just a couple of weeks. Thank you for offering! If they haven’t added it to 2022.6, I will absolutely take you up on that.

Has anyone tried the json ({"img":"&ALERT_JPEG","db":"&ALERT_DB"} ) to be able to view the clip with @TheHolyRoger’s code? Will that functionality work, by chance?


This is how one of my mqtt alerts is set up for a camera

- unique_id: mq_alerts_amcam1
  platform: mqtt
  topic: BI/alerts/amcam1
  encoding: b64
  name: Alerts Amcam1
3 Likes

Thank you!

If you’re on HAOS these steps will work until the patch is released:

Download this file https://raw.githubusercontent.com/home-assistant/core/0fcdca2d71578b257df2938cf350e9b07c17a176/homeassistant/components/mqtt/camera.py and save in your /config directory as mqtt_cam_fix.py

Then run this command in the SSH addon in “unprotected” mode:

docker cp /config/mqtt_cam_fix.py homeassistant:/usr/src/homeassistant/homeassistant/components/mqtt/camera.py

Restart hass, done :slight_smile:

2 Likes

@TheHolyRoger, since this stuff is still new with me, I have done your patch. If I don’t have to use Node Red, do I now create an automation and look for that MQTT topic and then do something with it?

For some reason, I still can’t wrap my head around it. I guess I am confused as to why your patch works and the other stuff did not???

You just set up your alerts & cameras as in this post, here’s an example yaml entry:

you just add inside the

cameras:
  - ...

entry of your configuration.yaml

I have all of that I believe. I am getting the MQTT topics according to MQTT Explorer. I guess where the disconnect is, how does it connect to my phone to show the picture?

You just take a snapshot of the camera to send it to your phone. If you add the camera entity to your dashboard you’ll see the last received image there. Here is my doorbell automation though, triggered when someone rings the doorbell and sends camera snapshot notification to my phone.

alias: Doorbell Notifications
variables:
  MSG: Someone's at the door
sequence:
  - variables:
      file_time: '{{ now().strftime(''%Y%m%d_%H%M%S'') }}'
# Take a snapshot of the camera and save to public http folder
  - service: camera.snapshot
    data:
      filename: /config/www/{{ file_time }}_amcam1_ha.JPG
    target:
      entity_id: camera.alerts_amcam1
# Notify the phone app for mobile notifications
  - service: notify.mobile_app_phone1
    data:
      message: '{{ MSG }}'
      title: Doorbell
      data:
        channel: doorbell
        importance: max
        tag: persistent
        persistent: true
        image: /local/{{ file_time }}_amcam1_ha.JPG
# Notify HA for persistent notifications inside hass
  - service: notify.persistent_notification
    data:
      message: '![image](/local/{{ file_time }}_ac1db_ha.JPG)'
      title: Doorbell

I have a separate automation to delete old images, but you can also change the filename and re-use the same file if you’re only bothered about the latest image

1 Like

Got it working with Android notifications however I get repetitive notifications. I don’t understand. My MQTT in node keeps cycling between disconnected to connecting to connected to disconnected…

Any ideas where to look?

I’ve not seen that… have you set anything up twice maybe? Which MQTT broker are you using? I’m using the HAOS mosquitto addon here

Using the same mosquitto addon. Really breaking my system with all the tweak attempts etc. Could it be a QOS setting? I looked at the Mosquitto broker log and get repetitive

New Client connected to XXX.XXX.X.XXX
New Connection from XXX.XXX.X.XXX
Client bi_alerts already connected, closing old connection

If it’s only BI having the problem then maybe an issue with BI itself? I’m on v5.5.6.21 x64 and only have critical updates for auto-install

Have you tried turning retain off/on for the MQTT messages to see how that affects it?

Maybe a version issue(5.5.4.1 x64 but I find that odd. Prior to discovering this image option I had all my alerts functioning correctly with MQTT. Its just the images?

I’ll keep playing with the MQTT node as I think it’s that setting.

You’re using an older version than me so I’d suggest updating to mine or newer, there might be MQTT bug fixes

just got through this setup and I’m getting notifications on my iPhone however no dice on the picture.

Instead I get an error message below, didn’t see this as something mentioned in the thread, any direction at what to look?

I can see the image in the viewer in node red (11.1.2). Running HAOS 8.1 with current core (2022.6.0) with mosquitto 6.1.2.

I’m not sure about the nodered setup but if you upgrade to the latest HA version you can use the simpler config above (without nodered)

honestly I cant really figure out your configuration, especially the notification portion, can you post the full notification automation instead of the just a portion? how do you trigger it?

1 Like