Image from email to home assistant sensor?

Hi everybody,

I couldn’t figure this out directly via Home Assistant, so I thought I’d utilize node-red… It’s a temporary quick’n’dirty thing I need to create real quick, plus I was going to learn a bit node-red, anyways.

I have extracted an image from an email imap node. The path is msg.attachments[0].content. This is definitely correct, as the viewer node displays the expected picture as a preview.

Can you please help me use this image as entity_picture for a sensor within Home Assistant?

I have tried passing it on to the sensor node as such:

I have tried to put the value for Entity picture in curly brackets as well, doesn’t fix this (it will display the curly brackets as well, not actually change the entity picture in Home Assistant).

Basically, what I’d like to achieve is this:

  1. node-red: receive email, extract attachment (it will always be one single attachment in this case, and only the expected content will be sent to this email - it’s a reolink argus eco, which can only send images via email)
  2. node-red: update a sensor within Home Assistant so that its entity picture will be the contents of the email just received
  3. Home Assistant: send this image to a signal recipient

I could do all this in node-red, I assume, but I’d like to work with Home Assistant if possible. I should be able to do everything needed, except I cannot figure out how to transfer the image from node-red to Home Assistant.

My next approach would be to test GitHub - emcniece/ha_imap_attachment: Home Assistant IMAP Attachment Component, but again, I would like to learn node-red, anyways, and this seems like a good start to learn how it and HASS can play together.

Thank you in advance for your ideas :slight_smile:

I have found a solution. Not too elegant, but functional.

Full flow

change node

This will send the image to an mqtt.camera entity:

mqtt:
  - camera:
      name: "Nodered Image"
      topic: nodered/security/reolinkargus/bild

It will also trigger an event noderedargus.

An automation will be triggered by this event and then send the image via signal. It will wait a couple of seconds beforehand, assuring the image has enough time to actually be transmitted from node-red to HA via mqtt.

Works okay so far.