UPS package tracking through UPS My Choice

Maybe @happyleaves can provide further assistance.

This error has been fixed on UPS version 1.0.5 onward. Hopefully 0.47 will have it.

Saw that earlier.

Just checked again, and it looks like it was fixed and updated.

Will try again tomorrow, and report back.

"J-CMartin
commented about 3 hours ago

Glad to report that the Pull Request was approved and the JSONDecodeError is fixed on the UPS component 1.0.5 onward. No more manual edits"

How do we apply this fix?

Waiting for @happyleaves to approve the pull request. Should be soon.

Version 1.0.6 is updated on GitHub. Goal is to have it on 0.47.

Thanks @happyleaves

I installed 1.0.6 and now getting the following error.

2017-06-07 08:25:49 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform ups
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/upsmychoice/init.py”, line 84, in wrapped
return function(*args)
File “/home/homeassistant/.homeassistant/deps/upsmychoice/init.py”, line 99, 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 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/ups.py”, line 55, in setup_platform
config.get(CONF_UPDATE_INTERVAL))])
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/ups.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/ups.py”, line 84, in _update
for package in upsmychoice.get_packages(self._session):
File “/home/homeassistant/.homeassistant/deps/upsmychoice/init.py”, line 86, in wrapped
_login(*args)
File “/home/homeassistant/.homeassistant/deps/upsmychoice/init.py”, line 76, in _login
_save_cookies(session.cookies, cookie_path)
File “/home/homeassistant/.homeassistant/deps/upsmychoice/init.py”, line 40, in _save_cookies
with open(filename, ‘wb’) as handle:
PermissionError: [Errno 13] Permission denied: ‘./upsmychoice_cookies.pickle’

What’s in your log looks like old code. Try copying the contents from this URL below into this file:

https://raw.githubusercontent.com/happyleavesaoc/python-upsmychoice/master/upsmychoice/__init__.py

ImportError: cannot import name ‘JSONDecodeError’

Thank you.

They both work.

FYI: I had to “pip install myusps==1.1.1”

I would like to see all the other information the upsmychoice component scrapes from UPS in the sensor as well. What I am trying to say is, right now the sensor only shows the total count of inbound packages, while the component is also getting information on the sender and the estimated delivery date/timeframe:

https://raw.githubusercontent.com/happyleavesaoc/python-upsmychoice/master/upsmychoice/init.py :

            'tracking_number': shipment['tn'],
            'status': shipment['sts'],
            'from': shipment['sfn'],
            'from_location': from_location,
            'estimated_delivery_date': estimated_date,
            'estimated_delivery_timeframe': shipment['sdtfd'],
            'delivery_date': actual_date

How to get the other information to display in the sensor card, potentially as an option? I am in no way a code guru in Python :slight_smile:

@Hmmbob
Were you able to figure this out?

1 Like