Add restore, and separate the produce box from add-ons
Validate / hassfest (push) Failing after 8s
Validate / HACS (push) Failing after 17s
Validate / pytest (push) Failing after 8s

Restore is POST /s/submit/restore-delivery, wired to switch.turn_off. Its
popup only exists once an order is actually skipped, which is why it could not
be found earlier; verified end to end by skipping Aug 18 and restoring it.

Fixes two bugs found while testing that. async_fetch treated popup and AJAX
fragments as full pages, so the signed-in heuristic read them as logged out and
skip could never run. And the to-do list mixed box produce with add-ons, which
would have invited deletes with no endpoint behind them: only add-ons are
add/removable, so the entity is now scoped to those.
This commit is contained in:
flan
2026-08-03 20:20:15 +00:00
parent 551d3240a2
commit 5e9d721a0f
7 changed files with 122 additions and 38 deletions
+13 -11
View File
@@ -76,17 +76,19 @@ class FreshHarvestSkip(FreshHarvestEntity, SwitchEntity):
await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs: Any) -> None:
"""Un-skip — deliberately not implemented.
The portal's restore control only appears once an order is already
skipped, so its endpoint has never been observed. Guessing at the way
back from a skip is exactly the kind of thing that should fail loudly
rather than post something plausible at a real order.
"""
raise HomeAssistantError(
"un-skipping is not supported yet: the restore endpoint has not "
"been confirmed. Restore it on freshharvest.com for now."
)
"""Un-skip the delivery."""
order = self.coordinator.data.open_order
if order is None or order.delivery_date is None:
raise HomeAssistantError("no delivery to restore")
try:
result = await self.coordinator.actions.async_restore(
order.delivery_date, dry_run=False
)
except FreshHarvestError as err:
self._fire("restore", False, str(order.delivery_date), str(err))
raise HomeAssistantError(f"could not restore: {err}") from err
self._fire("restore", True, str(order.delivery_date), result.detail)
await self.coordinator.async_request_refresh()
def _fire(self, action: str, ok: bool, target: str, detail: str) -> None:
self.hass.bus.async_fire(