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

Accumulative across all shippers.

1 Like

I am guessing you are still working around Amazon. Has the examples made it clear how Amazon works differently?

My guess it you will need two alerts. Most of the alerts (USPS Informed Delivery, other out for delivery, with the exception of Amazon of course) usually get sent by a certain time in the morning.

  1. Each morning at a set time (after you think most initial emails will be received) to give you an expectation for the day. This would include the Amazon expected deliveries since they get updated on the first run on the new day since it’s not a NEW email that triggers them like the other shippers. This would be triggered by time not the mail and packages sensors

  2. Through out the day an update triggered by any new emails, additional out for delivery or delivered notifications. This would be triggered by a state change in the mail and packages sensors.

Thanks. Doesn’t seem to work that way. Or not for Amazon. I had sensor.mail.amazon.packages and the Amazon delivered sensor both set to one and the above was still zero.

* Except Amazon

I have attempted to make it clear throughout this thread that Amazon is and has been separate. @firstof9 has been working on getting Amazon accurate in the newest BETA versions. Once it is, you will see it integrated. Please keep an eye on the BETA release notes.

@jriker1 If you feel there is more that needs to be in the documentation to explain the functioning from what you have gathered, please contribute or open issues to suggest documentation changes to the git hub.

2 Likes

Any idea why my automations are failing? I got things like this today:

2020-07-27 13:32:44 ERROR (MainThread) [homeassistant.components.automation] [Mail] Amazon Package Delivered Today: Error executing script. Error rendering template for call_service at pos 1: UndefinedError: 'sensor' is undefined
2020-07-27 13:32:44 ERROR (MainThread) [homeassistant.components.automation] While executing automation automation.mail_amazon_package_delivered_today
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 229, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'sensor' is undefined

This was the automation:

- id: notify_amazon_package_delivered_today
  alias: "[Mail] Amazon Package Delivered Today"
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.mail_amazon_packages_delivered
    above: 0
  action:
    - service: notify.john_and_barb
      data:
        message: >
          {{ sensor.mail_amazon_packages_delivered }} Amazon package delivered today

Do I need to reference it in the message as: states.sensor.mail_amazon_packages_delivered.state?

I would like to add some feedback regarding a future enhancement once the Amazon integration is stabilized. There has been other references previously in this thread as well to this need which I wanted to add on.

It would be incredibly useful if during setup, the Amazon scanner could be configured to support FWD emails as well. Since the Amazon email addresses are tied to identity, financial, device IDs, as well as shopping accounts,. In many cases multiple household members each have their own Amazon device identity and services. Setting up and maintaining multiple M&P integrations and templates seems far more complex and less secure than having a consolidated shipping email account where everyone can just set up an email forward filter without changing their Amazon account info.

This isn’t valid.

Try:

- id: notify_amazon_package_delivered_today
  alias: "[Mail] Amazon Package Delivered Today"
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.mail_amazon_packages_delivered
    above: 0
  action:
    - service: notify.john_and_barb
      data:
        message: >
          {{ trigger.to_state }} Amazon package delivered today

Reference: Automation trigger variables - Home Assistant

@moralmunky has already stated why this wouldn’t work here.

I missed the closed case. Sorry about that. I only searched the open requests. I don’t think it would be easy fix that does not add some complexity, but within the mail headers that usually get forwarded the original To/From is still listed within the email header body, just hidden. Regardless, looks like you all have investigated it and it is not feasible at this time. Thanks for responding!

I don’t know about other email providers, but it works just fine when forwarding messages from a Gmail account. When you manually forward an email, the "FW: " prefix gets attached and the body gets altered, but when you use a filter to automatically forward messages to another account, the subject and body end up looking the same as the original email.

Create a new email address and then link it as a forwarding address in Gmail’s settings. Then you can create a filter which looks something like this and forwards all the relevant emails to the new address:

from:(usps OR ups.com OR fedex OR amazon)

I only installed this component a few days ago but this setup seems to be working for me so far (at least for Amazon deliveries).

1 Like

upgraded to the latest home assistant and this no longer works, anyone else?

Working fine here in 0.113

Working here also… thought it was broken this morning but turns out USPS didn’t send my Informed Delivery email until about 8 hours later than normal…

@david1 Did you also happen to upgrade the integration and need to run through the settings screens for any breaking changes that were introduced in a recent beta update?

1 Like

I received two Amazon packages today but they were not reflected in the in-transit sensor though they showed up in the summary message. Now that the packages have been delivered I almost immediately received a they were delivered emails at 11:03. Forty minutes later they are still showing as in Transit in the summary message but not reflected in the deliveries. The sensor.mail_amazon_packages went from 0 to 2 at the same time as the time on the delivered email.

The entities below don’t seem to reflect Amazon sent packages.

sensor.mail_packages_delivered
sensor.mail_packages_in_transit

OK just saw a hidden reply as this is by design. :frowning: I think it should however reflect Amazon shipped packages.

Just adding some data points. I received this email on Sunday

from [email protected]

The amazon mail sensor showed 0 packages out for deliver, but did show the order Number
image

I then received the package a little bit ago along with an email from [email protected]


along with an image. I was hoping to see the image in the animated gif which also did not happen.

No complaints, just sharing my experience.

EDIT: doubt this makes a difference but wanted to add that in my setup I have my mail messages going to a subfolder. The folder is refrenced properly in the setup though.

1 Like

The amazon delivered image is a separate file in the images directory, amazon_delivered.jpg is the image name. Since this is a new feature, I’ve been awaiting feedback on where the image should end up.

We could defiantly roll it into the usps mail image, but that wouldn’t work for our friends outside of the US :stuck_out_tongue:

Is this with the latest beta? 0.2.2-b13

Thanks for that info. Super cool. I dont get informed delivery, so I may just create a camera entity for the amazon pic.

Yes, I am running the latest version, but it is possible that I upgraded after the email was sent out, but before the package was delivered

EDIT: I checked and no image either. Same folder as the mail.gif right?

Yes, feel free to turn on debugging and create an issue. It was working when I tested it on my last Amazon email.

1 Like