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

The betas (latest) are usually stable enough, I run them on my production system just fine. The more testing the better.

Yes it’s installable via HACS.

With the camera image for the Amazon packages, should it show a no package image the next morning or is that in the works?

I have a question. It may be more of a HACS question or a .js question, but something I’ve been trying to do just seems to not be happeing. So when the mail card was not working earlier, I realized it was likely due to being named incorrectly. I went into the mailcard.js file and made the changes, but they never seemed to “take” I refreshed, restarted, etc but nothing changed. Also the path says /hacsfiles, but I know that’s not a real path, its www/community/etc

Anyway, so now I tried to make a few more changes, just for me. I wanted to add the word amazon (I get that it’s not reliable) to the card. I went in and made changes to a few lines of code, and I have the same issue. It acts as if I’ve done nothing?

Does HACS put a copy of the file somewhere else (HACSFILES??) other than the community folder?

Here’s where we are today.

7:49AM USPS email
6:39AM Shipped arriving Sunday July 26

Right now showing 3 pieces of mail and nothing coming from USPS for the sensors:

mail_usps_delivering 0
mail_usps_mail 3
mail_amazon_packages 0
mail_amazon_packages_delivered 0

Here is the email I got today so additional items shipped from the same order:

7:49AM USPS email
6:39AM Amazon Shipped arriving Sunday July 26

Note I never got an alert. Kind of stopped since tweaking the original automation. Here’s my current automation:

- 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
    - platform: state
      entity_id: sensor.mail_fedex_packages
    - platform: state
      entity_id: sensor.mail_ups_packages
    - platform: state
      entity_id: sensor.mail_amazon_packages
  #send only if mail or packages are more than 0
  condition:
    - condition: or
      conditions:
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_usps_mail.last_changed)) < 15 and sensor.mail_usps_mail > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_packages_in_transit.last_changed)) < 15 and sensor.mail_packages_in_transit > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_ups_packages.last_changed)) < 15 and sensor.mail_ups_packages > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_fedex_packages.last_changed)) < 15 and sensor.mail_fedex_packages > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_amazon_packages.last_changed)) < 15 and sensor.mail_amazon_packages > 0) }}"
  action:
    - service: notify.john_and_barb
      data_template:
        title: "*Today's Mail and Packages*"
        message: "{{ states('sensor.mail_deliveries_message')}}"
    - service: notify.john_and_barb
      data:
        message: "Here is the mail"
        data:
          document:
            file: "/config/www/images/mail_and_packages/mail_today.gif"

EDIT: Note these are the logs and I can see an issue with the sensor at one point. Can see it’s related as the task runs every hour and the sensor error is on that timeline:

2020-07-25 01:11:02 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 02:11:33 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 03:12:03 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 04:12:33 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 05:13:03 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 06:13:33 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 07:14:04 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 08:14:34 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 08:14:36 ERROR (MainThread) [homeassistant.helpers.condition] Error during template condition: UndefinedError: 'sensor' is undefined
2020-07-25 09:15:04 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds
2020-07-25 10:15:34 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.mail_amazon_packages_delivered is taking over 10 seconds

Since that feature’s new, I haven’t really gone into a “No Packages” image placeholder yet, I’ll put it on my todo list.

HACS uses gzip files, so if you are going to modify the card, you will need to delete the gzip file in the directory with the card, otherwise HACS will re-extract it.

Based on this error it seems like one of the sensors might not be enabled? Can you double check them in the dev-tools -> states?

Looks like they are all set:



Verifying Physically.

EDIT: All sensors show active none unknown or whatever they say when not there.

Made a small adjustment, try this:

- 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
    - platform: state
      entity_id: sensor.mail_fedex_packages
    - platform: state
      entity_id: sensor.mail_ups_packages
    - platform: state
      entity_id: sensor.mail_amazon_packages
  #send only if mail or packages are more than 0
  condition:
    - condition: or
      conditions:
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_usps_mail.last_changed)) < 15 and states('sensor.mail_usps_mail') > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_packages_in_transit.last_changed)) < 15 and states('sensor.mail_packages_in_transit') > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_ups_packages.last_changed)) < 15 and states('sensor.mail_ups_packages') > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_fedex_packages.last_changed)) < 15 and states('sensor.mail_fedex_packages') > 0) }}"
        - condition: template
          value_template: "{{ ((as_timestamp(now()) - as_timestamp(states.sensor.mail_amazon_packages.last_changed)) < 15 and states('sensor.mail_amazon_packages') > 0) }}"
  action:
    - service: notify.john_and_barb
      data_template:
        title: "*Today's Mail and Packages*"
        message: "{{ states('sensor.mail_deliveries_message')}}"
    - service: notify.john_and_barb
      data:
        message: "Here is the mail"
        data:
          document:
            file: "/config/www/images/mail_and_packages/mail_today.gif"

Looking thru. Erroring.

What’s the errors? It should work as long as the sensor isn’t unavailable

Not sure it went all the way back to the configuration.yaml. Basically at:

sensor: !include_dir_merge_list entities/sensor

If I comment out the sensor_mail.yaml test passes.

this isn’t a sensor, it’s an automation

Yeah I just caught that. Stuck it in the wrong folder. That’s what happens when you are watching something, talking to someone, and using your gaming laptop that seems to run at 1/3 the speed when not plugged in. :slight_smile: So now I guess I will have to wait to see until Monday if something happens.

1 Like

Ok, so I reinstalled everything from HACS using the repos. Still back to where I was. It’s detecting my USPS Informed Delivery fine, but for some reason the camera is still borked!

also as a side note, what are you supposed to use as the deliver message sensor anyway?

edit: ok see this in the logs.

Could not read camera mail_usps image from file: /config/images/mail_and_packages/mail_today.gif
type or paste code here

makes sense since this gif doesn’t exist.

Edit: ok it doesn’t work the random image filename option ticked. Not even sure why it’s an option then?

Ok now that this is setup, it’s great. That just leaves my last question of what are you supposed to use as the deliver message sensor anyway?

Feature requests:

Instead of a slide show, show all mail Pieces as a vertical stack.

In addition to deliveries and In Transit at the top of the card, also add Out for Delivery so we know whats arriving today.

Thanks for all your help guys, great widget!

Again, you will find it in the docs. It’s not part of the integration. If you need help please review the template sensor section of the home assistant documentation and search the forum for template sensors.

This morning obviously am not going to get USPS but have a sensor in the system I should be getting a package today. shouldn’t that have triggered an alert?

image

I know the automations and the like are examples. Debating if I need to create multiple automations based on each sensor and simplify the alerts. Just have separate alerts that if the sensor changes to 1 or in some cases more than 0 trigger. Then if each one individually switch back to 0 won’t do anything.

Was thinking that although neat the sensor that merges all the sensors into one message is neat, but may not work right for families. If alerts were triggering for me right now, my family gets the alert and says you are getting 3 pieces of mail and no packages. But then an email comes thru for some package being delivered later and may then trigger another email that now says you are getting a package. Maybe even build up a message based on any sensors with values greater than 0 and now show messages for sensors that are 0.

The alert would have triggered around midnight.

Since they’re just examples, feel free to break them out and do as you please, they’re not a one size fits all.

What’s the difference between:

sensor.mail_packages_delivered
sensor.mail_usps_delivered

Does the second one assume if the USPS would tell when your regular mail is delivered and the other if a package from the USPS is delivered?