USPS, FedEx, UPS Custom UI Card & Lovelace (Updated 2-29-2020, Newer version available)

Anyway to test UPS, I have 2 packages in transit, but it shows 0 in the card?

The UPS component will show a few different package statuses as attributes with totals counts. The sensor.mail_packages_in_transit takes the total number the UPS component shows and subtracts the amount in the delivery attributes if it exists…

I currently do not have any packages in transit so it doesn’t show any of the status attributes. Does your UPS component currently have any attributes?

You can test it by setting the state and then attributes in the JSON like below.

State set to 6

{
  "attribution": "Information provided by www.ups.com",
  "unit_of_measurement": "packages",
  "friendly_name": "UPS",
  "icon": "mdi:package-variant-closed",
  "package": "Mail and Packages",
  "in_transit":"3",
  "delivered":"2"
}

Results would be ups sensor is 6, 4 in transit and 2 deliveries. If I remember right, the UPS component will show pre-shipement statuses in attributes too. In reality this example would have another attribute to make up for the last package counted in the main sensors 6 package count. I chose to just count those as in transit.

The component doesn’t currently show any attributes.

The UPS component page says the default is setting for scraping the UPS website every hour. I think it would pick it up but now.Are your packages showing in the MyChoice delivery page? I don’t know the inner workings of the UPS MyChoice component but I was receiving information through it over the recent holiday shopping weekend.

Yes, it shows 2 in transit for delivery tomorrow.

Did you ever see UPS packages show? I can confirm the official component is still functioning.

Yes, works perfectly, just need to add a notification for delivered packages, thanks again.

image

Can I install this (mail.py?) on a machine that does not run my main HA instance and use MQTT to get the info displayed there?
I don’t want to overload my live system with a process that constantly runs in the background.
That why I have e.g. Amazon-Dash running on a second RPi3 and I’d feel comfortable to install this cool component on the same machine.

Yes, the mail.py is independent of HASS and can be run on any machine so long as it can communicate with the MQTT server.

1 Like

Great, thanks!
I’ll try to set it up tomorrow :+1:

Is it possible to use this on Hass.io? I can run the mail.py on a pi I use just to run scripts, but is it possible to do the necessary things like install image kick, and the other files on my hass.io machine?

I have not used hass.io in a long time. I believe you would have to turn on the add-on to SSH into the machine in order to place the files by SFTP as well as setting up the systemd service.

Any chance on moving it away from being an OS level service and back into HomeAssistant? I’d love to try this from within Docker, but the current design isn’t really conductive of that.

I suspect the same with hass.io.

So I was able to get mail.py working in a separate docker container doing something like this:

FROM python:3.6
LABEL maintainer="Robert Accettura <[email protected]>"

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN apt-get install imagemagick

RUN pip3 install paho-mqtt

# Copy source
COPY . .

#CMD ["sleep", "infinity"]
CMD [ "python", "usps.py" ]

Then updating mail.py so that mqtt is referenced from:

MQTT_SERVER = "172.17.0.1"
MQTT_SERVER_PORT = 1883

And lastly setting it dependent in my mqtt instance starting and sharing the volume for home assistant configs:

  mail-agent:
    build: build/mail-agent
    restart: "always"
    volumes:
      - ./data/homeassistant/:/data
    depends_on:
      - mqtt

That got mail.py working as a daemon and dockerized. Only other issue I ran into was config.usps wasn’t set due to:

if (!config.mail || !config.usps) {
  throw new Error('Please define entities');
}

I just added:

    usps: sensor.mail_usps

to the block in ui-lovelace.yaml and that cleared up as well.

Hopefully that helps others.

1 Like

I tried to run the py file as a script defined in the home assistant configuration and triggering it with an automation, but it Did not run successfully. There were not any errors in the home assistant log. I don’t have enough knowledge at this point to trouble shoot it yet.

@moralmunky Hey, just getting started with Lovelace, I added the config as per your git, and re-downloaded all files, but my lovelace view is blank, any idea?, I was able to add a couple other lovelace views shared by other members, which show up fine, not sure what the issue may be.

The standard card still displays correctly.

What HomeAssistant version are you attempting this on? I am currently running 0.86.4. My best guess is that /local/mail_card/mail-card.js is not getting loaded. Are you seeing any errors in the web browser error console?

When I switched from manually managing the Lovelace.yaml to the raw UI editor it had an issue keeping the resource portion in there.

I have the resource section on the first thing

This is really awesome thanks for your work!

I am trying to get this working but not having much luck. I will keep working at it and may post back with some questions. I am running hassio inside a docker on a Ubuntu VM.

I’m getting “please define entities” when trying to add to Lovelace… or just a blank page when using raw config editor.
I have the resources loaded as you show above and it definitely sees mail-card.js…

That message is from the .js file

  setConfig(config) {
    if (!config.mail || !config.usps) {
      throw new Error('Please define entities');
    }
    this.config = config;

Meaning, the mail: or the usps: options where you pass sensors are not defined or do not exists in your yams configuration package

homeassistant:
  customize_glob:
    input_text.mail_delivery_summary:
      name: Delivery Summary
      custom_ui_state_card: custom-mail-card
      config:
        ups: sensor.mail_ups
        fedex: sensor.mail_fedex_packages
        usps: sensor.mail_usps_packages
        mail: sensor.mail_usps
        transit: sensor.mail_packages_in_transit
        today: sensor.mail_deliveries_today
        summary: sensor.mail_deliveries_message
        usps_update: sensor.mail_update

Double check that they are filled out and that they exist in the developer panel. They are defined in the yaml package under the sensor: section, if you copy and pasted the file and didn’t change any of the names, then there must something elsewhere.