diff --git a/README.md b/README.md index 40a74e3..1219c75 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Retrieves USPS mail and package info from informed delivery emails via IMAP. Pub * https://www.awesome-automations.com/blog/usps/ * https://community.home-assistant.io/t/a-working-usps-component-solved-for-now/41012/14 +https://hub.docker.com/r/aneisch/informed-delivery-home-assistant ## Usage diff --git a/retrieve_mail.py b/retrieve_mail.py index 857789f..433b902 100644 --- a/retrieve_mail.py +++ b/retrieve_mail.py @@ -61,9 +61,8 @@ def get_mails(account): '(FROM "USPS" SUBJECT "Informed Delivery Daily Digest" SINCE "' + today + '")') if rv == 'OK': - - message_count = len(str(data[0]).split(" ")) - print_message('Found {} Informed Delivery messages'.format(message_count)) + message_count = len(str(data[0]).split(" ")) - 1 + print_message("Found {} Informed Delivery messages".format(message_count)) for num in data[0].split(): rv, data = account.fetch(num, '(RFC822)') @@ -75,7 +74,7 @@ def get_mails(account): if part.get('Content-Disposition') is None: continue if '_' in part.get_filename(): - print_message('Found an advertisement, skipping it!') + print_message("Found an advertisement, skipping it!") continue filepath = '/output/' + part.get_filename() @@ -85,7 +84,7 @@ def get_mails(account): image_count = image_count + 1 fp.close() - print_message ('Found {} mails and images in your email.'.format(image_count)) + print_message ("Found {} mails and images in your email".format(image_count)) if image_count > 0: all_images = "" @@ -94,7 +93,7 @@ def get_mails(account): all_images += image + " " print_message ("Creating animated GIF out of {} images.".format(image_count)) - os.system( GIF_MAKER_OPTIONS + all_images + + os.system( GIF_MAKER_OPTIONS + " " + all_images + '/output/' + GIF_FILE_NAME ) print_message ("Cleaning up...") @@ -102,7 +101,7 @@ def get_mails(account): os.remove(image) if (image_count == 0): - print_message("Found '{}' mails".format(image_count)) + print_message("Found {} mails".format(image_count)) return image_count @@ -124,7 +123,7 @@ def package_count(account): if rv == 'OK': count = len(data[0].split()) - print_message("Found '{}' packages".format(count)) + print_message("Found {} packages".format(count)) return count @@ -157,9 +156,6 @@ def on_log(mosq, obj, level, string): # Set event callbacks mqttc.on_connect = on_connect - # Uncomment below line to enable debug/console messages - # mqttc.on_log = on_log - # Connect to MQTT using the username/password set above mqttc.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD) mqttc.connect(MQTT_SERVER, MQTT_SERVER_PORT)