fix: sync all supported Mi Fitness data types by default

This commit is contained in:
binglua committed 2026-06-29 02:21:44 +00:00
1 parent c901e712d7
commit f73fcb6659
1 file changed
+15 -24
+15 -24
View File
@@ -244,30 +244,21 @@ class MiFitnessCloudAdapter(DataAdapter):
return preferred_region return preferred_region
async def _discover_data_types(self) -> list[str]: async def _discover_data_types(self) -> list[str]:
types: list[str] = [] # The cloud API does not provide a reliable capability endpoint. The
probes = { # previous implementation probed a fixed historical range, which made
"daily_activity": "steps", # automatic sync silently skip most metrics when that range had no data.
"heart_rate": "heart_rate", # Return all data types supported by this adapter; syncing a type with no
"body_measurements": "weight", # records is safe and preferable to missing recent data.
"sleep": "sleep", return [
"spo2": "spo2", "daily_activity",
"stress": "stress", "heart_rate",
"abnormal_heart_beat": "abnormal_heart_beat", "body_measurements",
} "sleep",
for data_type, key in probes.items(): "workouts",
try: "spo2",
items = await self._fetch_key(key, "2025-04-01", "2025-05-31") "stress",
if items: "abnormal_heart_beat",
types.append(data_type) ]
except Exception:
continue
try:
items = await self._fetch_sport_records_by_time("2025-04-01", "2025-05-31")
if items:
types.append("workouts")
except Exception:
pass
return types
def _record_datetime(self, item: dict) -> datetime: def _record_datetime(self, item: dict) -> datetime:
timestamp = int(item.get("time", 0)) timestamp = int(item.get("time", 0))