Mail and Packages: Custom component for UPS, FEDEX, and USPS

It says /config

But I don’t have a config folder anymore… Should I use /config/www/mail_and_packages anyway?

Yep that should be it

Finally! mystery solved- I got the GIF to work. Possibly you did what I did wrong. When adding the integration from the “configuration” left menu bar, then selecting “integrations” and selecting the “mail and packages” integration, you probably copied and pasted the if using in docker path wrong. You must include the / forward slash at the end of the path: /config/www/mail_and_packages/ DO NOT /config/www/mail_and_packages without a foward slash at the end. As soon as I did that it worked- total rookie mistake I made and haunted me for days and hours of research!

I finally got it working too. I actually had the formatting correct but the path was completely off and I was missing the camera.py file. Thanks to @fuzzymistborn and BurnsHA’s YouTube channel I got it up and running after struggling for a week straight. Glad you figured it out as well. Love this component!

Been trying to get it to work but no dice. Seems like its finding the email but the images aren’t being detected? I have attached my log here. I had email today with 2 images

bash-5.0# python3 /config/www/mail_and_packages/test.py
Logged into your email server successfully!
Update Time 'Jan-30-2020 05:58 PM'
Logged into your email server successfully!
Attempting to find Informed Delivery mail for 27-Jan-2020
Found emails: 1

Total mages found in email: 0. 

Removing duplicate images.
Images to delete.



Found 0 unique images total to generate gif.



Removing USPS announcement images.
Found 0 mail images total to generate gif.



Checking for mail with no images.
Error occured while either processing email.
local variable 'msg' referenced before assignment

I thought maybe imagemagick isn’t installed but haven’t been able to get anywhere. I am running hassio in ubuntu

bash-5.0# apk add --update imagemagick
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 251 MiB in 173 packages

I have the camery.py file and the path in the integrations is /config/www/mail_and_packages/

Sounds like an old version. Latest version doesn’t have a camera.py anymore.

I followed this guide here from BurnsHA. Should I be doing something else?

The packages directory isn’t needed anymore all you need is the custom_component directory files. You can use the lovelace card if you like, but it’s not really needed you can make your own via the sensors.

Don’t pull the camera.py from my repo. :stuck_out_tongue: Use only the files from moralmunky’s repo.

Check the /config/www/mail_and_packages/ for a gif file called mail_today.gif that should display the images from the USPS email if any were attached.

I’ll see what I can do about updating the documentation on the repo to install this, maybe even get it added to HACS.

Do i need to add the flies under www folder as well? Or just custom_component directory?

It would be great if you get it added to HACS!

You will need the www directory as well

This is what i did but no success so far. I am running Hassio in Ubuntu

  • Pasted the custom component and www folders in their respective directories
  • Installed imagemagick in the homeassistant container ( docker exec -it homeassistant /bin/bash ) and then apk add --update imagemagick)
  • Set up integration from HA frontend with the following path: /config/www/mail_and_packages/

It generates mail_today.gif which is updated every few minutes but its just the default “no mail”.

When i run the test scrip this is what i get. I received an email today with USPS informed delivery with 2 images of the mail.

bash-5.0# python3 /config/www/mail_and_packages/test.py
Logged into your email server successfully!
Update Time 'Feb-01-2020 01:45 PM'
Logged into your email server successfully!
Attempting to find Informed Delivery mail for 1-Feb-2020
Found emails: 1

Total mages found in email: 0. 

Removing duplicate images.
Images to delete.



Found 0 unique images total to generate gif.



Removing USPS announcement images.
Found 0 mail images total to generate gif.

I am not sure if there is a problem with my imagemagick install. This is how i have installed it. Seems like the integration is working but the images are not detected.

sudo docker exec -it homeassistant /bin/bash
bash-5.0# apk add --update imagemagick
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 251 MiB in 173 packages

Try this go to the dev-tools -> Services

Change the drop down to logger.set_level

In the box put in
custom_components.mail_and_packages: debug

and click Call Service

image

That should turn on debugging for the component check your Home Assistant logs for messages.

Here you go!


