[New Addon] USPS Package Tracker

Hey everyone, just finished up the very minor release for the USPS Package Tracker.

You can add my repo here: https://github.com/AndBobsYourUncle/hassio-addons

This uses the USPS Informed Delivery service and scans the email for the updates that are sent. It then keeps track of each package, and updates it as new emails come in.

You have an endpoint that serves up enroute packages, delivered today, and one for getting all packages in the system.

To use this addon, I’d recommend creating a brand new Gmail account just for this, and setup Informed Delivery to send package notifications to that email address, like this:

First click on “Settings” in the Informed Delivery site:


Then fill out the package update notifications section with the new email address and check off all the possible updates:

Then, once you have your email up and running with Informed Delivery (and you’re getting emails there for package updates), then install the addon and follow this nifty video tutorial on how to link up your new Gmail account to this addon with OAuth:

You should start getting stuff like this when you hit the addons endpoints:
http://hassio.local:9005/packages


  "packages": [
    {
      "status": "delivered",
      "latest_message_subject": "USPS® Item Delivered, Front Door/Porch 943856749832308934",
      "tracking_number": "943856749832308934",
      "delivered_location": "Front Door/Porch",
      "delivery_from": null,
      "delivery_to": null,
      "delivered_at": "2019-12-04T20:06:22.000Z"
    },
    {
      "status": "delivered",
      "latest_message_subject": "USPS® Item Delivered, Front Door/Porch 92039393012939023",
      "tracking_number": "92039393012939023",
      "delivered_location": "Front Door/Porch",
      "delivery_from": null,
      "delivery_to": null,
      "delivered_at": "2019-12-04T20:06:25.000Z"
    }
]

You also get a couple other endpoints:
http://hassio.local:9005/enroute
http://hassio.local:9005/enroute_today
http://hassio.local:9005/delivered_today

All of these automatically filter based on the current status and delivery date of the packages. You can use these endpoints to create sensors or custom UI cards, or whatever you’d like. I just have a couple sensors for now that count how many JSON objects are in the “packages” array, and show me the number of enroute and delivered packages.

The “delivered_today” route only shows packages that have a “delivered_at” of the current day.

Let me know if you have any questions or feature requests.

2 Likes

Just added an “enroute_today” endpoint to get packages that are due to be delivered on the current day.

The Video that you posted is not working correctly, i appreciate your work on this add on and i would love to see it working on my setup thanks

Alright, I’ve uploaded the video to a different site that seems to work better and edited it into my original post. Let me know if you have any questions.

I finally got this setup after not having the time working good so far thank you for you work

HI Uncle Bob, can you share your config for the sensor? thanks

Sure! I have a different kind of setup, because I like to use NodeRED to update sensor values for stuff like this, but here are the sensors:

- platform: mqtt
  name: Delivered Packages
  unit_of_measurement: 'packages'
  state_topic: "home/delivered_packages"

- platform: mqtt
  name: Enroute Packages
  unit_of_measurement: 'packages'
  state_topic: "home/enroute_packages"

- platform: mqtt
  name: Enroute Today Packages
  unit_of_measurement: 'packages'
  state_topic: "home/enroute_today_packages"

And then here’s the NodeRED stuff:

