mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Expose more information about shipments by PostNL (#18334)
* Expose more information about shipments by PostNL * Update postnl.py
This commit is contained in:
parent
ab4e1fddd5
commit
8c27bf8c7c
@ -59,7 +59,9 @@ class PostNLSensor(Entity):
|
||||
def __init__(self, api, name):
|
||||
"""Initialize the PostNL sensor."""
|
||||
self._name = name
|
||||
self._attributes = None
|
||||
self._attributes = {
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
}
|
||||
self._state = None
|
||||
self._api = api
|
||||
|
||||
@ -92,18 +94,5 @@ class PostNLSensor(Entity):
|
||||
def update(self):
|
||||
"""Update device state."""
|
||||
shipments = self._api.get_relevant_shipments()
|
||||
status_counts = {}
|
||||
|
||||
for shipment in shipments:
|
||||
status = shipment['status']['formatted']['short']
|
||||
status = self._api.parse_datetime(status, '%d-%m-%Y', '%H:%M')
|
||||
|
||||
name = shipment['settings']['title']
|
||||
status_counts[name] = status
|
||||
|
||||
self._attributes = {
|
||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||
**status_counts
|
||||
}
|
||||
|
||||
self._state = len(status_counts)
|
||||
self._attributes['shipments'] = shipments
|
||||
self._state = len(shipments)
|
||||
|
Loading…
x
Reference in New Issue
Block a user