2020-02-01 16:04:44 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 15:38:46 INFO (MainThread) [custom_components.mail_and_packages.sensor] version 0.0.5 is starting, if you have any issues please report them here: http://github.com/moralmunky/Home-Assistant-Mail-And-Packages,
2020-02-01 15:36:08 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Removing duplicate images.,
2020-02-01 15:36:08 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail,
2020-02-01 15:36:08 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.,
2020-02-01 15:36:08 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 15:36:08 INFO (SyncWorker_2) [custom_components.mail_and_packages.sensor] No mail found.,
2020-02-01 15:36:09 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 15:36:09 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 15:36:09 DEBUG (SyncWorker_7) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 15:36:39 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 15:36:39 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 15:36:39 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered,
2020-02-01 15:36:09 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 15:36:40 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 15:36:41 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on,
2020-02-01 15:36:40 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on,
2020-02-01 15:36:40 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 15:36:40 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered,
2020-02-01 15:36:41 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 15:38:40 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for mail_and_packages which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.,
2020-02-01 15:38:40 INFO (SyncWorker_1) [homeassistant.loader] Loaded mail_and_packages from custom_components.mail_and_packages,
2020-02-01 15:36:42 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 15:36:41 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 15:38:43 INFO (MainThread) [homeassistant.setup] Setup of domain mail_and_packages took 0.0 seconds.,
2020-02-01 15:38:43 INFO (MainThread) [homeassistant.setup] Setting up mail_and_packages,
2020-02-01 15:38:46 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mail_and_packages,
2020-02-01 15:38:46 INFO (MainThread) [custom_components.mail_and_packages.sensor] No mail found.,
2020-02-01 15:44:04 INFO (SyncWorker_7) [custom_components.mail_and_packages.sensor] No mail found.,
2020-02-01 16:04:39 DEBUG (SyncWorker_0) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 16:04:39 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 16:04:39 DEBUG (SyncWorker_0) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 16:04:40 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered,
2020-02-01 16:04:40 DEBUG (SyncWorker_9) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 16:04:41 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 16:04:41 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on,
2020-02-01 16:04:41 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 16:04:41 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today,
2020-02-01 16:04:42 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 16:04:42 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered,
2020-02-01 16:04:42 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on,
2020-02-01 16:04:42 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on,
2020-02-01 16:04:42 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered,
2020-02-01 16:04:43 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered,
2020-02-01 16:04:43 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail,
2020-02-01 16:04:43 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.,
2020-02-01 16:04:43 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Removing duplicate images.,
2020-02-01 16:04:43 INFO (SyncWorker_4) [custom_components.mail_and_packages.sensor] No mail found.,
2020-02-01 16:04:44 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today,
2020-02-01 16:04:41 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered

Odd it seems to be missing the Informed Delivery mail.
Should look something like this:

2020-02-01 15:19:14 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-01 15:19:15 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today
2020-02-01 15:19:16 DEBUG (SyncWorker_18) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-01 15:19:45 DEBUG (SyncWorker_14) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail
2020-02-01 15:19:46 DEBUG (SyncWorker_14) [custom_components.mail_and_packages.sensor] Removing duplicate images.
2020-02-01 15:19:46 DEBUG (SyncWorker_14) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.
2020-02-01 15:19:49 INFO (SyncWorker_14) [custom_components.mail_and_packages.sensor] Mail image generated.
2020-02-01 15:19:50 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-01 15:19:50 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-01 15:19:50 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered

Is this what you are referring to? At the very bottom

2020-02-01 16:30:26 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-01 16:30:26 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-01 16:30:26 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-01 16:30:26 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered
2020-02-01 16:30:27 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-01 16:30:27 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-01 16:30:28 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-01 16:30:28 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today
2020-02-01 16:30:28 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-01 16:30:28 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-01 16:30:29 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-01 16:30:29 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-01 16:30:29 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-01 16:30:29 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered
2020-02-01 16:30:30 DEBUG (SyncWorker_7) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail
2020-02-01 16:30:30 DEBUG (SyncWorker_7) [custom_components.mail_and_packages.sensor] Removing duplicate images.
2020-02-01 16:30:30 DEBUG (SyncWorker_7) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.
2020-02-01 16:30:30 INFO (SyncWorker_7) [custom_components.mail_and_packages.sensor] No mail found.

Guess I missed that likely because it didn’t state that it was generating a image.

From inside your docker container can you execute the command which convert and post the output?

Should be something similar to: /usr/bin/convert

This is the output I get: /usr/bin/convert

I am also stuck on this step. Running the test.py I get mail found (4 images on the email) but 0 images returned. Have installed Imagemagick and it appeared to complete successfully. I am running HASSOS on a RPi.

Does your todays_mail.gif only show “No Mail”?

Correct, mail_today.gif shows “No Mail”. I don’t think the file is updating based on file date/timestamp.

mailAndPackageCap

The 1 mail found has 4 informed deliver images.
I have tested using both live.com and gmail.com accounts and both run into the same issue.