Skip to content

Commit

Permalink
Status message error if there is no colli (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjenbos authored Dec 27, 2024
1 parent 012e3cf commit 8e52de6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/postnl/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ async def transform_shipment(self, shipment) -> Package:

colli = track_and_trace_details.get('colli', {}).get(shipment['barcode'], {})

status_message = "Unknown"

if colli:
if colli.get("routeInformation"):
route_information = colli.get("routeInformation")
Expand All @@ -101,6 +103,8 @@ async def transform_shipment(self, shipment) -> Package:
planned_from = shipment.get('deliveryWindowFrom', None)
planned_to = shipment.get('deliveryWindowTo', None)
expected_datetime = None

status_message = colli.get('statusPhase', {}).get('message', "Unknown")
else:
_LOGGER.debug('Barcode not found in track and trace details.')
_LOGGER.debug(track_and_trace_details)
Expand All @@ -113,7 +117,7 @@ async def transform_shipment(self, shipment) -> Package:
key=shipment.get('key'),
name=shipment.get('title'),
url=shipment.get('detailsUrl'),
status_message=colli.get('statusPhase', {}).get('message', "Unknown"),
status_message=status_message,
delivered=shipment.get('delivered'),
delivery_date=shipment.get('deliveredTimeStamp'),
planned_date=planned_date,
Expand Down

0 comments on commit 8e52de6

Please sign in to comment.