Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored Mar 5, 2024
1 parent 29e9fad commit 9199672
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def get(self, key, default=None):
class GirthGoalsResponse(BaseModel):
status_code: str
status_message: str
terminal_user_session_key: str
girth_goals: List[GirthGoal]
new_bodyage_logic_flag: int
cooling_period_flag: int
Expand Down Expand Up @@ -696,7 +695,7 @@ async def get_device_info(self):
return None

# Check for successful response code
if parsed.get("status_code") == "20000":
if parsed.get("status_code") == "20000" and "device_binds_ary" in parsed:
device_info = [DeviceBind(**device) for device in parsed["device_binds_ary"]]
self.device_info = device_info
return device_info
Expand Down Expand Up @@ -744,8 +743,8 @@ async def list_girth(self):

if "status_code" in parsed and parsed["status_code"] == "20000":
response = GirthResponse(**parsed)
self.girth_info = response.get("girths", {})
return parsed
self.girth_info = response.girths
return self.girth_info
else:
_LOGGER.error(f"Error fetching girth info: {parsed.get('status_message')}")
return None
Expand All @@ -767,11 +766,10 @@ async def list_girth_goal(self):
return None

if "status_code" in parsed and parsed["status_code"] == "20000":
_LOGGER.error(f"parsed: {parsed}")
response = GirthGoalsResponse(**parsed)
self.girth_goal = GirthGoal(**response.get("girth_goals", {}))
self.girth_goal = response.girth_goals
self._last_updated_girth_goal = time.time()
return parsed
return self.girth_goal
else:
_LOGGER.error(f"Error fetching girth goal: {parsed.get('status_message')}")
return None
Expand Down

0 comments on commit 9199672

Please sign in to comment.