Skip to content

Commit

Permalink
Adding retry mode for geofencing pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneNulschDE committed Apr 11, 2024
1 parent 581652e commit 0ecd89c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions custom_components/mbapi2020/car.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Define the objects to store care data."""

from __future__ import annotations

import collections
Expand Down Expand Up @@ -189,6 +190,7 @@ class Car:
geofence_events: GeofenceEvents
baumuster_description: str = ""
has_geofencing: bool = True
geo_fencing_retry_counter: int = 0

def __init__(self, vin: str):
"""Initialize the Car instance."""
Expand Down
8 changes: 5 additions & 3 deletions custom_components/mbapi2020/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
LOGGER = logging.getLogger(__name__)

DEBUG_SIMULATE_PARTIAL_UPDATES_ONLY = False
GEOFENCING_MAX_RETRIES = 3


class Client: # pylint: disable-too-few-public-methods
Expand Down Expand Up @@ -1229,7 +1230,8 @@ async def update_poll_states(self, vin: str):
geofencing_violotions[-1].get("time"),
)
car.has_geofencing = True
car.geo_fencing_retry_counter = 0
else:
car.has_geofencing = False

# return geofencing_violotions
if car.geo_fencing_retry_counter >= GEOFENCING_MAX_RETRIES:
car.has_geofencing = False
car.geo_fencing_retry_counter = car.geo_fencing_retry_counter + 1

0 comments on commit 0ecd89c

Please sign in to comment.