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

New to this integration, very cool! I am having a problem, tried searching the thread but may not be looking for the right terms. Rather then point the integration at my personal email address, in my gsuite account I set up a mail group alias, so emails from USPS and FedEx send to my email, and my HA email for this integration. Fedex and USPS don’t seem to support more then one email address, but UPS does hence I went this route. I noticed while the emails to mygroupalias@mydomain are arriving into the inboxes of both email accounts, turning on debugging it says that 0 packages detected (I had USPS and Fedex notifications and delivery emails today.) UPS however DID work correctly and had my hass@mydomain email added to my UPS profile. Looking into the inbox of hass@mydomain, I do indeed see the UPS email that was processed is marked read, but the USPS and FedEx emails for today are not. The only difference is the destination email of mygroupalias@mydomain for the one’s that didn’t work, and hass@mydomain for the one that did. Does this integration look at the destination email for a match, or should it not care I’m using a gsuite group email address? Thanks!

The destination email address isn’t looked at.

For more information please see the wiki for how the integration works.

@firstof9 Thanks for the response, and I think I figured it out and looks my approach won’t work with the integration. Looks like when using a gsuite group alias for emails with USPS and Fedex, the email address for the “From” comes FROM that mail group alias too, not from the USPS or FedEx email . So while the email subjects were correct, the source of the email looks like it’s coming from gsuitegroupalias@domain.

In other words, since I set up packages@mydomain as an email group for USPS/Fedex, the email is showing from packages@mydomain, I assume not seeing the fedex or usps source, and then not processing them?

EDIT: This is what the header looks like, personal email domains removed:

from:	'FedEx Delivery Manager' via Packages <packages@mydomain>
reply-to:	[email protected]
to:	homeassistant@mydomain

If you setup a gmail filter to forward the emails to ‘homeassistant@domain’ this will work better.

1 Like

I didn’t think that would work, I will give it a shot, thank you!

EDIT: That worked, thank you! Didn’t think it was so easy, and over thought it. I did try to search the forum and wiki for guidance and obviously missed it.

Would it be possible to also add the subject “Your UPS Packages were delivered” to the supported list? Every email I’ve gotten from ups appears to have this subject and they are never counted on the delivered sensor. Even if it’s just one package, it has this subject.

It’s already in there:

1 Like

Thanks @firstof9. I was looking at the wiki.

Ya stuffing all the searches into the table would make it much larger lol

So with the latest beta getting rid of the option for non-rotating image names*, what’s the best way to update the image path for the camera? The new image URL sensor gives a URL path. I can hack a way together with NodeRed by stripping the leading url path to just get the file name and then pass that through to a file_path update if needed. But it also appears that this change would break the wiki example for the camera: https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Example-Automations-and-Templates#camera

* Mini-rant: I get this change in light of the security bulletin for HASS…but I’m frustrated. I already had moved my image out of the www directory and I don’t want it accessible to the internet…at least not through an image path (even randomly generated). Is there a way to make it so that if your path directory is in /www you have to use the random generated file name but if you move it outside of that directory (in my case /config/images/mail_and_packages) you don’t have to use the random file name? It just creates a lot more automation requirements and things that could break IMO.
Edit to add caveat: I’m testing in a dev HASS instance right now and there’s no mail today so if when there’s mail there still is a image_name attribute I’ll try to make it work.

So with the latest beta b33, are the secure images being successfully created for anyone else? I’m looking in the /config/www directory for the add-on and not seeing them created. The official lovelace card displays a broken image as well. I’ve got the camera entity updating automatically like in the wiki as well.

So it looks like there is a difference in the new sensor that is in the new version and the old attribute for the filename. The filename in the attribute is not getting updated correctly. This would be why I was having a lot of trouble with the instructions in the wiki.

The changes added to the latest beta are part of an effort to accomplish three things.

  1. Streamline/simplify configuration
  2. Eliminate the risk of inadvertently sharing confidential information at a standard path
  3. Reduce image related help requests

sensor.mail_image_url provides the needed URL for iOS notifications and display in the custom card (future update).
sensor.mail_image_system_path provides the file_path portion of the automation that updates a user created camera entity. Appears the file name is currently missing from this sensor in the beta.

Also, this as a first step to explore the possibility of creating a camera entity from within the integration so no extra set up is needed for the image or camera.

Feedback and discussion is welcome in the feature request related to this change.

The image name is still listed as an attribute of sensor.mail_usps_mail. There should be no affect on the Update USPS Mail Camera automation example. Unless a bug was inadvertently included in the code :slight_smile: If a user previously stored the image in a place other than /config/www/mail_and_packages/, the automation would need to be updated to reflect the standardized path in the beta.

The integration can figure out the path to the config directory and internal/external domain of the HASS install. That combined with a standard image path within the install helps create universal solution to get the paths needed for the different ways to display the image.

Last I checked the www directory is where the image has to be stored to include it in iOS notification (maybe Android too?). So that is the one I chose to suggest in the feature request.

The goal, not yet there, is that this would work for everyone with random file names

- alias: "Update USPS Mail Camera"
  trigger:
    - platform: state
      entity_id: sensor.mail_usps_mail
  action:
    - service: local_file.update_file_path
      data_template:
        entity_id: camera.mail_usps
        file_path: {{ states('sensor.mail_image_system_path') }}

Feedback and discussion are welcome on the feature request.

Ah, missed that that was the Github issue. I’ll chime in over there too.

I agree with these goals. But it also goes back to some of the YAML v. Integration arguments where power users don’t like features/options being taken away. I have no issues with the defaults being random image. But I do think that forcing the path to be in /local actually takes away a security feature, which is putting it in a different directory all together and making it not publicly accessible at all.

I don’t use the HASS app for the notification (iOS or Android. I instead use Telegram/Matrix, which allows you to pass through a local file without issues (so the image doesn’t need to be publicly accessible). I also believe (though haven’t been able to confirm and it may be iOS only) that you can use the camera stream directly without having to make it accessible. See Dynamic attachments | Home Assistant Companion Docs. I’ve run into issues with the GIF part tbh but that may be more that I use Matrix as my chat which has lackluster image/gif support ATM.

I totally understand the goal and making this more user friendly. But I remember when I initially tried out the auto image rotation thing I had trouble getting it to work nicely with NodeRed, which is something a lot of people use. Found my post on this: Mail and Packages: Custom component for UPS, FEDEX, and USPS - #340 by fuzzymistborn . I can stay on my current version for now but as you know, USPS/UPS/Fedex like to mess with things so I’ll need to update at some point in the future and right now this pretty much breaks the integration for me.

Anyway, rant over, it’s time for bed.

All 3 sensors should have the same exact filename.

I can’t seem to get this functioning. Just updated to b34

image

But config check shows

image

I can see the state is set

Your indention looks off.

Same. I copied the indentiation just now from Mail and Packages: Custom component for UPS, FEDEX, and USPS

image

image

Is that line 9?