Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USPS Sensor errors #7918

Closed
brianjking opened this issue Jun 5, 2017 · 9 comments
Closed

USPS Sensor errors #7918

brianjking opened this issue Jun 5, 2017 · 9 comments

Comments

@brianjking
Copy link

brianjking commented Jun 5, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):

0.46

Python release (python3 --version):

Python 3.4.2

Component/platform:

sensor.usps

Description of problem:

USPS Sensor should show Informed Delivery as well as Packages. Only Informed Delivery shows, generally requires deletion of usps_cookies.pickle in between restarts now as well.

Expected:

  • Should show USPS Informed delivery & USPS packages. I do have scheduled packages in my my.usps.com dashboard with valid tracking, including one out for delivery right now.

Problem-relevant configuration.yaml entries and steps to reproduce:

- platform: usps
  username: !secret usps_username
  password: !secret usps_password
  name: 'USPS'
- platform: template
  sensors:
      packages_in_transit:
        friendly_name: "Packages in Transit"
        value_template: >
          {% macro in_transit(sensor) %}
            {{sensor.state|int - delivered(sensor)|int}}
          {% endmacro %}
          {% macro delivered(sensor) %}
            {% if 'delivered' in sensor.attributes %}
              {{sensor.attributes.delivered}}
            {% else %}
               0
            {% endif %}
          {% endmacro %}
          {{in_transit(states.sensor.usps_packages)|int + in_transit(states.sensor.fedex)|int}}
      deliveries_today:
        friendly_name: "Today's Deliveries"
        value_template: >
          {% macro delivered(sensor) %}
            {% if 'delivered' in sensor.attributes %}
              {{sensor.attributes.delivered}}
            {% else %}
               0
            {% endif %}
          {% endmacro %}
          {{delivered(states.sensor.usps_packages)|int + delivered(states.sensor.fedex)|int}}

Traceback (if applicable):

2017-06-05 12:14:11 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.usps_mail, new_state=<state sensor.usps_mail=4; icon=mdi:mailbox, friendly_name=USPS mail, attribution=Information provided by www.usps.com @ 2017-06-05T12:14:11.648612-05:00>, old_state=None>
2017-06-05 12:14:12 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'

Additional info:

  • Relevant forum thread

  • Paging @happyleavesaoc Thank you for all that you do, please advise as to how I might be able to fix this whenever you have a chance.

ad6343e001b5f79aea28ae2d2ef4db6adc02911f 1

@happyleavesaoc
Copy link
Contributor

@brianjking Appears to be a bug in python-myusps. It will need to be fixed and updated in HA.

@brianjking
Copy link
Author

@happyleavesaoc Ok, thanks. I guess it's not just broken for me then. Let me know if you fix it in python-myusps and I can manually update without waiting for 0.47 HA.

@happyleavesaoc
Copy link
Contributor

happyleavesaoc commented Jun 5, 2017

@brianjking It's broken because one of your tracked packages probably doesn't have a tracking number. Check for that if you can and just delete that one. See if that helps.

@brianjking
Copy link
Author

myusps

@happyleavesaoc Both of my packages are both valid tracking #'s.

@brianjking
Copy link
Author

brianjking commented Jun 5, 2017

I also have to delete the usps_cookies.pickle everytime I restart HA all of the sudden. Otherwise not even the USPS Mail sensor loads.

@brianjking
Copy link
Author

image

@happyleavesaoc -- It now shows the packages after I deleted the custom names. However, it's still not showing that one is out for delivery (has been since 9:00am and it's currently 13:19hr).

@happyleavesaoc
Copy link
Contributor

@brianjking Ah! The custom name is not accounted for in python-myusps. I have fixed this locally.

I'm not sure yet about your other two issues.

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@balloobbot
Copy link

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants