New USPS sensor

Same as the other folks, did you

  1. Opt in to USPS My Choice
  2. Have at least one package on your Dashboard

Hello happyleaves.

I now have a package listed in MyUSPS so I restarted HASS. Got this error:

17-01-18 07:38:01 homeassistant.components.sensor: Error while setting up platform usps
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 151, in _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.5/asyncio/futures.py", line 379, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 297, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 292, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/usps.py", line 51, in setup_platform
    add_devices([USPSSensor(session, config.get(CONF_UPDATE_INTERVAL))])
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/usps.py", line 65, in __init__
    self.update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/util/__init__.py", line 296, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/usps.py", line 81, in _update
    for package in myusps.get_packages(self._session):
  File "/home/jeff/.homeassistant/deps/myusps/__init__.py", line 98, in wrapped
    return function(*args)
  File "/home/jeff/.homeassistant/deps/myusps/__init__.py", line 127, in get_packages
    'shipped_from': row.xpath(SHIPPED_FROM_XPATH)[1].text.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

Again, thanks for your contributions and help.

I do have 5 items listed on my dashboard. Any troubleshooting ideas ?

Seems like it is just having trouble finding the “shipped from” location information. The best thing to do would be to log in to your Dashboard, view the source, copy it and delete all personal info, and send it to me in a PM. The problem is I can’t reproduce it on my side without that.

In my case I no longer have any undelivered packages but I do show 6 delivered packages. Yesterday when I had the original problem I had a combo of delivered and undelivered packages.

I am having the same error

File “/home/pi/.homeassistant/deps/myusps/init.py”, line 127, in get_packages
‘shipped_from’: row.xpath(SHIPPED_FROM_XPATH)[1].text.strip()
AttributeError: ‘NoneType’ object has no attribute ‘strip’

and I think it has something to with in myusps that field is empty.

Ok, that helps. You can confirm that the shipped from field is empty?

Yes it is.

https://github.com/home-assistant/home-assistant/pull/5451 will address these issues (I hope!)

awesome. I hope it works too. I was really excited about this one when I saw it in the release. I just hope it gets released sooner rather than later. I don’t wanna have to order some more stuff once its released to test it out. lol

HA is on a two week release cycle. So you’ll either have to wait another week or so, or pip install myusps==1.0.3 in your Home Assistant virtual environment. May also have to bump the version number in the usps component.

@happyleaves – I’m still having issues as of 0.37.1. Any idea? Thanks!

https://github.com/home-assistant/home-assistant/issues/5739

I am on 0.38 with 1.0.2 myusps installed and getting this error. My login info is correct.

Feb 12 09:48:43 ha-pi hass[1195]: INFO:homeassistant.loader:Loaded sensor.usps from homeassistant.components.sensor.usps
Feb 12 09:48:43 ha-pi hass[1195]: INFO:homeassistant.components.sensor:Setting up sensor.usps
Feb 12 09:48:45 ha-pi hass[1195]: ERROR:homeassistant.components.sensor:Error while setting up platform usps
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 98, in wrapped
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 108, in get_profile
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 62, in _require_elem
Feb 12 09:48:45 ha-pi hass[1195]: myusps.USPSError: Not logged in
Feb 12 09:48:45 ha-pi hass[1195]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 54, in setup_platform
Feb 12 09:48:45 ha-pi hass[1195]: File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 65, in __init__
Feb 12 09:48:45 ha-pi hass[1195]: self._profile = myusps.get_profile(session)
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 101, in wrapped
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 108, in get_profile
Feb 12 09:48:45 ha-pi hass[1195]: File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 62, in _require_elem
Feb 12 09:48:45 ha-pi hass[1195]: myusps.USPSError: Not logged in

Its an issue with the myusps module. Fix will be coming, but in the meantime you probably can just disable that sensor.

Is there a bug ID or something that explains the issue?

USPS basically changed their login a bit.

If you pip install myusps==1.0.3 you can get the fix now.

It will also be in the 0.38.2 hotfix.

1 Like

