Trigger on new Email

Hi!

I’m trying to replicate the IFTTT Gmail-component: “Run on new email”, my problem with it is that it can be delayed over an hour before it activates. I want to use my HASS to check for new Gmail and then run an automation. Has anyone done something similar?

This may be an option, assuming you don’t have a lot of unread e-mail.

Not sure if that works. Google Calendar sends an email to a specific inbox (that only receives mail from google calendar). Upon receiving a new mail: Activate Automation is my end-goal. If a google rule to mark whatever mail that comes in as “read”, it may never trigger?

I assume you have a google calendar event triggering these e-mails. The calendar component may be a better route then.

Unfortunately, the calendar component does not have an function to offset when it’s triggered based on events…hence the current solution where Google Calendar sends an email 1 hour before the event to an inbox.

Ok, one more option.

You should be able to trigger off the sender, subject or content of the e-mail body.

Can’t seem to get it to work:

##Read Email and Activate Light
automation:

  • alias: ‘E-Mails from Calendar’
    hide_entity: False
    trigger:
    platform: template
    value_template: “{{ states.sensor.imapemailaddress.com.from == ‘calendar-notification.google.com’ }}”
    action:
    service: homeassistant.turn_on
    entity_id: script.timed_lamp