This provides a Card, Custom Component, and Notifications for getting UPS, USPS, and FedEx delivery information in Home Assistant. This component shows a snapshot of the current days packages that are in transit for delivery on the current day or have already been delivered on the current day. It also generates the number of USPS mail pieces and images, if available, for the current day.
The component connects to the email account you supply where your shipment notifications are sent. It looks at the subject lines of the current day's emails from the shipping companies and counts the subject line matches to the known standard subject lines from the shipping companies. For USPS Informed delivery emails, it also downloads the mail images to combine them into a rotating GIF.
All procedures are done locally on your machine.
Supports only Lovelace UI. Last tested in 0.105.x.
- Mail Card based on Bram_Kragten work at Home Assistant Community: Custom UI weather state card, with a question
- Mail.py script based on @skalavala work at skalavala blog
- Package and macros based on happyleavesaoc work at happyleavesaoc/my-home-automation
USPS Informed Delivery: account and all nortifications turned on for email with the email address you will have the component check.
FedEx Delivery Manager: account and all nortifications turned on for email with the email address you will have the component check.
UPS MyChoice: account and all nortifications turned on for email with the email address you will have the component check.
- Have HACS installed, this will allow you to easily update
- Add
https://github.com/moralmunky/Home-Assistant-Mail-And-Packages
as a custom repository as Type: Integration - Click install under "Mail and Packages", restart your instance.
- Download this repository as a ZIP (green button, top right) and unzip the archive
- Copy
/custom_components/mail_and_packages
to your<config_dir>/custom_components/
directory- You will need to create the
custom_components
folder if it does not exist - On HomeAssistant (formerly hass.io) the final location will be
/config/custom_components/mail_and_packages
- On Hassbian the final location will be
/home/homeassistant/.homeassistant/custom_components/mail_and_packages
- You will need to create the
- Copy/move
image-no-mailpieces700.jpg
andmail_none.gif
to the images directory (recommend<config_dir>/images/mail_and_packages
as the path)
Once you have finished either installing via HACS or manually (and rebooted HASS), go into Configuration -> Integration
select the +
and add the Mail And Packages
integration. You will be prompted to input your mail server settings.
Please note that anything in the www
folder is techncially publicly accessable unless you have taken security measures like a reverse proxy with authentication enabled. You can place the images in an images
directory and still send notifications via most notification integrations.
Use the following to create a deliveries summary sensor (under the sensor portion of configuartion.yaml):
- platform: template
sensors:
mail_deliveries_message:
friendly_name: "Deliveries Summary"
entity_id:
- sensor.mail_usps_mail
- sensor.mail_usps_delivering
- sensor.mail_fedex_delivering
- sensor.mail_ups_delivering
value_template: >
{# Deliveries Sentence #}
{% macro deliveries_sentence() -%}
{%- if states("sensor.mail_usps_mail")|int == 0 -%}
No
{%- else -%}
{{states("sensor.mail_usps_mail")|int}}
{%- endif -%}
{{' '}}
{%- if states("sensor.mail_usps_mail")|int <= 1 -%}
pieces of mail
{%- else -%}
pieces of mail
{%- endif -%}
{{' '}}will be delivered.{{' '}}
{%- if states("sensor.mail_usps_delivering")|int == 0 -%}
No
{%- else -%}
{{states("sensor.mail_usps_delivering")|int}}
{%- endif -%}
{{' '}}
{%- if states("sensor.mail_usps_delivering")|int == 1 -%}
USPS package is
{%- else -%}
USPS packages are
{%- endif -%}
{{' '}}in transit.{{' '}}
{%- if states("sensor.mail_fedex_delivering")|int == 0 -%}
No
{%- else -%}
{{states("sensor.mail_fedex_delivering")|int}}
{%- endif -%}
{{' '}}
{%- if states("sensor.mail_fedex_delivering")|int == 1 -%}
FedEx package is
{%- else -%}
Fedex packages are
{%- endif -%}
{{' '}}in transit.{{' '}}
{%- if states("sensor.mail_ups_delivering")|int == 0 -%}
No
{%- else -%}
{{states("sensor.mail_ups_delivering")|int}}
{%- endif -%}
{{' '}}
{%- if states("sensor.mail_ups_delivering")|int == 1 -%}
UPS package is
{%- else -%}
UPS packages are
{%- endif -%}
{{' '}}in transit.{{' '}}
{%- if states("sensor.mail_amazon_packages")|int == 0 -%}
No
{%- else -%}
{{states("sensor.mail_amazon_packages")|int}}
{%- endif -%}
{{' '}}
{%- if states("sensor.mail_amazon_packages")|int == 1 -%}
Amazon package is
{%- else -%}
Amazon packages are
{%- endif -%}
{{' '}}in transit.{{' '}}
{%- endmacro %}
{{deliveries_sentence()}}
You may also want to add a camera to display the image. Add to the camera portion of configuration.yaml.
- platform: local_file
file_path: /config/images/mail_and_packages/mail_today.gif
name: mail_usps
- alias: "Mail Notif - Mail Delieveries"
initial_state: 'on'
trigger:
#Trigger if mail or packages get updated
- platform: state
entity_id: sensor.mail_usps_mail
- platform: state
entity_id: sensor.mail_usps_delivering
#send only if mail or packages are more than 0
condition:
- condition: or
conditions:
- condition: template
value_template: "{{ states('sensor.mail_usps_mail') | int > 0 }}"
- condition: template
value_template: "{{ states('sensor.mail_usps_delivering') | int > 0 }}"
action:
- service: notify.YOUR_NOTIFY_METHOD
data_template:
title: "*Today's Mail and Packages*"
message: "{{ states('sensor.mail_deliveries_message')}}"
- service: notify.YOUR_NOTIFY_METHOD
data:
message: "Here is the mail"
data:
document:
file: "PATH_TO_FILE/mail_today.gif"
A few options here as provided by the community: Note: The local file camera reloads the file after 10 seconds. If the gif is longer than 10 seconds not all mail with be shown. Please use a picture entity card with the camera view set to live.
Option 1 (requires vertical stack in card custom card)
- type: custom:vertical-stack-in-card
title: Mail & Package Tracking
cards:
- aspect_ratio: 50%
camera_view: live
entity: camera.mail_usps
name: Mail
type: picture-entity
- type: entity-filter
state_filter:
- operator: ">"
value: '0'
entities:
- entity: sensor.mail_usps_mail
name: "Today's Mail"
- entity: sensor.mail_packages_in_transit
name: "Today's Package Delivery"
- entity: sensor.mail_usps_delivering
icon: 'mdi:package-variant-closed'
name: USPS
- entity: sensor.mail_fedex_delivering
icon: 'mdi:package-variant-closed'
name: FedEx
- entity: sensor.mail_ups_delivering
icon: 'mdi:package-variant-closed'
name: UPS
- entity: sensor.mail_updated
state_filter:
- operator: "regex"
value: 20
cards:
- cards: null
entities:
- entity: sensor.mail_usps_mail
name: Todays USPS Mail
- entity: sensor.mail_packages_in_transit
name: Todays Package Delivery
type: entities
- cards: null
entities:
- entity: sensor.mail_usps_delivering
icon: 'mdi:package-variant-closed'
name: USPS
- entity: sensor.mail_fedex_delivering
icon: 'mdi:package-variant-closed'
name: FedEx
- entity: sensor.mail_ups_delivering
icon: 'mdi:package-variant-closed'
name: UPS
show_header_toggle: false
type: glance
- aspect_ratio: 50%
camera_view: live
entity: camera.mail_usps
name: Mail
type: picture-entity
- cards: null
entities:
- entity: sensor.mail_updated
type: entities
title: Mail & Package Tracking
type: 'custom:vertical-stack-in-card'
- cards:
- aspect_ratio: 50%
camera_view: live
entity: camera.mail_usps
name: Mail
type: picture-entity
- entities:
- entity: sensor.mail_usps_mail
name: USPS Mail
- entity: sensor.mail_usps_packages
name: USPS Packages
- entity: sensor.fedex_packages
name: FedEx Packages
- sensor.mail_ups_packages
- sensor.mail_packages_in_transit
- sensor.mail_packages_delivered
- entity: sensor.mail_updated
state_filter:
- operator: regex
value: 20
state_filter:
- operator: '>'
value: '0'
type: entity-filter
title: Mail Today
type: vertical-stack