I have a sensor defined which uses the IMAP integration. It triggers an automation when an email arrives from specific senders which has specified text in the Subject. It’s been working fine for many months, but for some reason the automation has not been triggered in the last day, despite at least two qualifying emails arriving.
The parking_emails sensor (as defined below) currently has a state of parking_booking, and I can see the content of the most recent qualifying email in the attributes, so the emails are clearly being retrieved correctly.
Any idea why the automation has suddenly stopped triggering?
- platform: imap_email_content
server: imap.gmail.com
name: parking_emails
port: 993
username: [email protected]
password: googleapppassword
senders:
- [email protected]
- [email protected]
value_template: >-
{% if 'You have a new booking' in subject %}
parking_booking
{% elif 'you have a new JustPark booking' in subject %}
parking_booking
{% elif 'Booking received' in subject %}
parking_booking
{% endif %}
Yes it could be. Until now I have not needed to take any action to reset the sensor (I haven’t even been deleting the emails). Maybe something changed with a recent HA release? (I upgraded from 2023.2 to 2023.5 this week).
I’ll try explicitly resetting the sensor at the end of the automation, to see if that resolves things.
…except I don’t actually know how to do that…is there a service which can be scripted to reset a sensor?
I did have a solution - as per below, using the IMAP integration - but for some reason it has stopped triggering today (I have received 2 emails today which were not detected. The last time it triggered correctly was yesterday. I’m not sure why it has suddenly stopped working, as I’ve made no changes since it last triggered correctly.
template:
- trigger:
- platform: event
event_type: "imap_content"
event_data:
sender: "[email protected]"
- platform: event
event_type: "imap_content"
event_data:
sender: "[email protected]"
- platform: event
event_type: "imap_content"
event_data:
sender: "[email protected]"
- platform: event
event_type: "imap_content"
event_data:
sender: "[email protected]"
binary_sensor:
- name: Parking Booking
auto_off: "00:02:00"
state: >
{% set current = this.state|default('off', 1) %}
{% if trigger.event.data['subject'] is match
"You have a new booking|Booking received|JustPark booking|Booking request for My Road"
%}
true
{% else %}
{{ current }}
{% endif %}
I am having the same issue where it will be working and then will stop working until I restart Home Assistant. This behavior just started for me in 2023.5.2 after migrating to the new sensor. Until then the sensor worked perfectly.
Well, purely anecdotal but since I updated to 2023.5.3 two days ago my imap sensor has stayed up and emails are being scanned. I created just a generic imap_content sensor from the integration description to see if the emails are still being processed and they are. So there’s that.
YMMV.
Spoke too soon. Sure enough, the generic imap sensor shows that I got an email with the subject line I’m looking for but my sensor based on the content of the subject didn’t trigger…until I manually reloaded template entities.
There’s definitely a problem here.