New file notification using imap content sensor

Hi there,

On my Synology NAS I have created a bash script that will send automatically a mail when new files are being uploaded to specific folder, in this case photo uploads.

I would like to setup two sensors:

  1. A sensor with the following state: person a or person b
  2. A sensor with the following state: deleted or added

So far I created an imap sensor that can genere the state of person a or b:

    - platform: imap_email_content
      name: mail_scanner
      port: 993
      username: [email protected]
      password: !secret gmail_app
      folder: Synology
        - [email protected]
      value_template: >-
        {% if 'PXL' in body %}
          Photo from person a
        {% elif 'IMG' in body %}
          Photo from person b
        {% endif %} 

It reads the data from the following mail:

[ This is an automatic email sent from the NAS to all users ]

 NAS folder 'photo' has been modified:

-------- 2 files added:

-------- 3 files added:

I am trying to find out how to create another sensor that can alternate the state of deleted or added using the imap content sensor.

My goal is to make notifcations from HA using the two sensors.

Thank you!

Did you achieve what you set out to ?
Can you share the bash script you use to send that email ? Thanks