Imap_content_sensor during reboot of HA

I have an automation (actually an AppDaemon script) that works off the imap content_sensor, firing when it sees a specific email in the sensor. Triggered by a state change.

Works great, except when I reboot HA, at which point it fires again based on the last email, as the state apparently changes on initialization.

Is there any way to prevent this? Clear the sensor somehow, or get it to remember the state from before reboot and not report a state change?

This is an old thread, and you possibly had solved it. I am just sharing what I did in similar case.

I created an input_text. On a sensor trigger, set the input_text value as sensor’s value. Subsequent sensor trigger with same value will not trigger state change in input_text.
Automation hence is based on the input_text state change, instead of originally sensor’s state change. input_text survives HA restart.

1 Like