[
    {
        "id": "7bb2de21.567b8",
        "type": "tab",
        "label": "USPS",
        "disabled": false,
        "info": ""
    },
    {
        "id": "547dded8.bc5d5",
        "type": "http request",
        "z": "7bb2de21.567b8",
        "name": "Get Enroute Packages",
        "method": "GET",
        "ret": "obj",
        "paytoqs": false,
        "url": "http://192.168.1.51:9005/enroute",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 160,
        "y": 120,
        "wires": [
            [
                "6e42e77d.e839a8"
            ]
        ]
    },
    {
        "id": "9a122f63.f2aac",
        "type": "inject",
        "z": "7bb2de21.567b8",
        "name": "Fetch every 10 Minutes",
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": "0",
        "x": 150,
        "y": 40,
        "wires": [
            [
                "547dded8.bc5d5",
                "f3d8a3d7.e04b4",
                "6a72763a.0542d8"
            ]
        ]
    },
    {
        "id": "6e42e77d.e839a8",
        "type": "function",
        "z": "7bb2de21.567b8",
        "name": "Get Count",
        "func": "msg.payload.enroute_count = msg.payload.packages.length;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 150,
        "y": 200,
        "wires": [
            [
                "151e4437.12173c"
            ]
        ]
    },
    {
        "id": "151e4437.12173c",
        "type": "change",
        "z": "7bb2de21.567b8",
        "name": "Set Enroute Count",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.enroute_count",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 150,
        "y": 280,
        "wires": [
            [
                "835431ba.57c57"
            ]
        ]
    },
    {
        "id": "835431ba.57c57",
        "type": "mqtt out",
        "z": "7bb2de21.567b8",
        "name": "home/enroute_packages",
        "topic": "home/enroute_packages",
        "qos": "",
        "retain": "true",
        "broker": "f8d229e8.e776e8",
        "x": 150,
        "y": 360,
        "wires": []
    },
    {
        "id": "f3d8a3d7.e04b4",
        "type": "http request",
        "z": "7bb2de21.567b8",
        "name": "Get Delivered Packages",
        "method": "GET",
        "ret": "obj",
        "paytoqs": false,
        "url": "http://192.168.1.51:9005/delivered_today",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 770,
        "y": 120,
        "wires": [
            [
                "c13a04e9.5f9518"
            ]
        ]
    },
    {
        "id": "c13a04e9.5f9518",
        "type": "function",
        "z": "7bb2de21.567b8",
        "name": "Get Count",
        "func": "msg.payload.delivered_today = msg.payload.packages.length;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 750,
        "y": 200,
        "wires": [
            [
                "8fe0d77a.74f128"
            ]
        ]
    },
    {
        "id": "8fe0d77a.74f128",
        "type": "change",
        "z": "7bb2de21.567b8",
        "name": "Set Delivered Count",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.delivered_today",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 280,
        "wires": [
            [
                "abab97cb.371a88"
            ]
        ]
    },
    {
        "id": "abab97cb.371a88",
        "type": "mqtt out",
        "z": "7bb2de21.567b8",
        "name": "home/delivered_packages",
        "topic": "home/delivered_packages",
        "qos": "",
        "retain": "true",
        "broker": "f8d229e8.e776e8",
        "x": 760,
        "y": 360,
        "wires": []
    },
    {
        "id": "6a72763a.0542d8",
        "type": "http request",
        "z": "7bb2de21.567b8",
        "name": "Get Enroute Today Packages",
        "method": "GET",
        "ret": "obj",
        "paytoqs": false,
        "url": "http://192.168.1.51:9005/enroute_today",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 460,
        "y": 120,
        "wires": [
            [
                "af2c5b9a.41e268"
            ]
        ]
    },
    {
        "id": "af2c5b9a.41e268",
        "type": "function",
        "z": "7bb2de21.567b8",
        "name": "Get Count",
        "func": "msg.payload.enroute_count = msg.payload.packages.length;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 430,
        "y": 200,
        "wires": [
            [
                "87635084.f2dbf"
            ]
        ]
    },
    {
        "id": "87635084.f2dbf",
        "type": "change",
        "z": "7bb2de21.567b8",
        "name": "Set Enroute Today Count",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.enroute_count",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 280,
        "wires": [
            [
                "b543ab3a.642498"
            ]
        ]
    },
    {
        "id": "b543ab3a.642498",
        "type": "mqtt out",
        "z": "7bb2de21.567b8",
        "name": "home/enroute_today_packages",
        "topic": "home/enroute_today_packages",
        "qos": "",
        "retain": "true",
        "broker": "f8d229e8.e776e8",
        "x": 450,
        "y": 360,
        "wires": []
    },
    {
        "id": "f8d229e8.e776e8",
        "type": "mqtt-broker",
        "z": "",
        "name": "Home Assistant",
        "broker": "localhost",
        "port": "1883",
        "clientid": "nodered",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

It looks like this: