Skip to content

Commit

Permalink
Fixed issue with S-series scales not retrieving latest records (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
shauntarves authored May 6, 2023
1 parent a0a1c29 commit 9678486
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions wyze_sdk/api/devices/scales.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ def info(self, *, device_mac: str, **kwargs) -> Optional[Scale]:
# if "data" in device_info.data:
# scale.update(device_info.data["data"])

if self._user_id is not None:
now = datetime.now()
latest_records = super()._scale_client(scale['product_model']).get_records(user_id=self._user_id, start_time=now-timedelta(days=5), end_time=now)
if "data" in latest_records.data and latest_records.data['data'] is not None:
scale.update({"latest_records": latest_records.data["data"]})
now = datetime.now()
latest_records = super()._scale_client(scale['product_model']).get_records(user_id=self._user_id, start_time=now-timedelta(days=5), end_time=now)
if "data" in latest_records.data and latest_records.data['data'] is not None:
scale.update({"latest_records": latest_records.data["data"]})
elif scale['product_model'] in DeviceModels.SCALE_X:
raise WyzeFeatureNotSupportedError('Scale Series X')
else:
Expand Down

0 comments on commit 9678486

Please sign in to comment.