How can I send an image from MQTT to the IOS App?

Images from my motion detecting camera application (Frigate) are being published to MQTT. I can view the image using a Node Red image tools viewer node, but I can’t figure out how to pass it to to the notify.mobile_app_iphone service.

image

I figure I need to use the “attachment” field in the Data property of the notify service, but I don’t know the exact syntax to pass the raw image to it. I have the image being passed through the flow as base64 for what it’s worth. I could change it to a buffer if needed. How can I get this image to that notify service?

Thanks!

Why not use the usual home assistant camera integration?

Frigate already provides the image via MQTT, and Frigate also adds an additional overlay that, at least for now, is useful for debugging. I don’t have my cameras added to Home Assistant at all for now. Beyond that, I’m just really curious how to get that buffer/base64 image into notify.mobile_app since I’ve been trying to figure this out for several hours now.

Where would I find documentation on what sort of JSON attributes the notify.mobile_app service supports?

You do realise there is an MQTT camera integration?

https://companion.home-assistant.io/docs/notifications/notifications-basic/ or the source.

For the sake of anyone stumbling across this with a similar problem (wanting to get an image from MQTT out to the IOS app) I managed to come up with a solution. It doesn’t look like it’s possible to send the image itself to the IOS app; you can only send a URL to an image. Here were the steps I used:

  1. An mqtt in node subscribes to the topic with the image and outputs it as a Base64 encoded string.
  2. A base64 node then converts this to string.
  3. A file node (not a “file in” node) writes this to the local filesystem with binary encoding. I arbitrarily chose /config/www/latestcar.png for ease of testing.
  4. (OPTIONAL) We’re sending a URL to the iPhone that the iPhone needs to be able to resolve. I didn’t want to expose my Home Assistant to the internet, so I instead upload the image I saved to /config/www/lastestcar.png to my remote webhost using node-red-contrib-ftp.
  5. Call svc: notify.mobile_app_<your device> with JSON that looks something like this:
{
    "message": "Car detected",
    "data": {
        "attachment": {
            "url": "http://YourInternetVisibleDomainHere.com/lastcar.png",
            "content-type": "png",
            "hide-thumbnail": false
        }
    }
}

2 Likes

Wow. Thanks for this!! I just got Frigate up and running and have been trying to get the notifications working. I haven’t used Node-RED before so I guess this is my opportunity to finally jump in!