To keep up with the modernization of Home assistant this old card is no longer supported. The most recent revisions of the component and card can be found in the following repositories and discuss in the thread below.
Hello Everyone,
In the wake of the official USPS and FedEx components breaking I wanted to share what I have pulled together from other users work to get that information back into Home Assistant and Notifications. It’s not perfect but it’s better than no information at all.
Before the flamers get started about it not being Lovelace UI, yes I’ve seen those unhelpful replies in other threads, I have a lot to learn before I can hack together a Lovelace custom card. Also, I don’t know enough about python to contribute to fixing the broken components.
Thanks to @Bram_Kragten (Template based on the custom weather card), @skalavala@Vasiley@arychj (Python email check base code), and @happyleaves (Packages and Macro examples). These people are the ones that did the heavy lifting in their own projects.
Basically the python script scans an email account for emails from USPS, USPS Informed Delivery, and FedEx containing the delivery alerts. I can only take credit for added the FedEx part which was really just copying and pasting existing code and getting the subject lines from FedEx. It runs periodically and feeds the counts and a stitched gif of the USPS Informed Delivery images to Home Assistant. The front end contains a custom card to pull all the services information together along with the gif. The notification sends the summary and gif when mail pieces or package count increases. So far the UPS component is still going strong.
What doesn’t work is the updating of the image in the front end. Currently, the browser needs a cache flush to grab the new version. Notifications send the new image as expected.
You can find all the necessary files, code, and instructions in the GitHub repository
Any idea why it show’s “Checked unknown” and doesn’t seem to update?
No error’s in log.
Edit:
Just checked the status and got the following:
pi@hassbian:/etc/systemd/system $ sudo systemctl status homeassistant_mail_check .service
● homeassistant_mail_check.service - Home Assistant Mail Count Retriever
Loaded: loaded (/etc/systemd/system/homeassistant_mail_check.service; enabled
Active: activating (auto-restart) (Result: exit-code) since Sat 2018-11-24 10
Process: 20670 ExecStart=/srv/homeassistant/bin/python3 /home/homeassistant/.h
Main PID: 20670 (code=exited, status=1/FAILURE)
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Main proc
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Unit ente
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Failed wi
lines 1-9/9 (END)...skipping...
● homeassistant_mail_check.service - Home Assistant Mail Count Retriever
Loaded: loaded (/etc/systemd/system/homeassistant_mail_check.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Sat 2018-11-24 10:34:20 EST; 114ms ago
Process: 20670 ExecStart=/srv/homeassistant/bin/python3 /home/homeassistant/.homeassistant/includes/mail.py (code=exited, status=1/FAILURE)
Main PID: 20670 (code=exited, status=1/FAILURE)
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Main process exited, code=exited, status=1/FAILURE
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Unit entered failed state.
Nov 24 10:34:20 hassbian systemd[1]: homeassistant_mail_check.service: Failed with result 'exit-code'.
Is the mail.py executable (I added this step in on GitHub to be more clear) using chmod +x /path/to/mail.py or sudo chmod +x /path/to/mail.py
The Service
The User= should be the user your Home Assistant installation runs under
The first part of ExecStart= should point to where your Home Assistant was installed with /bin/python3 after
The second part of ExecStart= should point to where you stored the mail.py. Your path may differ depending on where the Home Assistant configuration is stored
I recently noticed that the other information was updating while when the script ran but sometimes the checked date would not. I added a 5 second sleep before the script disconnects from the internal HASS MQTT.
I’m not sure if it was just disconnecting too quickly but it seems to be updating the date on my end.
I did try to get the states to persists through a reboot but I don’t think what I did solved it. It continues to show unknown for everything until the script runs the first time.
@skalavala and @Vasiley, my first attempt to package this all together was to have the python script to run by way of an automation triggering the defined script. It never updated the sensors when run that way.
Do you know off hand what is missing or what the issue could be running it that way as opposed to the system service? I’ll have to read up about debugging python to see if I can find out what’s going on. I’m a bit outside my skill set already
pi@hassbian:~ $ sudo systemctl status homeassistant_mail_check.service
● homeassistant_mail_check.service - Home Assistant Mail Count Retriever
Loaded: loaded (/etc/systemd/system/homeassistant_mail_check.service; enabled
Active: active (running) since Sat 2018-12-01 13:10:02 EST; 497ms ago
Main PID: 23094 (python3)
CGroup: /system.slice/homeassistant_mail_check.service
└─23094 /srv/homeassistant/bin/python3 /home/homeassistant/.homeassis
Dec 01 13:10:02 hassbian systemd[1]: Started Home Assistant Mail Count Retriever
lines 1-8/8 (END)...skipping...
● homeassistant_mail_check.service - Home Assistant Mail Count Retriever
Loaded: loaded (/etc/systemd/system/homeassistant_mail_check.service; enabled; vendor pres
Active: active (running) since Sat 2018-12-01 13:10:02 EST; 497ms ago
Main PID: 23094 (python3)
CGroup: /system.slice/homeassistant_mail_check.service
└─23094 /srv/homeassistant/bin/python3 /home/homeassistant/.homeassistant/includes
Dec 01 13:10:02 hassbian systemd[1]: Started Home Assistant Mail Count Retriever.
Looks like it’s running. Are you seeing the update time on the card change every 5 minutes from when the service was started? Running the script as a service doesn’t output the console messages to the systemd status log so you won’t see anything more than the started message there.
Dec-01-2018 01:42 PM USPS: Connected to MQTT Server successfully
Dec-01-2018 01:42 PM USPS: Logged into your email server successfully!
Dec-01-2018 01:42 PM USPS: Selecting folder 'Inbox'
Dec-01-2018 01:42 PM USPS: Found 2 mail and images in your email.
Dec-01-2018 01:42 PM USPS: Creating animated GIF out of 2 images.
Dec-01-2018 01:42 PM USPS: Cleaning up...
Dec-01-2018 01:42 PM USPS: Found '0' USPS packages out for delivery
Dec-01-2018 01:42 PM USPS: Found '0' USPS packages delivered
Dec-01-2018 01:42 PM USPS: Found '0' FedEx packages delivered
Dec-01-2018 01:42 PM USPS: Update Time 'Dec-01-2018 01:42 PM'
Dec-01-2018 01:42 PM USPS: Disconnected MQTT successfully. Will check your mail again in 300 seconds.
Here’s my output, also, it doesn’t recognize “!secret”:
(homeassistant) homeassistant@hassbian:/home/pi $ python3 /home/homeassistant/.homeassistant/includes/mail.py
Dec-01-2018 06:50 PM USPS: Connected to MQTT Server successfully
Dec-01-2018 06:50 PM USPS: Logged into your email server successfully!
Dec-01-2018 06:50 PM USPS: Selecting folder 'Inbox'
Dec-01-2018 06:50 PM USPS: Found 7 mail and images in your email.
Dec-01-2018 06:50 PM USPS: Creating animated GIF out of 7 images.
convert-im6.q16: unable to open image `/home/homeassistant/.homeassistant/www/mail_card/todays_mail.gif': Permission denied @ error/blob.c/OpenBlob/2701.
Dec-01-2018 06:50 PM USPS: Cleaning up...
Dec-01-2018 06:50 PM USPS: Found '0' USPS packages
Dec-01-2018 06:50 PM USPS: Found '0' FedEx packages
Dec-01-2018 06:50 PM USPS: Update Time 'Dec-01-2018 06:50 PM'
Dec-01-2018 06:50 PM USPS: Disconnected MQTT successfully. Will check your mail again in 300 seconds.
Status is now:
pi@hassbian:~ $ sudo systemctl status homeassistant_mail_check.service
● homeassistant_mail_check.service - Home Assistant Mail Count Retriever
Loaded: loaded (/etc/systemd/system/homeassistant_mail_check.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-12-01 18:50:46 EST; 3min 29s ago
Main PID: 9217 (python3)
CGroup: /system.slice/homeassistant_mail_check.service
└─9217 /srv/homeassistant/bin/python3 /home/homeassistant/.homeassistant/includes/mail.py
Dec 01 18:50:46 hassbian systemd[1]: Started Home Assistant Mail Count Retriever.
Dec 01 18:50:47 hassbian python3[9217]: convert-im6.q16: unable to open image `/home/homeassistant/.homeassistant/www/mail_card/todays_mail.gif': Permission denied @ error/blob.c/OpenBlob/2
lines 1-9/9 (END)
Secrets can only be used Home Assistant configuration yaml files. The mail.py is separate from Home Assistant and could be stored outside of your home assistant folder or even on a different machine. I think the mail.py would have to be converted to a custom component in order to pass secret configuration options to it. Outside of my know how right now.
The group called “Deliveries” in your screen shot. I used it to group the entities so they were all together as reference while building the “Mail Summary” card.
So the section below in the mail_package.yaml group section can be removed or you can hide it using the customize options in Home Assistant.