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

There’s no need to modify the code, those are able to be changed via the configuration in the yaml file :wink:

- platform: mail_and_packages
  host: !secret mail_host
  username: !secret mail_user
  password: !secret mail_pwd
  folder: 'Tracking'
  image_path: '/config/www/mail_and_packages/'

I’ve also added a camera component that works off the image_path config from the sensor.
All that is needed is - platform: mail_and_packages in the cameras config.

I thought image_path wasn’t working yet. But good to know thanks!

1 Like

Just found this last night. Thank you for your hard work on this. It is working great and don’t have to worry about a service or anything fancy.

1 Like

Update: haven’t gotten a second ping past 2 days so think we’re good. Must have been a weird goof somewhere.

Have you tried the camera module? Just curious.

Camera module? I don’t know, how could i tell? I just loaded everything from the github.

in the customer_components do you see a camera.py?
if so add:

- platform: mail_and_packages

under cameras: in your configuration.yaml

Then in lovelace you can add camera.mail_usps to view the images. Nice and easy.

Yes i see the camera.py. I still get images/can see them in the UI without this, so maybe I’m missing something?

Correct you can still use the local_file camera to display it as well, but for ease of use I cobbled one together specifically for the mail_and_packages :smiley:

1 Like

Ah. Yeah I can test that out on my dev instance.

1 Like

Can’t figure out how to modify the lovelace to display the camera instead of whatever else it’s using, but the camera seems to load up just fine/i can see it in the states page in dev-tools.

If you click the little box to the left of it in the dev-tools it should open a modal with the image cycling as well.

Working great guys… we will see how it goes with tomorrow’s mail… now if we could just add amazon packages :grinning:(most of mine come from amazons delivery service now)

… although it does not look like the tracking number is in the emails which I guess would be the only way to know it’s an amazon delivery ?

I noticed my FedEx packages didn’t work when I had some FedEx stuff show up between Fri and Sat. I mentioned it in the GitHub and I think it might be the subject line. All the other functions work great!

I also noticed a FedEx package not showing up as “In Transit” (delivery still couple days out). I don’t see anything in sensor.py to look for “Your package is on its way” though either.

Also anyone else getting duplicate mail sensors? I have 2 for almost all of them… but could also be something I missed from @moralmunky original mail component?

You’d want to remove the package yaml to get rid of the duplicate sensors.

I just installed this platform and had a couple issues with it correctly identifying FedEx packages and generating the mail images from Informed Delivery. I believe I’ve tracked it down to two things:

FedEx Packages
The subject line that I received in my e-mail from FedEx reads “Your package is scheduled for delivery today” but the sensor is coded to look for “Delivery scheduled for today”. (I updated the variable on my system.)

USPS Informed Delivery
The sensor correctly identified the number of mailpieces but did not generate the GIF. It appears that an additional space is required between GIF_MAKER_OPTIONS and all_images. When executing the command in the sensor, the word “background” becomes part of the filepath.

convert -delay 300 -loop 0 -coalesce -set dispose background/home/homeassistant/.homeassistant/www/mail_and_packages/1046457451-057.jpg /home/homeassistant/.homeassistant/www/mail_and_packages/mail_today.gif

Once I changed line 868-870 to the below, the GIF was created successfully

try:
    os.system(GIF_MAKER_OPTIONS + ' ' + all_images
        + image_path + GIF_FILE_NAME)

Hope this helps someone! :slight_smile:

This is working for me except for the images of the mail. I am not sure if its scraping the images at all or if its failing to save to the directory? Im trying to run this in hassos.

The path from what I can tell should be /config/www/mail_and_packages/ for my setup.

Any suggestions on troubleshooting?

Set the image_path option to /config/www/mail_and_packages/

Example:

- platform: mail_and_packages
  host: !secret mail_host
  username: !secret mail_user
  password: !secret mail_pwd
  folder: !secret mail_folder
  image_path: /config/www/mail_and_packages/