'Update device state.'

def update(self):

    import myusps
    status_counts = defaultdict(int)
    for package in myusps.get_packages(self._session):
        status = slugify(package['primary_status'])
        if ((status == STATUS_DELIVERED) and (parse_datetime(package['date']).date() < now().date())):
            continue
        status_counts[status] += 1
    self._attributes = {ATTR_ATTRIBUTION: myusps.ATTRIBUTION}
    self._attributes.update(status_counts)
    self._state = sum(status_counts.values())
