Matrix sending message and snapshot from Frigate

Hello all. I have a Frigate instance setup and communicating with HA. I have HA configured with Matrix and it will send messages when Frigate detects a person. Ok good. But it will not include the thumbnail regardless of what I do.

I have 2 cameras and it also will not distinguish which camera triggered the alert. Any chance anyone can shed some light on this?


alias: Matrix
  - platform: mqtt
    topic: frigate/events
  - service: notify.matrix_notify
      message: A {{trigger.payload_json["after"]["label"]}} was detected in your office
        by camera {{trigger.payload_json["after"]["camera"]}}.
  mode: single

This will send an alert on finding a person, but it won’t process the second part to state which camera.

This is what I added in for thumbnails to work (but they don’t):

alias: Matrix
  - platform: mqtt
    topic: frigate/events
  - service: notify.matrix_notify
      message: A {{trigger.payload_json["after"]["label"]}} was detected in your office
        by camera {{trigger.payload_json["after"]["camera"]}}.
            image: 'http://MY_IP_AND_PORT/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android'
            tag: '{{trigger.payload_json["after"]["id"]}}'
            when: '{{trigger.payload_json["after"]["start_time"]|int}}'
  mode: single

This will fail completely and not even trigger. The errors I get state there is an undefined trigger.

Any suggestions?

Thank you. I edited my initial post.

I apologize for that.

1 Like

No problem. Thanks for correcting it. I don’t have frigate so unless someone else who does use it answers can you post the formatted event data (you can listen to an event in Developer Tools → Events).

I apologize, I don’t know which one to use for this event. But when I go to Automation > Matrix and then run the action, this is what I get:

Error rendering data template: UndefinedError: 'trigger' is undefined

I don’t think this is an issue with Frigate itself. This seems to be that the Matrix automation isn’t picking up the image that Frigate has made to send in the alert. I do get the message portion of the alert, just no thumbnail.

You can’t test it that way.

Manually running the actions skips the triggers (and conditions) and just runs the actions, therefore there are no trigger variables and your templates fail.

Try testing it by actually publishing to the mqtt topic.

But without the event data it is impossible to say if your templates are valid or not.

I finally figured it out. I appreciate your help and patience.

event_type: automation_triggered
  name: Matrix
  entity_id: automation.matrix
  source: mqtt topic frigate/events
origin: LOCAL
time_fired: "2023-12-20T15:03:10.946802+00:00"
  parent_id: null
  user_id: null

I have several of these during the listening period.

Is this what you were needing?

Thank you.


What data is published to the topic:


The advice I gave above about manual testing and this error is still relevant:

I’m trying basically the same thing and similarly can’t get the snapshot attached. But as far as I can tell my issue is one of permissions.

My logs show the following errors:

2023-12-30 18:05:23.855 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/share/homeassistant/lib/python3.11/site-packages/homeassistant/components/matrix/”, line 462, in _send_image
async with, “r+b”) as image_file:
File “/usr/local/share/homeassistant/lib/python3.11/site-packages/aiofiles/”, line 98, in aenter
self._obj = await self._coro
File “/usr/local/share/homeassistant/lib/python3.11/site-packages/aiofiles/threadpool/”, line 94, in _open
f = yield from loop.run_in_executor(executor, cb)
File “/usr/lib/python3.11/concurrent/futures/”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
PermissionError: [Errno 13] Permission denied: ‘/media/clips/back_door-1703976060.555205-qe2oa9.jpg’

The file it’s trying to send is created by a docker-ized instance of Frigate (I do not run HAOS, I’ve got HA in a python venv and Frigate via docker separately) and is owned by root with permissions 644, while HA is not running as root. If I manually change the permissions on the file to 777 then it works. But I don’t know how to get Frigate to do that for me…


I managed to set up incrond so that the permissions on all my snapshot files are changed 664 and the group is changed to one my HA process can access. Kind of hacky, but now it’s working…