I had to sudo pip3 install myusps==1.0.3 for the command to function properly

Hate to hijack this thread, but when I attempt to install myups 1.0.3 i receive the following error on my Windows box…

Installing collected packages: lxml, python-dateutil, requests, myusps
Running setup.py install for lxml … error
Complete output from command c:\users\homeassistant\appdata\local\programs\python\python36-32\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\HOMEAS~1\AppData\Local\Temp\pip-build-g4_f8tyz\lxml\setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record C:\Users\HOMEAS~1\AppData\Local\Temp\pip-5dibi6qf-record\install-record.txt --single-version-externally-managed --compile:
Building lxml version 3.7.1.
Building without Cython.
ERROR: b"‘xslt-config’ is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
running install
running build
running build_py
creating build
creating build\lib.win32-3.6
creating build\lib.win32-3.6\lxml
copying src\lxml\builder.py -> build\lib.win32-3.6\lxml
copying src\lxml\cssselect.py -> build\lib.win32-3.6\lxml
copying src\lxml\doctestcompare.py -> build\lib.win32-3.6\lxml
copying src\lxml\ElementInclude.py -> build\lib.win32-3.6\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win32-3.6\lxml
copying src\lxml\sax.py -> build\lib.win32-3.6\lxml
copying src\lxml\usedoctest.py -> build\lib.win32-3.6\lxml
copying src\lxml\_elementpath.py -> build\lib.win32-3.6\lxml
copying src\lxml\__init__.py -> build\lib.win32-3.6\lxml
creating build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win32-3.6\lxml\includes
creating build\lib.win32-3.6\lxml\html
copying src\lxml\html\builder.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\clean.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\defs.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\diff.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win32-3.6\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win32-3.6\lxml\html
creating build\lib.win32-3.6\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win32-3.6\lxml\isoschematron
copying src\lxml\lxml.etree.h -> build\lib.win32-3.6\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win32-3.6\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\etreepublic.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\htmlparser.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\relaxng.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\schematron.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\tree.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xmlerror.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xmlparser.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xmlschema.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xpath.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win32-3.6\lxml\includes
copying src\lxml\includes\lxml-version.h -> build\lib.win32-3.6\lxml\includes
creating build\lib.win32-3.6\lxml\isoschematron\resources
creating build\lib.win32-3.6\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win32-3.6\lxml\isoschematron\resources\rng
creating build\lib.win32-3.6\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl
creating build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win32-3.6\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build\temp.win32-3.6
creating build\temp.win32-3.6\Release
creating build\temp.win32-3.6\Release\src
creating build\temp.win32-3.6\Release\src\lxml
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc\lxml\includes -Ic:\users\homeassistant\appdata\local\programs\python\python36-32\include -Ic:\users\homeassistant\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win32-3.6\Release\src\lxml\lxml.etree.obj -w
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
src\lxml\includes\etree_defs.h(14): fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
creating Users
creating Users\HOMEAS~1
creating Users\HOMEAS~1\AppData
creating Users\HOMEAS~1\AppData\Local
creating Users\HOMEAS~1\AppData\Local\Temp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/libxml2 "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcC:\Users\HOMEAS~1\AppData\Local\Temp\xmlXPathInittqrd21qw.c /FoUsers\HOMEAS~1\AppData\Local\Temp\xmlXPathInittqrd21qw.obj
xmlXPathInittqrd21qw.c
C:\Users\HOMEAS~1\AppData\Local\Temp\xmlXPathInittqrd21qw.c(1): fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

----------------------------------------

Command “c:\users\homeassistant\appdata\local\programs\python\python36-32\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\HOMEAS~1\AppData\Local\Temp\pip-build-g4_f8tyz\lxml\setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record C:\Users\HOMEAS~1\AppData\Local\Temp\pip-5dibi6qf-record\install-record.txt --single-version-externally-managed --compile” failed with error code 1 in C:\Users\HOMEAS~1\AppData\Local\Temp\pip-build-g4_f8tyz\lxml\

nevermind, I installed the latest version of lxml and then installed myups 1.0.3 without dependencies…