Mail and Packages: Custom component for UPS, FEDEX, and USPS

Nope, just as I posted /config.....

Inside the container /config is where your configuration lives and the www directory.

OK thanks. I do everything physically by telnetting into the base server so do not see those config paths. I donā€™t go into the docker session and work. By the way, I may be missing something but is the documentation for this component missing some steps or is HAVC installing it? I noticed a requirement mentioned for ImageMagick but never saw it referenced in the GIT repository.

ImageMagick hasnā€™t been used in quite some time. Everything is installed automagicly.

OK thanks. If I donā€™t have a camera.mail_usps entity am I missing something?

Nope, thatā€™s more advanced configuration, hereā€™s some examples how to set that up and some automations.

Oh crap, Iā€™m in trouble now. :smile: The camera functionality seems to point to a single gif. In my case the current file in the mail_and_packages folder is called 20647c24-63ff-426e-9066-bc7b900596e2.gif

This makes me think itā€™s going to change everyday.

Iā€™m updating that page to include an example automation for that.

Thanks. Sounds like there is a way to turn that off as well no? Is that sometihng to do with DEFAULT_IMAGE_SECURITY to change it to False or something in the const.py file?

No just toggle it off in the options :stuck_out_tongue:
Integrations > Mail and Packages > Options button
Itā€™ll be on the 2nd screen.

I will check that in a bit. Didnā€™t remember seeing that. For some reason my Alexa integration stopped working so reverted my virtual to before I installed this component to make sure.

All good, was my NGINX server wasnā€™t running.

There seems to be many questions that I thought we got to in the wiki or the markdown documents. Please review these areas and suggest places where things are either lacking or could be defined in a better manner in the repository. Particularly helpful to suggest improvements now since you are new and going through all the steps.

1 Like

Sorry if this is a bit off topic. Iā€™ve been looking at implementing this integration and the related card in my setup. I use HACS where I can so I can more easily keep up on updates. I can add the integration as a custom repository, but the card says itā€™s not compliant.

Any suggestions? I assume there is something in the git repo that HACS just does not like.

OK so cool stuff. Got this working and getting the images. I do see this in my logs at times, anything to be concerned:

2020-07-10 08:28:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.mail_updated fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    self.update  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 316, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 176, in update
    account = login(self._host, self._port, self._user, self._pwd)
  File "/config/custom_components/mail_and_packages/sensor.py", line 326, in login
    account = imaplib.IMAP4_SSL(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1288, in __init__
    IMAP4.__init__(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 198, in __init__
    self.open(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1301, in open
    IMAP4.open(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 299, in open
    self.sock = self._create_socket()
  File "/usr/local/lib/python3.7/imaplib.py", line 1291, in _create_socket
    sock = IMAP4._create_socket(self)
  File "/usr/local/lib/python3.7/imaplib.py", line 289, in _create_socket
    return socket.create_connection((host, self.port))
  File "/usr/local/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
2020-07-10 08:28:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.mail_usps_mail fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    self.update  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 316, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 176, in update
    account = login(self._host, self._port, self._user, self._pwd)
  File "/config/custom_components/mail_and_packages/sensor.py", line 326, in login
    account = imaplib.IMAP4_SSL(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1288, in __init__
    IMAP4.__init__(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 198, in __init__
    self.open(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1301, in open
    IMAP4.open(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 299, in open
    self.sock = self._create_socket()
  File "/usr/local/lib/python3.7/imaplib.py", line 1291, in _create_socket
    sock = IMAP4._create_socket(self)
  File "/usr/local/lib/python3.7/imaplib.py", line 289, in _create_socket
    return socket.create_connection((host, self.port))
  File "/usr/local/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
2020-07-10 08:28:26 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.mail_usps_delivered fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    self.update  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 316, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/mail_and_packages/sensor.py", line 176, in update
    account = login(self._host, self._port, self._user, self._pwd)
  File "/config/custom_components/mail_and_packages/sensor.py", line 326, in login
    account = imaplib.IMAP4_SSL(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1288, in __init__
    IMAP4.__init__(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 198, in __init__
    self.open(host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 1301, in open
    IMAP4.open(self, host, port)
  File "/usr/local/lib/python3.7/imaplib.py", line 299, in open
    self.sock = self._create_socket()
  File "/usr/local/lib/python3.7/imaplib.py", line 1291, in _create_socket
    sock = IMAP4._create_socket(self)
  File "/usr/local/lib/python3.7/imaplib.py", line 289, in _create_socket
    return socket.create_connection((host, self.port))
  File "/usr/local/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

Also besides the above, what triggers seeing getting a package from the USPS? So hereā€™s what I see today:

And thatā€™s cool, I am getting three pieces of mail though the mail person never showed again. But at the bottom of the email itā€™s reading I have a package that was supposed to come today if this temp mail person didnā€™t suck.

image

Using one of the standard card examples:

cards:
  - aspect_ratio: 50%
    camera_view: live
    entity: camera.mail_usps
    name: Mail
    show_name: false
    show_state: false
    type: picture-entity
  - entities:
      - entity: sensor.mail_usps_mail
        name: USPS Mail
      - entity: sensor.mail_usps_packages
        name: USPS Packages
      - entity: sensor.fedex_packages
        name: FedEx Packages
      - sensor.mail_ups_packages
      - sensor.mail_packages_in_transit
      - sensor.mail_packages_delivered
      - entity: sensor.mail_updated
    state_filter:
      - operator: '>'
        value: '0'
    type: entity-filter
type: vertical-stack

State of sensor.mail_usps_delivering is 0.

Looking at the const.py it looks like the expectation is that package notices from the USPS would come from another place? i do not get that unless I have to turn something additional on but looks like they are all in the one email.

Edit: Do I have to enable this which was unchecked maybe? Any others?

image

I would enable all of them to get the ā€œbestā€ experience. The email that sends out the mail isnā€™t what you need, you need the package emails.

These are errors are from not being able to connect to the mail server, either the host name or port is wrong.

Please see the wiki for configuration requirements.

It canā€™t be. See my post above. Iā€™m literally getting mail and mail counts.

Double checked socket.gaierror: [Errno -3] Try again is a DNS failure.

I just started getting this error now as well. Nothingā€™s changed on my end other than a reboot of HASS.

Are you using Supervised/Home Assistant OS?