Home-Assistant-Mail-And-Packages: ISSUE: Amazon emails no longer parsing

Describe the bug Sometime in the last day, my Amazon emails stopped parsing. Interestingly, the _delivered sensor still work, but the regular package count sensor stopped working.

Environment (please complete the following information):

  • OS: [e.g. HassOS/Raspbian/CentOS] Docker
  • Type of device: [e.g. RPi3/NUC/Synology] Synology
  • Home Assistant version: [e.g. 0.105.5] 0.115.2
  • Hassio/Docker/Core? Docker
  • Component version: [e.g. 0.1.2] 0.2.2b29

Logs

2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Email Multipart: True
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Content Type: multipart/alternative
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Email Multipart: True
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Content Type: multipart/alternative
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Error while attempting to decode Amazon email: 'utf-8' codec can't decode byte 0xdf in position 405: invalid continuation byte
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Email Multipart: True
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Content Type: multipart/alternative
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Error while attempting to decode Amazon email: 'utf-8' codec can't decode byte 0xdf in position 404: invalid continuation byte
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Amazon emails found: 0
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Amazon emails found: 0
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Amazon emails found: 0
2020-09-25 15:21:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Amazon order: ['REMOVED']

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here. Please add emails in plain/text format if possible and applicable.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

So, with that sensor.py version, I was still receiving the following error:

2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Amazon emails found: 3
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Email Multipart: True
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Content Type: multipart/alternative
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Error while attempting to decode Amazon email: 'utf-8' codec can't decode byte 0xdf in position 404: invalid continuation byte
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Email Multipart: True
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Content Type: multipart/alternative
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Error while attempting to decode Amazon email: 'utf-8' codec can't decode byte 0xd7 in position 406: invalid continuation byte
2020-09-27 11:04:25 DEBUG (MainThread) [custom_components.mail_and_packages.sensor] Email Multipart: True

I managed to fix that issue by changing line 973 to (added a parameter for the unicode decode to ignore invalid characters):

email_msg = email_msg.decode("utf-8", "ignore")

I think that resolved my issues. I have an Amazon package out for delivery today, and I was going to back and forth trying to figure out why the sensor still said 0. I eventually realized the email Amazon sent says it is going to be delivered tomorrow, so they are ahead of schedule. 🤦‍♂️ I’ll keep an eye on things are report back. Next package should be Tuesday.