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

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.

What does your home-assistant.log show when you enable the debugging?

2020-02-03 15:08:20 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-03 15:08:21 DEBUG (SyncWorker_18) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-03 15:08:21 DEBUG (SyncWorker_18) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-03 15:08:21 DEBUG (SyncWorker_6) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-03 15:08:21 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-03 15:08:21 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-03 15:08:22 DEBUG (SyncWorker_15) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail
2020-02-03 15:08:22 DEBUG (SyncWorker_15) [custom_components.mail_and_packages.sensor] Removing duplicate images.
2020-02-03 15:08:22 DEBUG (SyncWorker_15) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.
2020-02-03 15:08:22 INFO (SyncWorker_15) [custom_components.mail_and_packages.sensor] Mail image generated.
2020-02-03 15:08:23 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-03 15:08:23 DEBUG (SyncWorker_10) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today
2020-02-03 15:08:23 DEBUG (SyncWorker_10) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-03 15:08:24 DEBUG (SyncWorker_3) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered
2020-02-03 15:08:25 DEBUG (SyncWorker_7) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-03 15:08:25 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-03 15:08:25 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-03 15:08:25 DEBUG (SyncWorker_8) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-03 15:08:26 DEBUG (SyncWorker_0) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-03 15:08:26 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-03 15:08:26 DEBUG (SyncWorker_4) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-03 15:08:27 DEBUG (SyncWorker_14) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today

Your’s is saying the image was generated, so mail_today.gif doesn’t show anything but the No Mail image?

Correct, but I do not see the mail_today.gif file was updated in /config/www/mail_and_packages/
The date/timestamp is always the same.

For additional info, I am NOT using the camera.py file. I have camera: -platform: mail_and_packages defined in my config file.

Make sure it’s mail_today.gif not today_mail.gif.

There should be no camera.py file.

It looks correct in www.
mail_today

Why would test.py come back with mail found but not want to update the image?
“Total mages found in email: 0”

Couple Thoughts:

  • Do I have to change any of the defaults in /config/custom_components/mail_and_packages/const.py?

  • Should I be expecting any kind of camera.X entity to be created as part of this integration?

  • I have included the files from /config/includes/packages/ and have packages: !include_dir_named includes/packages in my config. Is this correct or should I remove all of that?