Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -11,7 +11,7 @@ from . import DATA_USPS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
STATUS_DELIVERED = 'delivered'
|
||||
STATUS_DELIVERED = "delivered"
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
@@ -36,7 +36,7 @@ class USPSPackageSensor(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return '{} packages'.format(self._name)
|
||||
return "{} packages".format(self._name)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -48,14 +48,11 @@ class USPSPackageSensor(Entity):
|
||||
self._usps.update()
|
||||
status_counts = defaultdict(int)
|
||||
for package in self._usps.packages:
|
||||
status = slugify(package['primary_status'])
|
||||
if status == STATUS_DELIVERED and \
|
||||
package['delivery_date'] < now().date():
|
||||
status = slugify(package["primary_status"])
|
||||
if status == STATUS_DELIVERED and package["delivery_date"] < now().date():
|
||||
continue
|
||||
status_counts[status] += 1
|
||||
self._attributes = {
|
||||
ATTR_ATTRIBUTION: self._usps.attribution
|
||||
}
|
||||
self._attributes = {ATTR_ATTRIBUTION: self._usps.attribution}
|
||||
self._attributes.update(status_counts)
|
||||
self._state = sum(status_counts.values())
|
||||
|
||||
@@ -67,12 +64,12 @@ class USPSPackageSensor(Entity):
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend."""
|
||||
return 'mdi:package-variant-closed'
|
||||
return "mdi:package-variant-closed"
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
return 'packages'
|
||||
return "packages"
|
||||
|
||||
|
||||
class USPSMailSensor(Entity):
|
||||
@@ -88,7 +85,7 @@ class USPSMailSensor(Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return '{} mail'.format(self._name)
|
||||
return "{} mail".format(self._name)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@@ -109,7 +106,7 @@ class USPSMailSensor(Entity):
|
||||
attr = {}
|
||||
attr[ATTR_ATTRIBUTION] = self._usps.attribution
|
||||
try:
|
||||
attr[ATTR_DATE] = str(self._usps.mail[0]['date'])
|
||||
attr[ATTR_DATE] = str(self._usps.mail[0]["date"])
|
||||
except IndexError:
|
||||
pass
|
||||
return attr
|
||||
@@ -117,9 +114,9 @@ class USPSMailSensor(Entity):
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend."""
|
||||
return 'mdi:mailbox'
|
||||
return "mdi:mailbox"
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
return 'pieces'
|
||||
return "pieces"
|
||||
Reference in new issue
Block a user