#Automation to send Frigate images to discord

1 messages · Page 1 of 1 (latest)

normal dew
#

I've been trying to get this working for a while now, I'm sure its just a syntax thing but I cant figure it out, here is my current automation:
`
alias: Frigate notification
description: ""
triggers:

  • topic: frigate/events
    trigger: mqtt
    conditions: []
    actions:
  • action: notify.homeassistant
    metadata: {}
    data:
    target: "xxx"
    message: >-
    {{trigger.payload_json["after"]["camera"]}} -
    {{trigger.payload_json["after"]["label"]}} detected
    data:
    photo:
    - url: >-
    http://192.168.1.3:5000/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
    caption: >-
    A {{trigger.payload_json["after"]["label"]}} was detected on the
    {{trigger.payload_json["after"]["camera"]}} camera.
  • delay:
    hours: 0
    minutes: 0
    seconds: 10
    milliseconds: 0
    mode: single
    `
    Within the 2nd data: block I've tried photo, images, urls and have tried some with single quotes around them and some without, but just cant figure this out. The message gets sent but the image never does.

Any help please?

viscid flame
#

seems like you want the second one, but I don't know what that will do with URLs that are only accessible to your local HA

normal dew
#

yeah thats what I based my testing off, I have 6 similar automations all with variations of those on there, none seem to work tho

viscid flame
#

ok, I don't have any personal experience with it. but I wouldn't expect what you posted to work

normal dew
#

yeah I think "images" or "urls" should work instead of "photo", but tried those too

#

(single quotes)

#

and similar thing with "urls"

viscid flame
#

please format any code

strange grailBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

viscid flame
#

it just doesn't seem like you're actually following the syntax in the example

#

It says:

#
- action: notify.discord
  data:
    message: "A message from Home Assistant"
    target: ["1234567890", "0987654321"]
    data:
      verify_ssl: False
      urls:
      - "https://example.com/image.jpg"
      - "https://example.com/video.mp4"
normal dew
#

`

#
  - action: notify.homeassistant
    metadata: {}
    data:
      target: "xxx"
      message: "frigate 5 : urls"
      data:
        urls:
          - >-
            'http://192.168.1.3:5000/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg'
#

when I save it in the GUI, then go to Edit YAML it seems to change the formatting (eg adding the - >- bit)

#

maybe it needs double-quotes? but I have quotes inside the URL already, let me try escaping them

#

no get a malformed error

viscid flame
#

That's okay. It's just not what you had earlier

#

You need to provide a list of URLs

normal dew
#

I just added the verify_ssl and adding allowlist_external_urls, let me restart HA and try again

#

there will only be 1 image attached to the message, not multiple

viscid flame
#

Does not matter

#

Need to follow the docs

normal dew
#

the list can be anywhere from 1 to xx lines, so I just added 1 line

#

no luck after editing configuration.yml and restarting

normal dew
#

I think I've got further, installed the Frigate integration in HACS and now get working URLs that work in a web broswer:

#
action: notify.homeassistant
data:
  target: 'xxx'
  message: >-
    {{trigger.payload_json["after"]["camera"]}} -
    {{trigger.payload_json["after"]["label"]}} detected
  data:
    urls:
      - >-
        http://192.168.1.3:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg
#

I can see in the trace the URL that get generated and it now works

#

however its still not being sent to Discord

#

hmm, let me change the configuration.yml for the new IP:port in allowlist_external_urls and restart

#

SUCCESS

#

finally

viscid flame
#

I didn't realize that you didn't have the Frigate integration installed 🙂

normal dew
#

if anyone else comes here with the same issue the way I resolved it was:

  1. install the Frigate integration
  2. change the port number from Frigate port 5000 to HA port 8123
  3. edit your configuration.yml file to add the below and then restart HA
#
homeassistant:
  allowlist_external_urls:
    http://192.168.1.3:8123/api/frigate/notifications/
#

yeah, I thought that use could be used on frigate port 5000

#

didnt realize it was a custom URL only created by the integration 🤦‍♂️

viscid flame
#

well, earlier it looked like you were trying to use the Frigate API directly (if they even have one)

normal dew
#

I actually thought they did

viscid flame
#

maybe they do

#

in any case, I don't suggest confusing teh two

normal dew
#

but couldnt get it to work (copy-pasting the URL into a web browser would give me a 404 error)

#

anyway I'm not going to mess around with it now, its working 🙂

#

thanks for your pointers, nudged me the right way