Automation smtp not working

Good evening,
I am trying to send an image via gmail/smtp. I have this error in the yaml configuration logs
ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'testNotifCapteurGmail' could not be validated and has been disabled: extra keys not allowed @ data['notify']. Got...........
Here is the yaml file :

- id: '1726841271819'
  alias: testNotifCapteurGmail
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 739fb4b9a1cef0a2fe198b0425690bbe
    entity_id: cc6af08550377575a85886a331a1a81c
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
  condition: []
  action:
  - action: camera.snapshot
    metadata: {}
    data:
      filename: /media/Camera/Gabin.jpg
    target:
      entity_id: camera.192_168_1_xy
      area_id: living_room
  - action: notify.xxxxxx_gmail_com
    data:
      message: Gabin is at home
      title: RetourGabin
  notify:
  - name: xxxxxx_gmail
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: [email protected]
    encryption: starttls
    username: [email protected]
    password: abcdefghijklmnop
    recipient:
      - [email protected]
    sender_name: toto

The notify block:


notify:
  - name: xxxxxx_gmail
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: [email protected]
    encryption: starttls
    username: [email protected]
    password: abcdefghijklmnop
    recipient:
      - [email protected]
    sender_name: toto

needs to go in configuration.yaml… it doesn’t belong in your automations.yaml file.

I don’t understand what you say.

configuration.yaml

notify:
  - name: xxxxxx_gmail
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: [email protected]
    encryption: starttls
    username: [email protected]
    password: abcdefghijklmnop
    recipient:
      - [email protected]
    sender_name: toto

automation.yaml:

- id: '1726841271819'
  alias: testNotifCapteurGmail
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 739fb4b9a1cef0a2fe198b0425690bbe
    entity_id: cc6af08550377575a85886a331a1a81c
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
  condition: []
  action:
  - action: camera.snapshot
    metadata: {}
    data:
      filename: /media/Camera/Gabin.jpg
    target:
      entity_id: camera.192_168_1_xy
      area_id: living_room
  - action: notify.xxxxxx_gmail_com
    data:
      message: Gabin is at home
      title: RetourGabin

Good morning,
Thank you for your help. I read the article you sent me. That’s what I was planning to do but I’m not at home. However, I have access to my Home Assistant (NAT). On the other hand, I don’t have access to ‘File editor’!!
I can access File Editor via ssh??

A question: where should I enter the file in which the photo is located (/media/Camera/Gabin.jpg)? In Automations.yaml below - action: notify.xxxxxx_gmail_com? Or in configuration.yaml? In this case where?

If you are running HA OS you can install this addon and access your config files over the web: Install VSCode Community Addon

Hi,
No, i am running HA Supervised.

You can install add-ons in that too.

ok. I look at what it is.

finally I saw that you could connect via ssh. I get along better with the console.

I changed as you told me but it’s still the same: I receive the notification without the image

Erreur : expected dict for dictionary value @ data['data']

Look at the examples here: https://www.home-assistant.io/integrations/smtp/#usage

  action:
    - action: notify.NOTIFIER_NAME
      data:
        title: "Good Morning"
        message: "Rise and shine"
        target:
          - "[email protected]"

Hi,
I think I read this article 10 times!! There’s definitely something I don’t understand !!!
Here is my ‘configuration.yaml’

notify:
  - name: email
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: [email protected]
    encryption: starttls
    username: [email protected]
    password: abcdefghijkl 
    recipient:
      - [email protected]
    sender_name: toto
    data :
      message: Gabin est rentré
      title: RetourEcole 
      data:
        file: /media/Camera/Gabin.jpg

And i call the ‘email.notify’ in the ‘automations.yaml’ like the example you told me about:

 - action: notify.email
    data:
      title: RetourEcole
      message: Gabin est à la maison
      target:
        - [email protected]
      data:
          images:
              - /media/Camera/Gabin.jpg

Everything is ok. Thank you very much.