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

Seems that a time pattern check could work although I’ve not received any iOS push notifications in the past 24 hrs but do see in the logs that the mail and packages is updating every 15 minutes. I don’t have any deliveries in transit either.

# NOTIFY IF MAIL IS EXPECTED
- alias: "Mail Notify - Mail Deliveries"
  initial_state: 'on'
  trigger:
    - platform: time_pattern
      hours: /2 # repeat every 2 hrs.
    - platform: state    # Trigger if mail or packages get updated
      entity_id: sensor.mail_usps_mail
    - platform: state
      entity_id: sensor.mail_usps_delivering
  condition:
    condition: and
    conditions:
      - condition: time    # Time condition between 7AM - 9PM
        after: '07:00:00'
        before: '21:00:00'      
      - condition: or    # Send only if mail or packages are more than 0
        conditions:
        - condition: template
          value_template: "{{ states('sensor.mail_usps_mail') | int > 0 }}"
        - condition: template
          value_template: "{{ states('sensor.mail_usps_delivering') | int > 0 }}"
  action:
    ...

Hoping that someone can help with the image generation. I feel like it’s almost there but there’s just something misconfigured somewhere. I’m running HASS on Windows. The HASS directory is ....\.homeassistant

The integration is at: \.homeassistant\custom_components\mail_and_packages

According to the log: INFO (SyncWorker_4) [custom_components.mail_and_packages.sensor] Mail image generated.

But I don’t see the images anywhere. In the integration the mail images path is set up as: /config/www/mail_and_packages/. I was following the examples but do I need something different specifically for a Windows environment? The \.homeassistant\www\mail_and_packages dir is currently empty.

Ta.

Your image directory will need to be .../.homeassistant/www/mail_and_packages where the ... is whatever the path is to your Home Assistant config.

Tremendous, thanks. That fixed it - I didn’t realise it needed the full absolute path.

1 Like

I am right in thinking that in order to display the image of today’s mail, you need to either:

  1. Use the custom Lovelace card and set it’s ‘gif’ property appropriately, OR
  2. Define a camera pointing to a local file (and if using random gif names then have an automation that updates the local file name based on the mail sensor’s ‘image’ attribute).

For option 1, is the random image name feature supported? I tried setting ‘gif’ to something like:

/local/mail_and_packages/'{{ state_attr('sensor.mail_usps_mail','image') }}'

but that doesn’t work.

I’m not sure. You’ll have to poke moralmunky about that one.

No worries. Checked the code - it’s not supported at the moment, so I’ll go the manual route for the UI.

I use the local_file camera and have an automation update the image when it changes, all my other entities are just in an entity card. Like so:

Yeah I plan on doing exactly that, and incorporating some of the bits from this.

I do like his icons, think I’ll add them to my card :smiley:

I really like the card that combines all the sensors as well as the gif so I’ve been trying to figure out how to add the amazon sensor to it.

Add a feature request to the card’s github?

1 Like

Slimmed mine down now:
image

1 Like

Oh i like that! Those icons are excellent

UPS, FedEx and the USPS are from the reddit post, I added in 2 amazon icons, one with black background, one with white (as shown).

Here’s a link to them.

Card config if you’d like as well:

type: vertical-stack
cards:
  - type: horizontal-stack
    cards:
      - entities:
          - entity: sensor.mail_usps_mail
            name: USPS Mail
          - entity: sensor.mail_packages_in_transit
            name: Packages in Transit
          - entity: sensor.mail_packages_delivered
            name: Packages Delivered
          - entity: sensor.mail_updated
          - entity: input_select.notify_select
        show_header_toggle: false
        type: entities
  - type: glance
    entities:
      - entity: sensor.mail_ups_packages
        image: /local/icons/ups.png
      - entity: sensor.mail_fedex_packages
        image: /local/icons/fedex.jpeg
      - entity: sensor.mail_usps_packages
        image: /local/icons/usps.png
      - entity: sensor.mail_amazon_packages
        image: /local/icons/amazon-wh.png
    show_name: false
5 Likes

Wow Thanks I will definitely be stealing some of that:)

Very nice - I as well have copied this setup. The icons are a very nice touch!
Thanks!

Credit to u/RUNNING_IN_SPACE

1 Like

hi,
how much effort does it take to integrate other parcel services?
I am living in germany and would want to integrate DHL, GLS, DPD and Hermes. I already created a feature request for this, before I was pointed to this integration.

https://community.home-assistant.io/t/universal-parcel-tracking-integration/197187

What can I do to support?

We’d need to know what the emails look like (and the delivery service would need to support sending out status emails like “out for delivery”).