wyze_get_scale_records
Retrieve weight measurement records from a Wyze scale by specifying the device MAC, user ID, and desired time range. Access historical data for health tracking purposes.
Instructions
Get weight measurement records from a Wyze scale
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days_back | No | ||
| device_mac | No | ||
| user_id | No |
Implementation Reference
- src/mcp_wyze_server/server.py:307-352 (handler)The handler function decorated with @mcp.tool(), implementing the core logic for retrieving scale records using the Wyze SDK. It calculates a time range based on days_back, fetches records via client.scales.get_records(), processes them into a structured list with measurements like weight, BMI, body fat, etc., and handles various errors.@mcp.tool() def wyze_get_scale_records( device_mac: str = None, user_id: str = None, days_back: int = 30 ) -> Dict[str, Any]: """Get weight measurement records from a Wyze scale""" try: from datetime import datetime, timedelta client = get_wyze_client() # Calculate time range end_time = datetime.now() start_time = end_time - timedelta(days=days_back) records = client.scales.get_records( user_id=user_id, start_time=start_time, end_time=end_time ) record_list = [] for record in records: record_info = { "measure_time": int(record.measure_ts) if hasattr(record, 'measure_ts') and record.measure_ts else None, "weight": float(record.weight) if hasattr(record, 'weight') and record.weight is not None else None, "bmi": float(record.bmi) if hasattr(record, 'bmi') and record.bmi is not None else None, "body_fat": float(record.body_fat) if hasattr(record, 'body_fat') and record.body_fat is not None else None, "muscle_mass": float(record.muscle) if hasattr(record, 'muscle') and record.muscle is not None else None, "heart_rate": int(record.heart_rate) if hasattr(record, 'heart_rate') and record.heart_rate is not None else None, } record_list.append(record_info) return { "status": "success", "records": record_list, "count": len(record_list), "days_back": days_back } except WyzeClientConfigurationError as e: return {"status": "error", "message": f"Configuration error: {str(e)}"} except WyzeRequestError as e: return {"status": "error", "message": f"API error: {str(e)}"} except Exception as e: return {"status": "error", "message": f"Unexpected error: {str(e)}"}