This has been a very deep rabbit hole but I think I’m close to the end. I’m trying to send a camera snapshot via the SMTP integration. However the jpg images generated by camera.snapshot cause the SMTP integration to log the following error:
Logger: homeassistant.components.smtp.notify
Source: components/smtp/notify.py:285
integration: SMTP (documentation, issues)
First occurred: 8:51:10 PM (1 occurrences)
Last logged: 8:51:10 PM
Attachment ./www/snapshots/frontyard_snapshot2.jpg has an unknown MIME type. Falling back to file
Further digging uncovers the suggestion to use ImageMagick to “convert” the jpg to a jpg file - SMTP - unknown MIME type - #4 by ladefoged81
After a few hours spent getting that running, I can run magick to convert the file from the command line and successfully send the converted file using the SMTP integration. The problems setting this up were due to the package installer not installing the needed JPEG support. In addition to the
apk --update add imagemagick && apk --no-cache add msttcorefonts-installer fontconfig && update-ms-fonts && fc-cache -f
suggested in the thread, I had to also run
apk add imagemagick-jpeg
to actually add jpeg support to magick.
After all that, I’m now trying to automate that process using a shell command. I have the following in my configuration.yaml file:
shell_command:
fixup_jpeg: "magick /config/www/snapshots/frontyard_snapshot2.jpg /config/www/snapshots/frontyard_snapshot2.jpg"
And the following in my script (huge thanks to Aussie_Adam for Guide for CCTV Snapshot on motion, send to Google Generative AI & get notification with description & snapshot):
alias: Camera - Frontyard - Snapshot, AI & Notification
sequence:
- metadata: {}
data:
filename: ./www/snapshots/frontyard_snapshot1.jpg
target:
device_id: 0a7bd481b9f24aaa85a2be44f5392912
enabled: true
action: camera.snapshot
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
enabled: true
- metadata: {}
data:
filename: ./www/snapshots/frontyard_snapshot2.jpg
target:
device_id: 0a7bd481b9f24aaa85a2be44f5392912
enabled: true
action: camera.snapshot
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
enabled: true
- metadata: {}
data:
filename: ./www/snapshots/frontyard_snapshot3.jpg
target:
device_id: 0a7bd481b9f24aaa85a2be44f5392912
enabled: true
action: camera.snapshot
- metadata: {}
data:
prompt: >-
Motion has been detected, compare and very briefly describe what you see
in the following sequence of images from my driveway camera number 1.
What do you think caused the motion alarm? If a person or car is
present, describe them in detail. Do not describe stationary objects or
buildings. If you see no obvious causes of motion, reply with "No
Obvious Motion Detected." Your message needs to be short enough to fit
in a phone notification.
image_filename:
- ./www/snapshots/frontyard_snapshot1.jpg
- ./www/snapshots/frontyard_snapshot2.jpg
- ./www/snapshots/frontyard_snapshot3.jpg
response_variable: generated_content
action: google_generative_ai_conversation.generate_content
- if:
- condition: template
value_template: "{{ 'No Obvious Motion Detected.' in generated_content.text }}"
then:
- stop: ""
else:
- action: shell_command.fixup_jpeg
data: {}
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- metadata: {}
data:
title: Frontyard Motion Detected
message: "{{generated_content['text'] }}"
data:
images:
- ./www/snapshots/frontyard_snapshot2.jpg
action: notify.family_sms
mode: single
description: ""
The Google AI has no problems using the three snapshots created, and I can display them in my browser without problems, but the SMTP integration doesn’t like the MIME type so the attempt to use ImageMagick towards the end of the script to convert the one snapshot being send.
Unfortunately I end up with the following log error:
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:129
integration: Shell Command (documentation, issues)
First occurred: 8:44:46 PM (2 occurrences)
Last logged: 8:51:10 PM
Error running command: `magick /config/www/snapshots/frontyard_snapshot2.jpg /config/www/snapshots/frontyard_snapshot2.jpg`, return code: 127
NoneType: None
Any ideas?