"""Constants for Mail and Packages.""" from __future__ import annotations from typing import Final from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.sensor import SensorDeviceClass, SensorEntityDescription from homeassistant.helpers.entity import EntityCategory from .entity import MailandPackagesBinarySensorEntityDescription DOMAIN = "mail_and_packages" DOMAIN_DATA = f"{DOMAIN}_data" VERSION = "0.5.15" ISSUE_URL = "http://github.com/moralmunky/Home-Assistant-Mail-And-Packages" PLATFORM = "sensor" PLATFORMS = ["binary_sensor", "camera", "sensor"] DATA = "data" COORDINATOR = "coordinator_mail" OVERLAY = ["overlay.png", "vignette.png", "white.png"] SERVICE_UPDATE_FILE_PATH = "update_file_path" CAMERA = "cameras" CONFIG_VER = 19 # Attributes ATTR_AMAZON_IMAGE = "amazon_image" ATTR_COUNT = "count" ATTR_CODE = "code" ATTR_GRID_IMAGE_NAME = "grid_image" ATTR_ORDER = "order" ATTR_TRACKING = "tracking" ATTR_TRACKING_NUM = "tracking_#" ATTR_IMAGE = "image" ATTR_IMAGE_PATH = "image_path" ATTR_SERVER = "server" ATTR_IMAGE_NAME = "image_name" ATTR_EMAIL = "email" ATTR_SUBJECT = "subject" ATTR_BODY = "body" ATTR_BODY_COUNT = "body_count" ATTR_PATTERN = "pattern" ATTR_USPS_MAIL = "usps_mail" ATTR_UPS_IMAGE = "ups_image" ATTR_WALMART_IMAGE = "walmart_image" ATTR_FEDEX_IMAGE = "fedex_image" ATTR_GENERIC_IMAGE = "generic_image" ATTR_USPS_IMAGE = "usps_image" ATTR_POST_DE_IMAGE = "post_de_image" # Configuration Properties CONF_ALLOW_EXTERNAL = "allow_external" CONF_CAMERA_NAME = "camera_name" CONF_CUSTOM_IMG = "custom_img" CONF_CUSTOM_IMG_FILE = "custom_img_file" CONF_AMAZON_CUSTOM_IMG = "amazon_custom_img" CONF_AMAZON_CUSTOM_IMG_FILE = "amazon_custom_img_file" CONF_UPS_CUSTOM_IMG = "ups_custom_img" CONF_UPS_CUSTOM_IMG_FILE = "ups_custom_img_file" CONF_WALMART_CUSTOM_IMG = "walmart_custom_img" CONF_WALMART_CUSTOM_IMG_FILE = "walmart_custom_img_file" CONF_FEDEX_CUSTOM_IMG = "fedex_custom_img" CONF_FEDEX_CUSTOM_IMG_FILE = "fedex_custom_img_file" CONF_GENERIC_CUSTOM_IMG = "generic_custom_img" CONF_GENERIC_CUSTOM_IMG_FILE = "generic_custom_img_file" CONF_POST_DE_CUSTOM_IMG = "post_de_custom_img" CONF_POST_DE_CUSTOM_IMG_FILE = "post_de_custom_img_file" CONF_STORAGE = "storage" CONF_FOLDER = "folder" CONF_PATH = "image_path" CONF_DURATION = "gif_duration" CONF_SCAN_INTERVAL = "scan_interval" CONF_IMAGE_SECURITY = "image_security" CONF_IMAP_TIMEOUT = "imap_timeout" CONF_GENERATE_GRID = "generate_grid" CONF_GENERATE_MP4 = "generate_mp4" CONF_AMAZON_FWDS = "amazon_fwds" CONF_AMAZON_DAYS = "amazon_days" CONF_VERIFY_SSL = "verify_ssl" CONF_IMAP_SECURITY = "imap_security" CONF_AMAZON_DOMAIN = "amazon_domain" CONF_ALLOW_FORWARDED_EMAILS = "allow_forwarded_emails" CONF_FORWARDED_EMAILS = "forwarded_emails" CONF_FORWARDING_HEADER = "forwarding_header" CONF_CUSTOM_DAYS = "custom_days" CONF_USPS_PLACEHOLDER = "usps_placeholder" # Defaults DEFAULT_CAMERA_NAME = "Mail USPS Camera" DEFAULT_NAME = "Mail And Packages" DEFAULT_PORT = "993" DEFAULT_FOLDER = "INBOX" DEFAULT_PATH = "custom_components/mail_and_packages/images/" DEFAULT_IMAGE_SECURITY = True DEFAULT_IMAP_TIMEOUT = 60 DEFAULT_GIF_DURATION = 5 DEFAULT_SCAN_INTERVAL = 30 DEFAULT_CUSTOM_DAYS = 3 MAX_TRACKING_AGE_DAYS = 14 DEFAULT_GIF_FILE_NAME = "mail_today.gif" DEFAULT_AMAZON_FWDS = "(none)" DEFAULT_ALLOW_EXTERNAL = False DEFAULT_CUSTOM_IMG = False DEFAULT_CUSTOM_IMG_FILE = "custom_components/mail_and_packages/mail_none.gif" DEFAULT_AMAZON_CUSTOM_IMG = False DEFAULT_AMAZON_CUSTOM_IMG_FILE = ( "custom_components/mail_and_packages/no_deliveries_amazon.jpg" ) DEFAULT_UPS_CUSTOM_IMG = False DEFAULT_UPS_CUSTOM_IMG_FILE = ( "custom_components/mail_and_packages/no_deliveries_ups.jpg" ) DEFAULT_WALMART_CUSTOM_IMG = False DEFAULT_WALMART_CUSTOM_IMG_FILE = ( "custom_components/mail_and_packages/no_deliveries_walmart.jpg" ) DEFAULT_FEDEX_CUSTOM_IMG = False DEFAULT_FEDEX_CUSTOM_IMG_FILE = ( "custom_components/mail_and_packages/no_deliveries_fedex.jpg" ) DEFAULT_GENERIC_CUSTOM_IMG = False DEFAULT_GENERIC_CUSTOM_IMG_FILE = ( "custom_components/mail_and_packages/no_deliveries_generic.jpg" ) DEFAULT_POST_DE_CUSTOM_IMG = False DEFAULT_POST_DE_CUSTOM_IMG_FILE = "custom_components/mail_and_packages/mail_none.gif" DEFAULT_AMAZON_DAYS = 3 DEFAULT_AMAZON_DOMAIN = "amazon.com" DEFAULT_STORAGE = "custom_components/mail_and_packages/images/" DEFAULT_ALLOW_FORWARDED_EMAILS = False DEFAULT_FORWARDED_EMAILS = "(none)" DEFAULT_FORWARDING_HEADER = "(none)" DEFAULT_USPS_PLACEHOLDER = True # Amazon AMAZON_DOMAINS = [ "amazon.com", "amazon.ca", "amazon.co.uk", "amazon.in", "amazon.de", "amazon.it", "amazon.com.au", "amazon.pl", "amazon.es", "amazon.fr", "amazon.ae", "amazon.nl", ] AMAZON_DELIVERED_SUBJECT = [ "Delivered: ", "Your Amazon order has arrived!", "Consegna effettuata:", "Dostarczono:", "Geliefert:", "Livré", "Entregado:", "Bezorgd:", "Livraison : Votre", "Zugestellt:", ] AMAZON_SHIPMENT_TRACKING = [ "auto-confirm", "shipment-tracking", "order-update", "conferma-spedizione", "confirmar-envio", "versandbestaetigung", "confirmation-commande", "verzending-volgen", "update-bestelling", ] AMAZON_SHIPMENT_SUBJECT = [ "Shipped:", "Enviado:", "Out for delivery:", "Spedito:", ] AMAZON_ORDERED_SUBJECT = ["Ordered:", "Pedido efetuado:"] AMAZON_EMAIL = [ "order-update@", "update-bestelling@", "versandbestaetigung@", "verzending-volgen@", "auto-bevestiging@", ] AMAZON_PACKAGES = "amazon_packages" AMAZON_ORDER = "amazon_order" AMAZON_DELIVERED = "amazon_delivered" AMAZON_IMG_LIST = [ "us-prod-temp.s3.amazonaws.com", "gb-prod-temp.s3.eu-west-1.amazonaws.com", ] AMAZON_IMG_PATTERN = ( "(https://)([\\w_-]+(?:(?:\\.[\\w_-]+)+))([\\w.,@?^=%&:/~+#-;]*[\\w@?^=%&/~+#-;])?" ) AMAZON_HUB = "amazon_hub" AMAZON_HUB_CODE = "amazon_hub_code" AMAZON_HUB_EMAIL = [ "thehub@amazon.com", "order-update@amazon.com", "amazonlockers@amazon.com", "versandbestaetigung@amazon.de", ] AMAZON_HUB_SUBJECT = ["ready for pickup from Amazon Hub Locker"] AMAZON_HUB_SUBJECT_SEARCH = "(a package to pick up)(.*)(\\d{6})" AMAZON_HUB_BODY = "(Your pickup code is )(\\d{6})" AMAZON_TIME_PATTERN = [ "will arrive:", "estimated delivery date is:", "guaranteed delivery date is:", "Arriving:", "Arriverà:", "arriving:", "Arriving ", "Dostawa:", "Entrega:", "A chegar:", "Arrivée :", "Chega ", "Verwachte bezorgdatum:", "Votre date de livraison prévue est :", "In arrivo", ] AMAZON_TIME_PATTERN_END = [ "Previously expected:", "This contains", "Track your", "Per tracciare il tuo pacco", "View or manage order", "Acompanhar", "Seguimiento", "Verfolge deine(n) Artikel", "Lieferung verfolgen", "Ihr Paket verfolgen", "Suivre", "Volg je pakket", "Je pakket volgen", ] AMAZON_TIME_PATTERN_REGEX = [ "Arriving (\\w+ \\d+) - (\\w+ \\d+)", "Arriving (\\w+ \\d+)", "Arriving (\\w+ ?\\d*)", "Arriving (\\w+)", "Zustellung (\\w+ \\d+) - (\\w+ \\d+)", "Zustellung (\\w+ \\d+)", "Zustellung (\\w+ \\d*)", "Arriverà (\\w+ \\d+) - (\\w+ \\d+)", "Arriverà (\\w+ \\d+)", "Arriverà (\\w+ \\d*)", "Arrivée (\\w+ \\d+) - (\\w+ \\d+)", "Arrivée (\\w+ \\d+)", "Arrivée (\\w+ \\d*)", "Chega ((\\w+(-\\w+)?))", "Wordt bezorgd op (\\w+ \\d+ \\w+)", "Wordt bezorgd op (\\w+ \\d+)", "Wordt (\\w+) bezorgd", "In arrivo (\\w+ \\d+) - (\\w+ \\d+)", "In arrivo (\\w+ \\d+)", "In arrivo (\\w+ \\d*)", "In arrivo (\\w+)", ] AMAZON_EXCEPTION_SUBJECT = "Delivery update:" AMAZON_EXCEPTION_BODY = "running late" AMAZON_EXCEPTION = "amazon_exception" AMAZON_EXCEPTION_ORDER = "amazon_exception_order" AMAZON_PATTERN = "[0-9]{3}-[0-9]{7}-[0-9]{7}" AMAZON_LANGS = [ "it_IT", "it_IT.UTF-8", "pl_PL", "pl_PL.UTF-8", "de_DE", "de_DE.UTF-8", "es_ES", "es_ES.UTF-8", "pt_PT", "pt_PT.UTF-8", "pt_BR", "pt_BR.UTF-8", "fr_CA", "fr_CA.UTF-8", "", ] AMAZON_OTP = "amazon_otp" AMAZON_OTP_CODE = "amazon_otp_code" AMAZON_OTP_REGEX = "(\n)(\\d{6})(\n)" AMAZON_OTP_SUBJECT = "A one-time password is required for your Amazon delivery" AMAZON_DELIEVERED_BY_OTHERS_SEARCH_TEXT = ["AMAZON"] # Sensor Data SENSOR_DATA = { # USPS "usps_delivered": { "email": ["auto-reply@usps.com", "auto-reply@tracking.usps.com"], "subject": ["Item Delivered"], }, "usps_delivering": { "email": ["auto-reply@usps.com", "auto-reply@tracking.usps.com"], "subject": ["Expected Delivery on", "Out for Delivery"], "body": ["Your item is out for delivery"], }, "usps_exception": { "email": ["auto-reply@usps.com", "auto-reply@tracking.usps.com"], "subject": ["Delivery Exception"], }, "usps_packages": { "email": ["auto-reply@usps.com", "auto-reply@tracking.usps.com"], "subject": ["Expected Delivery by"], }, "usps_tracking": {"pattern": ["9[2345]\\d{15,26}"]}, "usps_mail": { "email": [ "USPSInformedDelivery@usps.gov", "USPSInformeddelivery@email.informeddelivery.usps.com", "USPSInformeddelivery@informeddelivery.usps.com", "USPS Informed Delivery", ], "subject": ["Your Daily Digest"], }, "usps_mail_delivered": { "email": [ "USPSInformedDelivery@usps.gov", "USPSInformeddelivery@email.informeddelivery.usps.com", "USPSInformeddelivery@informeddelivery.usps.com", "USPS Informed Delivery", ], "subject": ["Your Mail Was Delivered"], }, # UPS "ups_delivered": { "email": ["mcinfo@ups.com", "pkginfo@ups.com"], "subject": [ "Your UPS Package was delivered", "Your UPS Packages were delivered", "Your UPS Parcel was delivered", "Your UPS Parcels were delivered", "Votre colis UPS a été livré", "Paket wurde zugestellt", ], }, "ups_delivering": { "email": ["mcinfo@ups.com", "pkginfo@ups.com"], "subject": [ "UPS Update: Package Scheduled for Delivery Today", "UPS Update: Follow Your Delivery on a Live Map", "UPS Pre-Arrival: Your Driver is Arriving Soon! Follow on a Live Map", "UPS Update: Parcel Scheduled for Delivery Today", "Mise à jour UPS : Livraison du colis prévue demain", "Mise à jour UPS : Livraison du colis prévue aujourd'hui", ], }, "ups_exception": { "email": ["mcinfo@ups.com"], "subject": ["UPS Update: New Scheduled Delivery Date"], }, "ups_packages": { "email": ["mcinfo@ups.com", "pkginfo@ups.com"], "subject": ["UPS Ship Notification"], }, "ups_tracking": {"pattern": ["1Z?[0-9A-Z]{16}"]}, # FedEx "fedex_delivered": { "email": [ "TrackingUpdates@fedex.com", "fedexcanada@fedex.com", "noreply@fedex.com", ], "subject": [ "Your package has been delivered", "Your packages have been delivered", "Your shipment was delivered", ], }, "fedex_delivering": { "email": [ "TrackingUpdates@fedex.com", "fedexcanada@fedex.com", "noreply@fedex.com", ], "subject": [ "Delivery scheduled for today", "Your package is scheduled for delivery today", "Your package is now out for delivery", "Your shipment is out for delivery today", "out for delivery today", "Ihre Sendung wird voraussichtlich heute zugestellt", ], }, "fedex_packages": { "email": [ "TrackingUpdates@fedex.com", "fedexcanada@fedex.com", "noreply@fedex.com", ], "subject": ["Your shipment is on the way"], }, "fedex_exception": { "email": [ "TrackingUpdates@fedex.com", "fedexcanada@fedex.com", "noreply@fedex.com", ], # Subject confirmed against a real FedEx delivery-exception # notification (From: trackingupdates@fedex.com, Subject: # "FedEx Delivery Exception"). IMAP SUBJECT search is a # case-insensitive substring match, mirroring usps_exception's # "Delivery Exception" fragment. "subject": ["FedEx Delivery Exception"], }, "fedex_tracking": {"pattern": ["\\d{12,20}"]}, # Canada Post "capost_delivered": { "email": [ "donotreply@canadapost.postescanada.ca", "donotreply-nepasrepondre@notifications.canadapost-postescanada.ca", ], "subject": [ "Delivery Notification", ], }, "capost_delivering": { "email": [ "donotreply-nepasrepondre@notifications.canadapost-postescanada.ca", ], "subject": [ "Your parcel is out for delivery", ], }, "capost_packages": {}, "capost_tracking": {"pattern": ["\\d{16}"]}, "capost_mail": { "email": ["donotreply-nepasrepondre@communications.canadapost-postescanada.ca"], "subject": ["You have mail on the way"], "body": ["\\sYou have (\\d) piece|pieces of mail\\s"], "body_count": True, }, # DHL "dhl_delivered": { "email": [ "donotreply_odd@dhl.com", "NoReply.ODD@dhl.com", "noreply@dhl.de", "no-reply@dhl.de", "pl.no.reply@dhl.com", "support@dhl.com", "noreply@dhlecommerce.nl", "noreply@dhl.nl", ], "subject": [ "DHL On Demand Delivery", "Powiadomienie o przesyłce", "wurde zugestellt", "DHL Shipment Notification", "liegt am gewünschten Ablageort", "Ihre Sendung liegt im Briefkasten", "Zustellung an Ablageort", "Ablageort", "Sendung zugestellt", "Paket wurde zugestellt", "Ihre AliExpress Sendung liegt im Briefkasten", "succesvol bezorgd", "is bezorgd", ], "body": [ "has been delivered", "została doręczona", "ist angekommen", 'Notification for shipment event group "Delivered', " - Delivered - ", "liegt im Briefkasten", "zugestellt", "Zustellung", "wurde zugestellt", "succesvol bezorgd", "is bezorgd", "pakket is afgeleverd", ], }, "dhl_delivering": { "email": [ "donotreply_odd@dhl.com", "NoReply.ODD@dhl.com", "noreply@dhl.de", "no-reply@dhl.de", "pl.no.reply@dhl.com", "support@dhl.com", "noreply@dhlecommerce.nl", "noreply@dhl.nl", ], "subject": [ "DHL On Demand Delivery", "Paket kommt heute", "kommt heute", "wird gleich zugestellt", "Powiadomienie o przesyłce", "DHL Shipment Notification", "ist unterwegs", "Jetzt Live verfolgen", "vanavond voor de deur", "vandaag voor de deur", "pakket onderweg", "bezorging vandaag", "staan vandaag voor de deur", "staan vanavond voor de deur", "komen we bij je langs", ], "body": [ "scheduled for delivery TODAY", "zostanie dziś do Państwa doręczona", "wird Ihnen heute", "wird Ihnen voraussichtlich", "heute zwischen", " - Shipment is out with courier for delivery - ", "Shipment is scheduled for delivery", "voraussichtlich innerhalb", "staan vandaag voor de deur", "staan vanavond voor de deur", "wordt vandaag bezorgd", "bezorger onderweg", "komen we bij je langs", ], }, "dhl_packages": {}, "dhl_tracking": { "pattern": [ "(?:JJD\\d{18}|JVGL\\d{20}|MDP[A-Z0-9]{5,15}|00\\d{18}|(?