From 8c27bf8c7c20973c105ff94c96b4a90c24991c41 Mon Sep 17 00:00:00 2001 From: Bas Date: Fri, 11 Jan 2019 23:59:31 +0100 Subject: [PATCH] Expose more information about shipments by PostNL (#18334) * Expose more information about shipments by PostNL * Update postnl.py --- homeassistant/components/sensor/postnl.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/sensor/postnl.py b/homeassistant/components/sensor/postnl.py index 5c70ca035cf..84cb42c0957 100644 --- a/homeassistant/components/sensor/postnl.py +++ b/homeassistant/components/sensor/postnl.py @@ -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)