Fix currency presentation and update resilience
Validate / syntax (push) Canceled after 0s

This commit is contained in:
git
2026-09-27 17:56:08 +10:00
parent 264a7dd42f
commit 4dcf2f04c5
5 changed files with 21 additions and 8 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ class UpApi:
if response.status >= 400:
raise UpApiError(f"Up API request failed ({response.status})")
return (await response.json())["data"]
except aiohttp.ClientError as err:
except (aiohttp.ClientError, TimeoutError) as err:
raise UpApiError("Unable to reach the Up API") from err
async def _list(
@@ -70,5 +70,5 @@ class UpApi:
if response.status >= 400:
raise UpApiError(f"Up API request failed ({response.status})")
return await response.json()
except aiohttp.ClientError as err:
except (aiohttp.ClientError, TimeoutError) as err:
raise UpApiError("Unable to reach the Up API") from err
+4 -1
View File
@@ -59,7 +59,10 @@ class UpCoordinator(DataUpdateCoordinator[dict[str, dict[str, Any]]]):
for tx_id, saved in list(self._seen.items()):
if saved["status"] != "HELD":
continue
current = await self.api.transaction(tx_id)
try:
current = await self.api.transaction(tx_id)
except UpApiError as err:
raise UpdateFailed(str(err)) from err
if current is None:
# A held item that no longer exists was deleted by Up.
payload = dict(saved["event"])
+1 -1
View File
@@ -21,7 +21,7 @@ def transaction_event(transaction: dict[str, Any], event_type: str) -> dict[str,
"status": attrs["status"].lower(),
"account_id": account.get("id"),
"amount": money["value"],
"currency": money["currencyCode"],
"currency": "$",
"description": attrs.get("description", ""),
"created_at": attrs.get("createdAt"),
"raw_text": attrs.get("rawText"),