Can not send images with discord integration

Hi,

I managed to send notifications to discord, but I can’t attach any images to my notifications. I followed the documentation and added the url to configuration.yaml

homeassistant:
  allowlist_external_urls:
    - "http://10.102.50.10/snap.jpeg"
    - "http://10.102.50.10/snap_2.jpeg"

Here’s the code I am trying to execute:

service: notify.home_assistant_bot
data:
  message: "A message from Home Assistant"
  target: ["xxxx"]
  data:
    verify_ssl: false
    images:
    - "http://10.102.50.10/snap.jpeg"

But this results in this error in my home assistant logs:

Path not allowed: http://10.102.50.10/snap.jpeg

20:56:32 – (WARNING) Discord - message first occurred at 20:41:48 and shows up 3 times

(The notification without text is being sent to discord)

Error is triggered from here https://github.com/home-assistant/core/blob/8a9f9b94ef8437869895e0227eb0ecf55b38bd92/homeassistant/components/discord/notify.py

image
Why is the code checking if the file is on the disk if it’s a URL in my LAN? Is this a bug?

Oh god, nevermind!!

I had to use

  data:
    urls:
    - "http://10.102.50.10/snap.jpeg"

instead of

  data:
    images:
    - "http://10.102.50.10/snap.jpeg"
1 Like

does this make your image show up in discord? i’ve been getting the messages but don’t get the image attachment

1 Like

Hi,

for me the following seems to work with my own core install, with the frigate HACS installed. Slightly out of date currently, but that should not matter. Anyway, relevant parts:

alias: Frigate motion detection message to discord
description: ""
trigger:
  - platform: mqtt
    topic: frigate/events
    payload: new
    value_template: "{{ value_json.type }}"
    enabled: true
action:
  - service: notify.discord_bot_or_whatever_you_named_yours
    data:
      message: >-
        Saw a {{trigger.payload_json["after"]["label"]}} on
        {{trigger.payload_json["after"]["camera"]}} 
      target:
        - "<your discord target channel id here>"
      data:
        verify_ssl: false
        urls:
          - >-
            http://localhost:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
          - >-
            http://localhost:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg

This uploads both the specific thumbnail and the full camera snapshot to discord. I did not experiment with the mp4 clip so far, which would be same but /clip.mp4

I did have to add localhost to the allowlist_external_urls portion of the configuration file like this:

homeassistant:
   allowlist_external_urls:
     - "http://localhost:8123/"

Or your messages will lack the picture and you’ll get some log entries with "URL not allowed: "

1 Like