USPS Mail Camera

You need the following files:

components\usps.py
components\sensor\usps.py
components\camera\usps.py

The usps.py in the sensor folder should overwrite your existing file. You’ll also need to adjust your configuration.yaml to look like this:

usps:
    username: userhere
    password: password
    name: mailname (optional)
    interval: 10 (optional, sets delay in rotating through the images)

I did it that way on my first test run, but there isn’t necessarily a precedent for packaging in another file like that. I know the demo images are there, but they kinda serve a different purpose.

Since it is the cleaner solution i’ll probably give it a shot and can always switch back during the PR process if someone doesn’t like it.

One step after the other :wink:

Now I have the following error messages - all files are in the right folder and configuration.yaml adjusted!

2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component usps
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
component.setup, hass, processed_config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self  # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/usps.py", line 43, in setup
conf = config[DOMAIN]
KeyError: 'usps'
2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.usps. Setup failed for dependencies: usps
2017-07-25 22:32:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.usps: Could not setup all dependencies.

Thanks for your help!

Ok, lets figure out a few things… What version of HASS are you running and what version of python (looks like 3.4)? Did you have the usps component working before giving my changes a try?

  • I’m on HASS version 0.49.0
  • Python should be version 3.4, yes
  • The sensor (Standard usps component!) was working before and showed 3 packages on the way
  • I just started with your changes - never started with @aneisch’s changes

Am I missing any steps from @aneisch’s first post that I have to do? Or can I just implement your changes

You don’t need to do anything posted by @aneisch, I wrapped all his changes into a finished component. Can you post your yaml configuration? The new lines should go in the main configuration.yaml, not a sensor specific include file.

2 Likes

Does your new component also fix the pickle issue? I have been having to restart Hass a couple times as I am trying to get other components working. After restaring about 3 times I have to delete the usps.pickle file to get the usps component working again.

Unfortunately, no. The pickle issues need to be fixed in the underlying myusps library I believe.

Do I create a components folder under the .homeassistant directory?

I guess it’s too late at night!!

I still had it under the sensor section and not as its own component…

THANKS for the help - I appreciate the help and the awesome work on this component!

@Coolie1101 No need to make a new folder. These files need to go into your existing components folder.

@DanielGalle No problem, glad you got it figured out.

Where is the existing components folder?

EDIT:
For anyone else wondering, the folder is located in the following location.

/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components

Have a look here

I don’t understand what you are referring to, I know where the config directory is.

Are you referring to /packages/deps?

Ok, got it setup but, now getting the following error:

If you’ve pulled the latest files from my repo you also need to add the “nomail.jpg” file to your camera folder. That may be the cause of the error. Otherwise, please post a log.

2017-07-26 14:36:57 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform usps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 90, in wrapped
    return function(*args)
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 105, in get_packages
    raise UPSError('failed to find token or tid')
upsmychoice.UPSError: failed to find token or tid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 55, in setup_platform
    config.get(CONF_UPDATE_INTERVAL))])
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 68, in __init__
    self.update()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 84, in _update
    for package in upsmychoice.get_packages(self._session):
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 93, in wrapped
    return function(*args)
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 105, in get_packages
    raise UPSError('failed to find token or tid')
upsmychoice.UPSError: failed to find token or tid
2017-07-26 14:36:59 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform usps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 90, in wrapped
    return function(*args)
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 105, in get_packages
    raise UPSError('failed to find token or tid')
upsmychoice.UPSError: failed to find token or tid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 55, in setup_platform
    config.get(CONF_UPDATE_INTERVAL))])
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 68, in __init__
    self.update()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 84, in _update
    for package in upsmychoice.get_packages(self._session):
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 93, in wrapped
    return function(*args)
  File "/srv/homeassistant/lib/python3.4/site-packages/upsmychoice/__init__.py", line 105, in get_packages
    raise UPSError('failed to find token or tid')
upsmychoice.UPSError: failed to find token or tid
2017-07-26 14:36:59 ERROR (MainThread) [homeassistant.components.http] Failed to create HTTP server at port 8123: [Errno 98] error while attempting to bind on address ('0.0.0.0', 8123): address already in use
2017-07-26 14:37:00 ERROR (MainThread) [homeassistant.components.http] Failed to create HTTP server at port 8300: [Errno 98] error while attempting to bind on address ('192.168.200.210', 8300): address already in use

Completely broke HASS

Those errors are all related to the UPS component, not the USPS component. Did you have the USPS component setup and working before you attempted to test my new version?

Yes, USPS, UPS and FedEx were all setup and functioning prior.

HASS completely dead now.

Created a bunch more error’s for other components.