Skip to content

Commit

Permalink
Fixed invalid changes handling
Browse files Browse the repository at this point in the history
- Error after a few requests would surface
  • Loading branch information
alryaz authored Sep 4, 2020
1 parent 8dd1814 commit d498fd5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/pandora_cas/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ async def async_fetch_changes(self, timestamp: Optional[int] = None,

_timestamp = self._last_update if timestamp is None else timestamp
async with session.get(self.BASE_URL + '/api/updates', params={'ts': _timestamp}) as response:
content: Dict[str, Any] = await response.json()
content: Dict[str, Any] = await self._handle_response(response)

updated_device_ids = set()

# Time updates
if content['time']:
if content.get('time'):
for device_id, times_data in content['time'].items():
device_object = self.get_device(device_id)
if device_object:
Expand All @@ -420,7 +420,7 @@ async def async_fetch_changes(self, timestamp: Optional[int] = None,
% (device_id,))

# Stats updates
if content['stats']:
if content.get('stats'):
for device_id, stats_data in content['stats'].items():
device_object = self.get_device(device_id)
if device_object:
Expand Down

0 comments on commit d498fd5

Please # to comment.