Pulling a time from a email with IMAP to automate

Hello, new to HA and it’s been a chore to learn. Somethings are more straightforward then others. I’m attempting to pull a start and stop time from a email to start and stop automations. I can’t find any working examples and am stuck trying to figure out how to pull the times out, hopefully with the ability to find just the times in a email that might have more or less text (location may not be static).

This doesn’t have anything to do with the time the email is sent or received.

Any help would be appreciated, not exactly sure if this should be a blueprint either, or if I can just write it into the automation itself. Thanks.

We can’t help without seeing the email’s body. You can post the raw email contents in a code block here.

You’ll need to parse it out of the body using regular expressions and the text you’re looking for will need to be in the first 2048 characters.

Always good to show what you’ve tried.

I thought there might be a way to search using dating syntax or such, which would be preferable instead of just spacing things out in a sentence.

It’ll look like this.

start at 4:00 PM CT on Monday, 12/19/2088

ending at 7:00 PM CT on Monday, 12/19/2088

With text between the beginning, ending, and stuff in between.

I looked through the IMAP guide and didn’t see anything along these line to pull out a date/time.

Show more of the email text, please. I need to see more of what’s before and after those snippets. I’ll have a look tomorrow.

What you’re looking for won’t be in the IMAP integration’s docs, because it’s not specific to IMAP. How to use regexes is explained in the templating docs.

I’m willing to roleplay if that’s what you’re after.

Hi Your Name,

This is random filler text that would take place before the event that’s about to happen which start at 4:00 PM CT on Monday, 12/19/2088. This event will last about X number of hours, we’ll all be making it happen, and be ending at 7:00 PM CT on Monday, 12/19/2088. Be aware that these times may or may not change, but would appreciate you participating!

Thanks,
The person sending this email.

Date syntax should, hopefully, always be the same. I assumed more people would be interested or have looked at integrating time elements from emails into HA as it really has a lot of uses when it can integrate with the real world.

email is so 1998, which may be your problem :slight_smile:

Modern systems are so much better at interpreting xml or json or something other than text.

Having said that, openai may help here. OpenAI Conversation - Home Assistant

If this is a joke to you then you can seek help elsewhere. There’s a good reason I asked for what I did. Good luck.

What is the reason you asked for what you did? If you’re searching for keywords, I added the syntax already. I can just make up stuff if you want to see XYZ characters before the time stamp, between, and after.

I’m not giving you full emails because it’s a privacy concern and I find people focus too much on stuff that doesn’t matter rather then on task at hand.

Just looking to pull time stamps out of a email to use them for automation, that’s it.

I’ll look into this, thanks. Also considering using chatGPT to write something, but figured there was already a working solution here. Emails are like the fax machine, some people still use them instead of having a API somewhere you can easily pull from.

I work with a system which parses pdfs for info and builds a database. Mind you they are quite regularly constructed PDFs. (Before you ask, I didn’t write it).