Skip to content

Commit

Permalink
fix: catch 4xx errors when fetching balance and continue if it appears (
Browse files Browse the repository at this point in the history
  • Loading branch information
geertmeersman authored Jan 9, 2025
2 parents e1bcd8a + dffebaf commit ffb8f63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.5
v1.0.6-beta.9
26 changes: 16 additions & 10 deletions custom_components/mobile_vikings/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,22 @@ async def get_subscriptions(self):
f"/subscriptions/{subscription_id}/modem/settings"
)
else:
# Check if the 'sim' field exists and 'msisdn' is not empty
sim_info = subscription.get("sim", {})
if sim_info.get("msisdn"):
balance = await self.handle_request(
f"/subscriptions/{subscription_id}/balance"
)
subscription["balance"] = balance
subscription["balance_aggregated"] = self.aggregate_bundles_by_type(
balance
)
# Check if the 'sim' field exists and 'msisdn' is not empty
sim_info = subscription.get("sim", {})
if sim_info.get("msisdn"):
try:
balance = await self.handle_request(
f"/subscriptions/{subscription_id}/balance"
)
subscription["balance"] = balance
subscription["balance_aggregated"] = self.aggregate_bundles_by_type(
balance
)
except Exception as e:
_LOGGER.debug(
f"Failed to retrieve balance for subscription {subscription_id}: {e}"
)
# Continue without setting the balance if there's an error
subscription["product"] = await self.get_product_details(
subscription.get("product_id")
)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/mobile_vikings/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/geertmeersman/mobile_vikings/issues",
"requirements": [],
"version": "v1.0.5"
"version": "v1.0.6-beta.9"
}

0 comments on commit ffb8f63

Please sign in to comment.