I am attaching the yaml to create an automation for doing something based on if a USPS email has been received indicating your mail was delivered. For my particular use, I am only turning on an input_boolean for 10 minutes and then turning it off. I intend to use it to turn on a light bulb in a certain color to let us know we have email to go pickup.
I created a second automation that will also do the same, but for indicating via the USPS daily digest email, indicating that there WILL /should be a mail delivery today, toggling another input boolean for the digest. I will also change this to do a different notification, that I will create.
alias: "Mail: has arrived"
description: >-
Checks to see if there is new mail in the mail box by checking email from
USPS, and sets the boolean mail_delivered to ON, waits 10 minutes and clears
mail_delivered.
triggers:
- trigger: event
event_type: imap_content
id: custom_event
conditions:
- condition: and
conditions:
- condition: template
value_template: |-
{% if 'Mail Was Delivered' in trigger.event.data.subject %} true
{% else %} false
{% endif %}
enabled: true
actions:
- action: input_boolean.turn_on
target:
entity_id:
- input_boolean.mail_delivered
data: {}
- delay:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
- action: input_boolean.turn_off
target:
entity_id:
- input_boolean.mail_delivered
data: {}
mode: single
If you do decide to capture both email events, the ‘Mail Was Delivered’ message needs to be changed to ‘Your Daily Digest’.
I hope this proves to be helpful to others wanting the same, or similar information captured from email.
Regards!