USPS Mail Camera

  • 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.

Quick note @Coolie1101: You might want to try running sudo netstat -lptn to see what’s actually running on the ports that HASS is trying to use.

Thanks.
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN 434/mosquitto
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1209/mysqld
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1354/smbd
tcp 0 0 192.168.200.210:8300 0.0.0.0:* LISTEN 795/python3
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 796/sshd
tcp 0 0 192.168.200.210:1400 0.0.0.0:* LISTEN 795/python3
tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN 795/python3
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 434/mosquitto
tcp 0 0 0.0.0.0:8989 0.0.0.0:* LISTEN 795/python3
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1354/smbd
tcp6 0 0 :::139 :::* LISTEN 1354/smbd
tcp6 0 0 :::22 :::* LISTEN 796/sshd
tcp6 0 0 :::1883 :::* LISTEN 434/mosquitto
tcp6 0 0 :::445 :::* LISTEN 1354/smbd

Great. In the future, you can use 3x grave symbols at the start of the text, and again at the end to create a block of text without having weird formatting things happen to it.

tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN 795/python3

So, I’m willing to bet that the python3 instance you see there, is HASS in a stuck state, and it didn’t fully shut down or something of the sort. I use hassctl to handle my restarts hassctl restart or hassctl kill vs. other methods.

You might want to also look at htop - install it via sudo apt-get install htop

Run it via sudo htop

Then hit F5 for tree view, F4 to filter and type either the PID 795, or the process name python3. You can hit spacebar once you have it highlighted to lock focus on it.

You can kill it with F9 and enter.

Noted, all added to my QuickNotes, thanks.