Sending still image from IP camera when motion detection from Ikea sensor

Hi all !

Got an Hikvision IP camera with line crossing detection, but it is very slow to process the signal sent to HA due to the heavy load of the cam (sending email, recording video, sending signal to HA). I also noticed that in some light circonstances there is no detection, especially at night due to the city public light that is just in front of the cam.
When HA gets the detection, it switch on an external light for one minute. The delay can reach 8 seconds before the light switch on.

So I decided to use an Ikea Vallhorn motion detector to tell HA there is a detection, and would like HA to switch on the light, then get still image from camera and store it in a folder while (or after) sending it via email.

Ikea detection works fine, and the light switch on immediately (less than 1 sec), but I don’t know how to handle the request for the picture (I know how to do to get a still image) but no idea how to manage the picture and to send it by mail.

Any help possible ?

hello @amy598cross

Thanks for clear answer.
The snapshot is ok…
Sending email is not.

I did as explained here

using “packages”.

I restarted HA and got no errors after reboot.

When trying to execute the “Action 3”, I got an error due to the link to the picture.
If I remove the line for the picture, it sends the email.

Any idea ?

Hi !

After so many time, it works !

Here are my settings

=== configuration.yaml, at the end of the file ===

homeassistant:
  packages: !include_dir_named packages
  allowlist_external_dirs:
    - "/config/www"

=== In folder packages, a file named “mails.yaml” ===
===Note that I do not need smtp authentication in my case ===

notify:
  - name: "envoimail"
    platform: smtp
    server: "smtp.free.fr"
    port: 25
    timeout: 5
    sender: "[email protected]"
#    encryption: starttls
    encryption: none
#    username: "[email protected]"
#    password: "PasswordForemailaddress"
    recipient: "[email protected]"
    sender_name: "ha domotique maison"

=== In automation, when a detection is detected ===
=== Camera snapshot ===

action: camera.snapshot
metadata: {}
data:
  filename: /config/www/snapshot_portail.jpg
target:
  device_id: e985db118fa2d36cd48d08f6239899dc

=== Sending the image by mail ===

action: notify.envoimail
data:
  message: Entrée {{ now().strftime('%H:%M:%S')}}
  title: Détection entrée maison
  data:
    images:
      - /config/www/snapshot_portail.jpg

Many thanks to @amy598cross