I know I'm missing something. I followed the keyword spotting example on the IMAP integration documentation along with an example from the community for a binary sensor (this allowed for an auto off which is perfect for my use). I can watch the event happen with the developer tools but when I don't see the state getting updated. For context- I'm trying to monitor my email for a message from USPS that my mail has been delivered and flip the binary switch. (once that's working: I'll then check the switch from a MagicMirror module and display an icon showing it's been delivered).
Edited to format: Also adding that I'm putting this in the configuration.yaml (I'm not 100% sure that's the right spot).
template:
- trigger:
- trigger: event
event_type: "imap_content"
id: "custom_event"
event_data:
sender: "Someone@somewhere.com"
initial: true
binary_sensor:
- name: mail_delivered
auto_off: "08:00:00"
state: >-
{% set current = this.state|default('off', 1) %}
{% if 'Mail Was Delivered' in trigger.event.data["subject"] %}
on
{% else %}
{{ current }}
{% endif %}