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

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?

No

No

Remove it

Did some cleanup as suggested and created a new card to track as removing the /includes/packages/ seems to have broken some of the orig. card sensors.

Still unable to get the .gif to update, even when running the test.py, it does not seem to output the mail_today_test.gif file as expected. :frowning: Everything else seems to be working just fine. Logs don’t seem to denote any issues.

Any other troubleshooting steps? My integration path is /config/www/mail_and_packages/

Which one is the main branch that is getting updated with the newest stuff? I see this one and this one it looks like the 2nd one is being committed to more frequently, but it looks like it’s not the main project.

The documentation is a little out of date for both projects as well. In this comment @firstof9 says there should not be a camera.py file and in the repository there is one. While there is no camera.py file in @moralmunky repository.

It is also said to remove the includes statement in this comment, but if I take it out the feature will not work.

I am working on cleaning up the documentation and removing depreciated files.
Moral’s is the main fork where I merge my branches into, don’t use my files unless you are testing. :slight_smile:
You’ll notice I created a new branch for documentation update as well.

The gif is named mail_today.gif, I am thinking this might be a Docker thing, I’ll keep plugging away.

Thanks for the update. Look forward to using this as I have some ideas for some automations off of the sensors here.

Also I don’t use the lovelace card myself, I just put the sensors in manually:

image

and next to that I use the local_file camera for the mail image.

Like so (cameras.yaml):

 - platform: local_file
   file_path: /home/homeassistant/.homeassistant/www/mail_and_packages/mail_today.gif
   name: mail_usps

Quick update: So yesterday and today I noticed the timestamp on the mail_today.gif was getting updated (only once per day though when new mail arrives). It still shows “no mail” however despite having correctly identified 3 pieces of mail coming today. There are images present in the informed delivery message, unsure why it cant generate the correct image. HA logs below:

2020-02-05 07:58:47 DEBUG (SyncWorker_15) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject UPS Update: Package Scheduled for Delivery Today
2020-02-05 07:58:48 DEBUG (SyncWorker_10) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-05 07:58:48 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-05 07:58:48 DEBUG (SyncWorker_10) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-05 07:58:48 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Attempting to find Informed Delivery mail
2020-02-05 07:58:48 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Removing duplicate images.
2020-02-05 07:58:48 DEBUG (SyncWorker_19) [custom_components.mail_and_packages.sensor] Removing USPS announcement images.
2020-02-05 07:58:48 INFO (SyncWorker_19) [custom_components.mail_and_packages.sensor] No mail found.
2020-02-05 07:58:49 DEBUG (SyncWorker_0) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-05 07:58:49 DEBUG (SyncWorker_2) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-05 07:58:49 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-05 07:58:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-05 07:58:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-05 07:58:50 DEBUG (SyncWorker_11) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered
2020-02-05 07:58:51 DEBUG (SyncWorker_13) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Delivery scheduled for today
2020-02-05 07:58:51 DEBUG (SyncWorker_9) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on
2020-02-05 07:58:51 DEBUG (SyncWorker_9) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Item Delivered
2020-02-05 07:58:52 DEBUG (SyncWorker_12) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your package has been delivered
2020-02-05 07:58:52 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-05 07:58:52 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-05 07:58:53 DEBUG (SyncWorker_5) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Your UPS Package was delivered
2020-02-05 07:58:53 DEBUG (SyncWorker_1) [custom_components.mail_and_packages.sensor] Attempting to find mail from [email protected] with subject Expected Delivery on

I am thinking it’s a permissions issue or the path for some reason may not be correct. I’ll be checking it on a docker image to investigate when I get a chance. Maybe this evening.

If you just upgraded to the latest release of home assistant. You might need to reinstall imagemagick. Not sure what kind of hass install you have but that has gotten me a couple of times.

How are you running home assistant? I have done the imagemagick install and it completes successfully. I can actually run the convert command to generate mail_today.gif from the SSH add-on but the sensor.py script does not generate the image (despite not throwing any exceptions).

Yes I just build my own docker image of HASS to always add imagemagick in. Would be nice if there was a way to get it auto-installed by the component.

Might be doable, could you submit this on github as a feature request?

Done. 10char

1 Like