2017-05-22 08:34:43 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform usps
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 148, in wrapped
return function(*args)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 158, in get_profile
profile = _require_elem(session.get(PROFILE_URL), PROFILE_TAG, PROFILE_ATTRS)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 74, in _require_elem
raise USPSError('Not logged in')
myusps.USPSError: Not logged in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 155, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
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/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 54, in setup_platform
config.get(CONF_UPDATE_INTERVAL))])
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 65, in __init__
self._profile = myusps.get_profile(session)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 151, in wrapped
return function(*args)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 161, in get_profile
data[row[0].text.strip().lower().replace(' ', '_')] = row[1].text.strip()
IndexError: string index out of range
Thanks, I’ll consider doing this. The template is actually from @happyleaves Home Assistant repo, I just stripped out the UPS config as I do not have this setup and implemented it.
I do have this automation setup as well which sends a push notification to my mobile when packages are delivered.
Man, I really thought this change was added to 0.45. I guess I was a bit too late!
You’re right, there is a breaking change in the entity naming. It is now {conf_name}_packages for packages and {conf_name}_mail for informed delivery mail.
@J-CMartin – That didn’t work for me on 0.45.1 with the All-in-One installer. I guess I’m on hold unless @happyleaves has another workaround idea. Hopefully the PR gets merged in for 0.46.
USPS didn’t work for me in 46.0 either. I deleted the pickle file and this is the error I get in the logs:
2017-06-04 09:21:52 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/tasks.py”, line 241, in _step
result = coro.throw(exc)
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 368, in async_process_entity
new_entity, self, update_before_add=update_before_add
File “/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py”, line 198, in async_add_entity
yield from self.hass.async_add_job(entity.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 361, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 296, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 274, 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 124, in update
self._state = len(myusps.get_mail(self._session))
File “/usr/local/lib/python3.5/dist-packages/myusps/init.py”, line 155, in wrapped
return function(*args)
File “/usr/local/lib/python3.5/dist-packages/myusps/init.py”, line 205, in get_mail
container = _require_elem(response, INFORMED_DELIVERY_TAG, INFORMED_DELIVERY_ATTRS)
File “/usr/local/lib/python3.5/dist-packages/myusps/init.py”, line 84, in _require_elem
raise ValueError(‘No element found’)
ValueError: No element found
@J-CMartin@happyleaves – If I delete the usps_cookies.pickle file and restart Home Assistant I can at least get the Informed Delivery for Mail to appear, however, the USPS packages still do not appear.
Once I restart Home Assistant a second time the Informed Delivery disappears and requires me to re-delete the usps_cookies.pickle file again.
There are 2 packages with tracking in my my.usps.com dashboard.
2017-06-05 08:55:57 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, entity_id=sensor.usps_mail, new_state=<state sensor.usps_mail=4; icon=mdi:mailbox, attribution=Information provided by www.usps.com, friendly_name=USPS mail @ 2017-06-05T08:55:57.882566-05:00>>
2017-06-05 08:55:58 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 368, in async_process_entity
new_entity, self, update_before_add=update_before_add
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 198, in async_add_entity
yield from self.hass.async_add_job(entity.update)
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/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 78, in update
for package in myusps.get_packages(self._session):
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/myusps/__init__.py", line 155, in wrapped
return function(*args)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/myusps/__init__.py", line 188, in get_packages
'tracking_number': _get_tracking_number(row),
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/myusps/__init__.py", line 118, in _get_tracking_number
return row.find(TRACKING_NUMBER_TAG, TRACKING_NUMBER_ATTRS).string.strip()
AttributeError: 'NoneType' object has no attribute 'strip'
It should either say : “You currently have no scheduled deliveries.” or have packages information. I don’t have any package coming right now, but maybe something has changed again…
Hi everyone:
I’m having a similar authentication issue:
2017-06-06 01:36:38 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform usps
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 160, 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/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/usps.py", line 45, in setup_platform
cookie_path=cookie)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 237, in get_session
_login(session)
File "/home/homeassistant/.homeassistant/deps/myusps/__init__.py", line 137, in _login
if resp.json()['rs'] != 'success':
KeyError: 'rs'
I’m certain the password is correct. I changed it several times to be sure, and I tried changing to a password without special characters, in case that was the issue. I tried deleting the myusps_cookies.pickle file. I tried updating the init.py file in the virtual environment and in the main filesystem. I have version 1.1.1 of myusps and version 0.46.0 of home assistant running on a raspberry pi 3 from the all-in-one installer. Python is version 3.4.2.
Do y’all think the problem is my version of python? Is there a workaround?
Thanks sincerely to this community and to @happyleaves 's work on home assistant and the USPS python program.
2017-06-07 14:51:16 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform usps
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 155, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
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/sensor/usps.py”, line 45, in setup_platform
cookie_path=cookie)
File “/srv/homeassistant/lib/python3.4/site-packages/myusps/init.py”, line 237, in get_session
_login(session)
File “/srv/homeassistant/lib/python3.4/site-packages/myusps/init.py”, line 137, in _login
if resp.json()[‘rs’] != ‘success’:
KeyError: ‘rs’
@happyleaves - I can confirm that python-myusps 1.1.2 is working for me too. @Coolie1101 - to implement the new version, I replaced the contents of the following file: