Imap_email_content, gmail, and 2FA

I’ve been trying to get the imap_email_content sensor working, and it’s been failing apparently silently. I’ve generated an application password, since I’m using 2FA on my GMail account.

Poking at it with Thunderbird, I got sent for an OAUTH login, and a 2FA prompt. I suspect that’s why the sensor isn’t working. Is there any way around this that anybody knows of?

If not, it’s not the end of the world. I can forward just those emails to a less secured account and use that :slight_smile:

An app password works for me while 2fa is enabled. I’m currently running 0.51.2.

Cheers. Dunno why I’m also getting OATH, I simply stood up another account for it :slight_smile:

You need to enable less secure access.
https://support.google.com/accounts/answer/6010255?hl=en

Interesting, didn’t know about that option, thanks.

Did the “less secure apps” password solution work for you?

Nah, gave up with that in the end for a number of reasons, including that it’s really only useful for triggering an immediate action.

I got the sensor to show up on the dashboard…but I’m wondering how to implement it now. This could be used to generate a specific sound based upon a specific e-mail sender or content of the message, or even trigger a log to record how many times a certain message comes in…

What were your original thoughts on implementing it? I find, often, that after I figure out how something works in HA, I forget why I was doing it in the first place…and then I have to invent a reason to have it set up.

One of the things I was thinking was to create some sort of automatic “party mode” boolean that would disable certain automations but it would be triggered based upon either an e-mail that exists in the in-box, or a calendar event. I’ve found with the calendar events, that the sensor only turns on during the event, so triggering something 30 minutes before the event doesn’t work unless perhaps there’s a default e-mail reminder that goes out 30 minutes prior to the event.

For instance, setting the lighting for guests who are going to arrive to a specific mode…or…well, I guess it’s unlimited in possibilities.

For me, it was to be part of my bin collection automations. The trouble is the sensor activates at the time the email is received, which wasn’t what I needed. I needed to use the content of the email to generate future events, not to know at 2 AM that in 2 days the brown bin would be collected.

For a while I used it to set a couple of template sensors, which gave me something closer to what I needed. The problem I ran into is that I need their state to persist across restarts, so ended up with a script to parse emails to files, that would then be used to populate some sensors. Right now those sensors primarily are used in my Floorplan and for some limited notifications.