New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imap_content sensor not updating #93092
Comments
Hey there @engrbm87, @jbouwh, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) imap documentation |
What service is supplying your mailbox? (e.g. GMAIL). When is the sensor not updated? logger:
default: info
logs:
homeassistant.components.imap: debug When the event is fired a message like ... ... 2023-05-15 11:21:24.781 DEBUG (MainThread) [homeassistant.components.imap.coordinator] Message processed, sender: sender@example.com, subject: xxxxx` ... should be logged when a new message is processed or at startup/reload. |
I am using GMAIL. What was happening was I sent an email to the IMAP account. The "sensor.imap_aaronautomation88" would update from 0 to 1, and "sensor.imap_content" would change to show attributes from that email. I would then send a 2nd email to the IMAP account "sensor.imap_aaronautomation88", and it would update from 1 to 2, or 0 to 1 if I had cleared the first email...but then "sensor.imap_content" would not update...and hold onto the data from the old email. When I would reload the integration, "sensor.imap_content" would instantly update and show the new email. It was doing this all yesterday and this morning. Currently, I have an email with a subject called "this is a test subject new 6", and the "sensor.imap_content" is not updating to show that email, it is only displaying the old email before it. |
The event will only be fired if the latest message changes, not if you read some older messages but the latest message has not changed. |
The latest message IS changing though on my GMAIL account. In the below photo, the new email is in my inbox, and is the ONLY message in my inbox and unread, but is not showing on the imap_content on the left. |
And if you are adding a new message it does not update? Does it update the count sensor? |
I mean, if you send another message to the maibox (without reloading), is the count changed to 2 but the content sensor not updated? |
Correct, the count will change from 1 to 2 if there is 1 message there, and another comes in. Or if there are 0 messages, it will update from 0 to 1, but the imap_content sensor will not update to show the message. It seems to happen more when it goes from 0 messages to 1 actually. edit: actually it may only be happening when the count goes from 0 to 1. still testing it. |
You could check your debug logging as I asked. It is important to known if the custom_event was fired or not. |
I think I may be onto it. Here is my reproduction steps:
I will edit / comment when I can get the log for this. It seems right now that if the count goes from 1 to 2, 2 to 3, 3 to 4, this isn't happening. |
So may be the message ID's (UID's) are being reused? |
Can you test without clearing all messages (leave at least 1 message) |
Yes, if I leave 1 message there, and send a new one, it comes in and updates from 1 to 2, and displays the imap_content attributes for the new email. If I clear out the oldest email and go from a count of 2 to 1 again, and send a new email, the count goes from 1 to 2 again, and imap_content updates correctly. So this may be an issue when the count is going from 0 to 1. |
I just cleared my inbox so the message count went from 3 to 0. I sent a new email called "subject 16", it came through. and the message count went from 0 to 1. I cleared my inbox AGAIN, and sent another email called "subject 17", it came through and the message count went from 0 to 1. I cleared my inbox AGAIN and sent another email called "subject 18", the message count changed from 0 to 1, but it did not come through.
|
Thnx, I'll dive deeper into this and see if I can supply a fix for this case. |
I'm uploading a video showing this. Give me a moment. |
Here is a video detailing the issue: https://www.youtube.com/watch?v=bTBALUC7DWM Essentially when the email count goes from 0 to 1, clear all messages, then your count goes from 0 to 1 again, it will not update the imap_content sensor (or whatever you named your sensor). But...if you reload the configuration, it instantly updates it and works, for some reason. |
Thanks for your help. I have opened a PR that should fix your issue. It will ensure that the last ID is reset to |
Thanks for hanging in there to understand! |
@talormanda - I've been scratching my head for days trying to resolve what I believe is the same/similar problem. My IMAP sensor checks all incoming mail for a specific sender but the sensor state as reported in developer tools does not update as expected, leading to intermittent notifications. Any idea when the fix will be rolled out? |
You would have to ask @jbouwh that. |
The documentation shows an example on how to filter a specific sender. The only limitation is that you can only configure one sender. An other option is to grate a template sensor based on the custom event. If there is another issue, feel free to open a new issue. |
Thanks for your response Jan. My problem is that the sensor that was created when I updated to the IMAP integration does not accurately reflect the state of the desired field (in my case, I'm monitoring the Sender field). When I receive an email in the relevant Inbox, the IMAP sensor increments the number of UnSeen/UnRead mails but the sensor that deals with monitoring the sender field does not update accordingly, instead it remains on a sender adress of some days ago. |
May be your email size is the issue: see #93138. |
I don't think so, considering the sensor is not looking at the body text of the email, only at the sender? |
The event data can be filtered, but this is limited. If you need more advanced conditions you need to add them to your automation acting upon state changes of your template sensor. |
The trouble is that the state of the template sensor is not changing reliably based on the search parameter ie Sender, I have no problem with the automation/notification side of things. |
I suggest you open an issue to reflect you problem. |
Thanks Jan, reason I'm posting here is because I suspect this is the same issue as per original poster. Should I open a new issue? |
Yes, as this issue has to do with an empty mailbox not updating |
Thanks very much for your time, I'll open an issue. |
The problem
My IMAP sensor "sensor.imap_aaronautomation88" is updating to show 1 new email is present:
However, when I look at my imap_content sensor "sensor.imap_content", it is not updating the show the latest email. If I go to the Home Assistant devices page, go to the IMAP entity, and hit "reload", the "sensor.imap_content" instantly updates and my automations begin to trigger:
After a reboot of Home Assistant, it works without having to reload the integration for 1 email. Then, when the 2nd email comes in, it stops updating the "sensor.imap_content". But then other times, it seems to work fine randomly.
What version of Home Assistant Core has the issue?
2023.5.3
What was the last working version of Home Assistant Core?
2023.5.2
What type of installation are you running?
Home Assistant OS
Integration causing the issue
imap
Link to integration documentation on our website
https://www.home-assistant.io/integrations/imap/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
redacted email addresses for privacy
The text was updated successfully, but these errors were encountered: