def update(self, **kwargs): """Fetch the latest info from USPS.""" import myusps self.packages = myusps.get_packages(self.session) self.mail = myusps.get_mail(self.session, now().date()) self.attribution = myusps.ATTRIBUTION _LOGGER.debug("Mail, request date: %s, list: %s", now().date(), self.mail) _LOGGER.debug("Package list: %s", self.packages)
def update(self): """Update device state.""" import myusps self._state = len(myusps.get_mail(self._session))
slack_text = (f"Tracking Number: {tracking_number}\n" f"Primary Status: {primary_status}\n" f"Secondary Status: {secondary_status}\n" f"Delivery Date: {delivery_date}\n") slack_data = {"text": slack_text} slack_post(webhook_url, slack_data) #No Packages set for delivery today or after today's date else: print("No Packages in the queue for delivery!") slack_text = ("No USPS Package Items Today!") slack_data = {"text": slack_text} slack_post(webhook_url, slack_data) # Get mail delivered today mail = myusps.get_mail(session, datetime.datetime.now().date()) if len(mail) == 0: print("You have no mail today") #Post to pushbullet if enabled if pushbullet_enabled == 1: push = pb.push_note("MyUSPS", "No USPS Mail Items Today!") #post to slack slack_text = ("No USPS Mail Items Today!") slack_data = {"text": slack_text} slack_post(webhook_url, slack_data) else: #Print number of mail items to console print(f"Number of Mail Items: {len(mail)}") mail_num = (f"Number of USPS Mail Items Today: {len(mail)}")