Skip to content

Commit ae58d17

Browse files
fix: no future order edge case handling (#25)
* fix: updated time parsing * fix: improper handling of non-iso time - added zfill * chore: update version * fix: Split out the handling of no future order with past emails within the IMAP search range so it no longer results in comparing a None to a datetime.
1 parent a7c86db commit ae58d17

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

custom_components/ocado/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"BeautifulSoup4>=4.10.0"
1717
],
1818
"single_config_entry": true,
19-
"version": "1.1.5"
19+
"version": "1.1.6"
2020
}

custom_components/ocado/sensor.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,20 @@ def _handle_coordinator_update(self) -> None:
255255
now = datetime.now()
256256
# Switch between orders depending on edit deadlines or output None
257257
order = ocado_data.get("next")
258-
if (order is None) or (order.edit_datetime < now):
258+
if (order is None):
259259
order = ocado_data.get("upcoming")
260260
if order is not None:
261261
if order.edit_datetime < now:
262262
order = None
263-
264263
if order is not None:
265-
result = set_edit_order(self, order, now) # type: ignore
266-
_LOGGER.debug("Set_order returned %s", result)
264+
if (order.edit_datetime < now):
265+
order = ocado_data.get("upcoming")
266+
if order is not None:
267+
if order.edit_datetime < now:
268+
order = None
269+
else:
270+
result = set_edit_order(self, order, now) # type: ignore
271+
_LOGGER.debug("Set_order returned %s", result)
267272
else:
268273
self._attr_state = None
269274
self._attr_icon = "mdi:help-circle"

0 commit comments

Comments
 (0)