Attach image from image sensor in notification

Hello,
I am trying to attach an image from an image sensor in an iOS notification. I know how to do this with a local image when I send a picture of who is at my front door. My problem is that I don’t know how to include the image from an image sensor.

Specifically, when my Deebot throws an error, I would like to include the current map from the Ecovacs integration so I know where it got stuck. I know that there is an image.deebot_map sensor and that there is an attribute with a path to the image like this: /api/image_proxy/image.deebot_map?token=4723e8dd0dc94ec480d82e0ca06e884715ea2be4aee6ffa5d0419f2241123a05
but I don’t know how to translate that to YAML

the code that works for my doorbell looks like:

data:
  message: Person detected at the front door
  data:
    subtitle: ""
    image: /local/tmp/front_door.jpg
action: notify.my_devices

Any guidance would be appreciated. My first guess was something like:

data:
  message: Deebot has an error
  data:
    subtitle: ""
    image: {{ state_attr('image.deebot_map','entity_picture') }} 
action: notify.my_devices

But, alas, that did not work.

I’m looking to do this as well, but no luck yet.

I was hoping the new snapshot action for images would do this but all I got was a corrupted image.

The image from the image entity of the deebot map returns an SVG. We need to figure out how to convert it to JPG. At least on an iPhone the notification can not handle the SVG format.

ChatGPT has the following suggestion. Maybe I’ll try this in some near future:

Yes! You can create a Home Assistant custom integration that provides an SVG-to-JPG conversion service. This integration will:
1. Monitor a folder for SVG files (optional).
2. Convert SVG files to JPG using Python (cairosvg or Pillow).
3. Expose a Home Assistant service (image.convert_svg_to_jpg).

  1. Create the Custom Component Directory

Navigate to your Home Assistant custom_components folder (create it if necessary):

mkdir -p /config/custom_components/svg_to_jpg
cd /config/custom_components/svg_to_jpg

  1. Create manifest.json

This file tells Home Assistant about your integration.

{
  "domain": "svg_to_jpg",
  "name": "SVG to JPG Converter",
  "version": "1.0.0",
  "documentation": "https://github.com/your-repo/svg_to_jpg",
  "dependencies": [],
  "codeowners": ["@your-github"],
  "requirements": ["cairosvg"]
}

cairosvg is a lightweight library for converting SVG to PNG or JPG.
  1. Create init.py

This initializes the integration and registers the service.

import logging
import os
import cairosvg
import homeassistant.helpers.config_validation as cv
import voluptuous as vol

from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers.typing import ConfigType

_LOGGER = logging.getLogger(__name__)

DOMAIN = "svg_to_jpg"

SERVICE_CONVERT = "convert_svg_to_jpg"

CONF_INPUT_PATH = "input_path"
CONF_OUTPUT_PATH = "output_path"

SERVICE_SCHEMA = vol.Schema(
    {
        vol.Required(CONF_INPUT_PATH): cv.string,
        vol.Required(CONF_OUTPUT_PATH): cv.string,
    }
)


def setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the SVG to JPG conversion service."""

    def handle_convert(call: ServiceCall) -> None:
        """Handle the conversion request."""
        input_path = call.data[CONF_INPUT_PATH]
        output_path = call.data[CONF_OUTPUT_PATH]

        if not os.path.exists(input_path):
            _LOGGER.error("SVG file not found: %s", input_path)
            return

        try:
            _LOGGER.info("Converting %s to %s", input_path, output_path)
            cairosvg.svg2png(url=input_path, write_to=output_path.replace(".jpg", ".png"))
            os.system(f"convert {output_path.replace('.jpg', '.png')} {output_path}")  # Convert PNG to JPG
            _LOGGER.info("Conversion successful: %s", output_path)
        except Exception as e:
            _LOGGER.error("Error converting file: %s", e)

    hass.services.register(DOMAIN, SERVICE_CONVERT, handle_convert, schema=SERVICE_SCHEMA)

    return True

  1. Create services.yaml

This defines how the service works.

convert_svg_to_jpg:
  description: "Convert an SVG file to a JPG image"
  fields:
    input_path:
      description: "Path to the input SVG file"
      example: "/config/www/input.svg"
    output_path:
      description: "Path to save the output JPG file"
      example: "/config/www/output.jpg"

  1. Add to configuration.yaml

Enable the integration:

svg_to_jpg:

Restart Home Assistant to apply the changes.

  1. Test the Service

Go to Developer Tools → Services and call:

service: svg_to_jpg.convert_svg_to_jpg
data:
  input_path: "/config/www/input.svg"
  output_path: "/config/www/output.jpg"

This will convert input.svg into output.jpg.

Next Steps
• Add a folder monitoring feature.
• Store images in a media folder (/media).
• Improve error handling.

Do you need additional features?

Here is a first implementation: https://github.com/der-punkt/svg_to_png_addon/