diff --git a/homeassistant/components/sensor/ups.py b/homeassistant/components/sensor/ups.py index 40d84fe2618..c51ae67475f 100644 --- a/homeassistant/components/sensor/ups.py +++ b/homeassistant/components/sensor/ups.py @@ -76,17 +76,26 @@ class UPSSensor(Entity): """Return the state of the sensor.""" return self._state + @property + def unit_of_measurement(self): + """Return the unit of measurement of this entity, if any.""" + return 'packages' + def _update(self): """Update device state.""" import upsmychoice status_counts = defaultdict(int) - for package in upsmychoice.get_packages(self._session): - status = slugify(package['status']) - skip = status == STATUS_DELIVERED and \ - parse_date(package['delivery_date']) < now().date() - if skip: - continue - status_counts[status] += 1 + try: + for package in upsmychoice.get_packages(self._session): + status = slugify(package['status']) + skip = status == STATUS_DELIVERED and \ + parse_date(package['delivery_date']) < now().date() + if skip: + continue + status_counts[status] += 1 + except upsmychoice.UPSError: + _LOGGER.error('Could not connect to UPS My Choice account') + self._attributes = { ATTR_ATTRIBUTION: upsmychoice.ATTRIBUTION }