HA configuation script + IMAP sensor value for notifications

Hello to all,

After searching around and being even more confused than before, I wanted to ask around here.

I would like to cut a certain string (at the same position) out of an email subject and sent it to my smartphone as a notification per Home Assistant.

Sending the value to my smartphone is not a problem for me. What I am struggling with is to create the value of the email as a sensor value.

The subject is: “TR:Box X: Lunchtime Delivery Confirmation”

In this case, I only want to set the letter, in this case “X”, as the sensor value. This value is different in every email.

What I have so far is the function to read the e-mails via IMAP.

sensor:
- platform: imap_email_content
  server: outlook.office365.com
  name: lunchtime_email
  port: 993
  username: [email protected]
  password: xyxyxy
  folder: Inbox
  senders:
    - [email protected]

Now I don’t know whether I should create a template sensor or how I can determine the value, in this case the letter.

I would appreciate your help.