Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBrink committed Sep 12, 2020
2 parents 47cb84e + b4882cc commit 5e0eea5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/picnic/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""The picnic Component"""
"""The Picnic Component"""
13 changes: 8 additions & 5 deletions custom_components/picnic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def async_update(self):
def _get_data(self):
# try:
self.cart = self._api.get_cart()
self.current_deliveries = self._api.get_current_deliveries()
self.current_deliveries = self._api.get_deliveries()[0]
self.open_delivery_time_slots = self.cart["delivery_slots"]
_LOGGER.debug("Updated data from Picnic")

Expand Down Expand Up @@ -164,14 +164,12 @@ async def async_update(self):
if not delivery:
return

delivery = delivery[0]

data = {}
data["creation_time"] = delivery["creation_time"]
data["delivery_id"] = delivery["delivery_id"]
data.update(delivery["slot"])

if "eta2" in delivery:
if "eta2" in delivery.keys():
data["window_start"] = delivery["eta2"]["start"]
data["window_end"] = delivery["eta2"]["end"]

Expand All @@ -181,7 +179,12 @@ async def async_update(self):

self._attributes[ATTR_DELIVERY] = data

self._state = data["window_start"]
if delivery["status"] == "COMPLETED":
self._state = "order_delivered"
elif "eta2" in delivery.keys():
self._state = "order_announced"
elif delivery["status"] == "CURRENT":
self._state = "order_placed"

@property
def name(self):
Expand Down

0 comments on commit 5e0eea5

Please sign in to comment.