Hi,
I have following setup:
A jpg image being pushed into home/Mailbox/camera/image
MQTT topic.
The HA is configured via auto discovery, which creates image.mailbox_mailbox_camera
.
This all works fine (I can publish a jpg into the topic above and it is displayed on the Picture Card).
What I am trying to do with that image is to save it to disk when it is published.
I have tried to create an automation, but the problem is that I can’t understand how the notify.file
meant to work at all.
I have set up the File Service in the UI and tried using it directly:
automation:
- id: save_mailbox_image
alias: "Save Mailbox Image"
trigger:
- platform: mqtt
topic: "home/Mailbox/camera/image"
action:
- service: notify.file
data_template:
message: "{{ trigger.payload }}"
filename: "/var/www/html/uploads/mailbox_{{ now().strftime('%Y-%m-%d_%H-%M-%S') }}.jpg"
The above doesn’t work and results in this error:
Error: Service notify.file not found
I found mention that I am supposed to use notify.send_message
instead but there is absolutely no documentation how it meant to tie into the File service.
I have bumbled around until I got to this stage:
automation:
- id: save_mailbox_image
alias: "Save Mailbox Image"
trigger:
- platform: mqtt
topic: "home/Mailbox/camera/image"
action:
- service: notify.send_message
target:
entity_id: notify.file_2
data_template:
message: "{{ trigger.payload }}"
Where notify.file_2 service is configured with this template: /var/www/html/uploads/mailbox_{{ now().strftime('%Y-%m-%d_%H-%M-%S') }}.jpg
except the template is taken literally and it doesn’t evaluate, I didn’t get the image anyway as it created a file:
cat /var/www/html/uploads/mailbox_\{\{\ now\(\).strftime\(\'%Y-%m-%d_%H-%M-%S\'\)\ \}\}.jpg
Home Assistant notifications (Log started: 2025-03-27T10:06:42.691958+00:00)
--------------------------------------------------------------------------------
I am currently tempted to write a small python script and give up on HA…
The problem here (having 20+ years of programming experience) I do not understand the logic or structure, and documentation is very lacking.
I am sure the problem is trivial to solve and I am holding it wrong.
Thank you.