From 762bec8aed374758768863578b3d3472aa821f4f Mon Sep 17 00:00:00 2001 From: "firstof9@gmail.com" Date: Fri, 6 Oct 2023 09:24:35 -0700 Subject: [PATCH] fix: make sure subject is a string --- custom_components/mail_and_packages/helpers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index b6a57ad6..460d8d20 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -1378,6 +1378,11 @@ def get_items( ) else: email_subject = decode_header(msg["subject"])[0][0] + + if not isinstance(email_subject, str): + _LOGGER.debug("Converting subject to string.") + email_subject = email_subject.decode('utf-8','ignore') + _LOGGER.debug("Amazon Subject: %s", str(email_subject)) pattern = re.compile(r"[0-9]{3}-[0-9]{7}-[0-9]{7}")